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"
50 #include "bt-service-dpm.h"
51 #include "bt-service-hidhost.h"
52 #include "bt-service-rfcomm.h"
53 #include "bt-service-hdp.h"
56 #include "bt-service-obex-server.h"
57 #include "bt-service-opp-client.h"
58 #include "bt-service-map-client.h"
59 #include "bt-service-pbap.h"
60 #include "bt-service-oob.h"
62 #include "bt-service-battery-monitor.h"
64 #ifdef TIZEN_FEATURE_BT_PAN_NAP
65 #include "bt-service-network.h"
68 #ifdef TIZEN_FEATURE_BT_IPSP
69 #include "bt-service-ipsp.h"
71 /* For maintaining Application Sync API call requests */
72 static GSList *invocation_list = NULL;
74 static GDBusConnection *bt_service_conn;
75 static guint owner_id = 0;
76 static guint owner_sig_id = 0;
77 static gboolean is_le_intended = FALSE;
79 static cynara *p_cynara;
80 static cynara_configuration *conf;
81 static const char *requester_unique_creds = NULL;
83 static const gchar bt_service_introspection_xml[] =
84 "<node name='/org/projectx/bt_service'>"
85 " <interface name='org.projectx.bt'>"
86 " <method name='service_request'>"
87 /* Input Parameters */
88 " <arg type='i' name='service_type' direction='in' />"
89 " <arg type='i' name='service_function' direction='in' />"
90 " <arg type='i' name='request_type' direction='in' />"
91 " <arg type='ay' name='input_param1' direction='in' />"
92 " <arg type='ay' name='input_param2' direction='in' />"
93 " <arg type='ay' name='input_param3' direction='in' />"
94 " <arg type='ay' name='input_param4' direction='in' />"
95 " <arg type='ay' name='input_param5' direction='in' />"
96 /* Return Parameters */
97 " <arg type='i' name='output_param1' direction='out' />"
98 " <arg type='v' name='output_param2' direction='out' />"
100 " <method name='get_avc_mode'>"
102 " <arg type='u' name='avc_mode' direction='out' />"
107 static gboolean name_acquired = FALSE;
109 static char *current_sender_playing = NULL;
111 GDBusNodeInfo *node_info_g = NULL;
113 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param);
115 static void __bt_service_method(GDBusConnection *connection,
117 const gchar *object_path,
118 const gchar *interface_name,
119 const gchar *method_name,
120 GVariant *parameters,
121 GDBusMethodInvocation *invocation,
124 int __bt_bluez_request(int function_name,
127 GDBusMethodInvocation *context,
132 GArray **out_param1);
133 int __bt_obexd_request(int function_name,
136 GDBusMethodInvocation *context,
141 GArray **out_param1);
142 int __bt_agent_request(int function_name,
145 GDBusMethodInvocation *context,
150 GArray **out_param1);
151 int __bt_core_request(int function_name,
154 GDBusMethodInvocation *context,
155 GVariant *in_param1);
157 gboolean __bt_service_check_privilege(int function_name,
159 const char *unique_name);
161 /* Function definitions*/
162 GSList *_bt_get_invocation_list(void)
164 return invocation_list;
167 void _bt_free_info_from_invocation_list(invocation_info_t *req_info)
169 ret_if(NULL == req_info);
170 invocation_list = g_slist_remove(invocation_list, req_info);
171 g_free(req_info->sender);
172 g_free(req_info->user_data);
176 void _bt_set_le_intended_status(gboolean value)
178 is_le_intended = value;
181 static void __bt_service_get_parameters(GVariant *in_param,
182 void *value, int size)
185 buf = (void *)g_variant_get_data(in_param);
186 memcpy(value, buf, size);
189 static gboolean __bt_is_sync_function(int service_function)
191 /*TODO: Keep adding sync methods with expect replies from bluetooth service */
192 if (service_function == BT_GET_LOCAL_ADDRESS
193 || service_function == BT_GET_LOCAL_NAME
194 || service_function == BT_GET_LOCAL_VERSION
195 || service_function == BT_GET_BONDED_DEVICES
196 || service_function == BT_GET_BONDED_DEVICE
197 || service_function == BT_GET_PROFILE_CONNECTED_DEVICES
198 || service_function == BT_GET_IS_ALIAS_SET
199 || service_function == BT_GET_CONNECTED_LINK_TYPE
200 || service_function == BT_IS_SERVICE_USED
201 || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
202 || service_function == BT_RFCOMM_LISTEN
203 || service_function == BT_HDP_REGISTER_SINK_APP
204 || service_function == BT_HDP_UNREGISTER_SINK_APP
205 || service_function == BT_HDP_GET_FD
206 || service_function == BT_AVRCP_GET_TRACK_INFO
207 || service_function == BT_AVRCP_CONTROL_GET_PROPERTY
208 || service_function == BT_SET_ADVERTISING_DATA
209 || service_function == BT_SET_SCAN_RESPONSE_DATA
210 || service_function == BT_SET_ADVERTISING
211 || service_function == BT_SET_CUSTOM_ADVERTISING
212 || service_function == BT_GATT_SERVER_REGISTER
213 || service_function == BT_GATT_SERVER_ADD_SERVICE
214 || service_function == BT_GATT_SERVER_ADD_CHARACTERISTIC
215 || service_function == BT_GATT_SERVER_ADD_DESCRIPTOR
216 || service_function == BT_GATT_SERVER_START_SERVICE
217 || service_function == BT_GATT_SERVER_STOP_SERVICE
218 || service_function == BT_GATT_SERVER_DELETE_SERVICE
219 || service_function == BT_START_LE_DISCOVERY
220 || service_function == BT_STOP_LE_DISCOVERY
221 || service_function == BT_GET_CONNECTABLE
222 || service_function == BT_GATT_CLIENT_REGISTER
223 || service_function == BT_GATT_GET_PRIMARY_SERVICES
224 || service_function == BT_GATT_GET_SERVICE_PROPERTIES
225 || service_function == BT_GATT_GET_INCLUDED_SERVICES
226 || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
227 || service_function == BT_GATT_WATCH_CHARACTERISTIC
228 || service_function == BT_GATT_ACQUIRE_WRITE
229 || service_function == BT_AUDIO_SELECT_ROLE
231 || service_function == BT_MESH_NETWORK_CREATE
232 || service_function == BT_MESH_NETWORK_DESTROY
233 || service_function == BT_MESH_NETWORK_LOAD
234 || service_function == BT_MESH_NETWORK_SCAN
235 || service_function == BT_MESH_NETWORK_ADD_NETKEY
236 || service_function == BT_MESH_NETWORK_DELETE_NETKEY
237 || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
238 || service_function == BT_MESH_NETWORK_ADD_APPKEY
239 || service_function == BT_MESH_NETWORK_DELETE_APPKEY
240 || service_function == BT_MESH_NETWORK_UPDATE_APPKEY)
246 void _bt_save_invocation_context(GDBusMethodInvocation *invocation, int result,
247 char *sender, int service_function,
248 gpointer invocation_data)
250 invocation_info_t *info;
251 info = g_malloc0(sizeof(invocation_info_t));
252 info->context = invocation;
253 info->result = result;
254 info->sender = g_strdup(sender);
255 info->service_function = service_function;
256 info->user_data = invocation_data;
257 invocation_list = g_slist_append(invocation_list, info);
261 static int __bt_service_get_sender_pid(const char *unique_name, pid_t *pid)
264 char err_msg[256] = {0, };
266 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
268 ret = cynara_creds_gdbus_get_pid(bt_service_conn, unique_name, pid);
269 if (ret != CYNARA_API_SUCCESS) {
270 cynara_strerror(ret, err_msg, sizeof(err_msg));
271 BT_ERR("Fail to get user credential: %s", err_msg);
273 return BLUETOOTH_ERROR_INTERNAL;
276 return BLUETOOTH_ERROR_NONE;
279 static int __bt_bm_request_data(_bt_battery_data_t *latest)
281 int ret = _bt_bm_read_data(latest);
282 if (ret == BLUETOOTH_ERROR_NONE) {
283 BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
284 latest->session_start_time, latest->session_end_time,
285 latest->session_scan_time, latest->session_connected_time);
287 if (latest->atm_list == NULL) {
288 BT_DBG("No app data transaction for this session");
292 for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
293 _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
294 BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
298 BT_ERR("Error encountered");
302 static void __bt_service_method(GDBusConnection *connection,
304 const gchar *object_path,
305 const gchar *interface_name,
306 const gchar *method_name,
307 GVariant *parameters,
308 GDBusMethodInvocation *invocation,
313 BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
314 method_name, object_path, interface_name);
316 if (g_strcmp0(method_name, "service_request") == 0) {
318 int service_function;
320 GVariant *param1 = NULL;
321 GVariant *param2 = NULL;
322 GVariant *param3 = NULL;
323 GVariant *param4 = NULL;
324 GVariant *param5 = NULL;
325 GArray *out_param1 = NULL;
326 GVariant *out_var = NULL;
327 GVariant *temp = NULL;
331 g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
332 &service_function, &request_type,
333 ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
335 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
337 if (service_type == BT_CORE_SERVICE) {
338 BT_DBG("No need to check privilege from bt-core");
339 } else if (__bt_service_check_privilege(service_function,
340 service_type, (const char *)sender) == FALSE) {
341 BT_ERR("Client don't have the privilege to excute this function");
342 result = BLUETOOTH_ERROR_PERMISSION_DEINED;
346 BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
347 service_type, service_function);
348 switch (service_type) {
349 case BT_BLUEZ_SERVICE:
350 result = __bt_bluez_request(service_function,
351 request_type, request_id,
352 invocation, param1, param2,
353 param3, param4, &out_param1);
355 case BT_OBEX_SERVICE:
356 result = __bt_obexd_request(service_function,
357 request_type, request_id,
360 param4, &out_param1);
362 case BT_AGENT_SERVICE:
363 result = __bt_agent_request(service_function,
364 request_type, request_id,
367 param4, &out_param1);
369 case BT_CORE_SERVICE:
370 result = __bt_core_request(service_function,
371 request_type, request_id,
374 case BT_CHECK_PRIVILEGE:
375 result = BLUETOOTH_ERROR_NONE;
378 BT_ERR("Unknown service type");
379 result = BLUETOOTH_ERROR_INTERNAL;
383 if (result != BLUETOOTH_ERROR_NONE)
386 if (service_type == BT_CHECK_PRIVILEGE)
389 if (service_function == BT_OPP_PUSH_FILES)
392 if (request_type == BT_ASYNC_REQ ||
393 __bt_is_sync_function(service_function)) {
394 /* Do not send reply to bt-api over dbus,
395 Invocation context is already saved in service_function */
400 out_var = g_variant_new_from_data((const GVariantType *)"ay",
401 out_param1->data, out_param1->len,
404 temp = g_variant_new("(iv)", result, out_var);
405 g_dbus_method_invocation_return_value(invocation, temp);
406 g_array_free(out_param1, TRUE);
410 g_variant_unref(param1);
411 g_variant_unref(param2);
412 g_variant_unref(param3);
413 g_variant_unref(param4);
414 g_variant_unref(param5);
418 BT_ERR_C("Request is failed [%s] [0x%x]",
419 _bt_convert_error_to_string(result), result);
421 out_var = g_variant_new_from_data((const GVariantType *)"ay",
422 out_param1->data, out_param1->len,
425 temp = g_variant_new("(iv)", result, out_var);
426 g_dbus_method_invocation_return_value(invocation, temp);
428 g_array_free(out_param1, TRUE);
431 g_variant_unref(param1);
432 g_variant_unref(param2);
433 g_variant_unref(param3);
434 g_variant_unref(param4);
435 g_variant_unref(param5);
437 else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
438 unsigned int mode = 0;
440 if (_bt_audio_get_avc_mode(&mode) != BLUETOOTH_ERROR_NONE)
441 BT_ERR("Fail to get the avc mode");
443 BT_DBG("Absolute Volume Control mode: %d", mode);
445 g_dbus_method_invocation_return_value(invocation,
446 g_variant_new("(u)", mode));
454 static const GDBusInterfaceVTable method_table = {
461 int __bt_bluez_request(int function_name,
464 GDBusMethodInvocation *context,
471 int result = BLUETOOTH_ERROR_NONE;
474 switch (function_name) {
475 case BT_ENABLE_ADAPTER: {
476 result = _bt_enable_adapter();
477 _bt_adapter_start_enable_timer();
480 case BT_DISABLE_ADAPTER: {
481 result = _bt_disable_adapter();
484 case BT_RECOVER_ADAPTER:
485 result = _bt_recover_adapter();
487 case BT_RESET_ADAPTER:
488 result = _bt_reset_adapter();
490 case BT_BATTERY_READ_DATA: {
491 _bt_battery_data_t *data = NULL;
492 data = g_malloc0(sizeof(_bt_battery_data_t));
493 result = __bt_bm_request_data(data);
495 bt_battery_dbus_data_t dbus_data;
496 memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
497 dbus_data.session_start_time = data->session_start_time;
498 dbus_data.session_end_time = data->session_end_time;
499 dbus_data.session_scan_time = data->session_scan_time;
500 dbus_data.session_connected_time = data->session_connected_time;
501 dbus_data.tx_time = data->tx_time;
502 dbus_data.rx_time = data->rx_time;
503 dbus_data.idle_time = data->idle_time;
505 /*Populating app data*/
507 for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
508 bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
509 memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
512 dbus_data.num_app = n;
513 g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
514 g_slist_free_full(data->atm_list, g_free);
519 case BT_CHECK_ADAPTER: {
520 int enabled = BT_ADAPTER_DISABLED;
521 result = _bt_check_adapter(&enabled);
523 g_array_append_vals(*out_param1, &enabled,
527 case BT_ENABLE_ADAPTER_LE:
528 _bt_set_le_intended_status(TRUE);
529 result = _bt_enable_adapter_le();
531 case BT_DISABLE_ADAPTER_LE:
532 _bt_set_le_intended_status(FALSE);
533 result = _bt_disable_adapter_le();
535 case BT_START_DISCOVERY: {
536 unsigned short max_response;
537 unsigned short discovery_duration;
538 unsigned int classOfDeviceMask;
541 __bt_service_get_parameters(in_param1,
542 &max_response, sizeof(unsigned short));
543 __bt_service_get_parameters(in_param2,
544 &discovery_duration, sizeof(unsigned short));
545 __bt_service_get_parameters(in_param3,
546 &classOfDeviceMask, sizeof(unsigned int));
547 __bt_service_get_parameters(in_param4, &uid, sizeof(uid_t));
549 result = _bt_start_discovery(max_response, discovery_duration, classOfDeviceMask);
551 if (result == BLUETOOTH_ERROR_NONE) {
554 sender = (char*)g_dbus_method_invocation_get_sender(context);
556 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
557 BT_ERR("Fail to get the sender pid");
559 BT_DBG("Remeber pid / uid for the scan operation");
560 _bt_bm_add_scan_app(SCAN_REGACY, uid, pid);
565 case BT_START_CUSTOM_DISCOVERY: {
566 bt_discovery_role_type_t role;
568 __bt_service_get_parameters(in_param1,
569 &role, sizeof(bt_discovery_role_type_t));
570 result = _bt_start_custom_discovery(role);
574 case BT_CANCEL_DISCOVERY:
575 result = _bt_cancel_discovery();
577 case BT_IS_DISCOVERYING: {
578 gboolean discovering = FALSE;
579 discovering = _bt_is_discovering();
580 g_array_append_vals(*out_param1,
581 &discovering, sizeof(gboolean));
584 case BT_GET_LOCAL_ADDRESS: {
585 result = _bt_get_local_address();
587 /* Save invocation */
588 if (result == BLUETOOTH_ERROR_NONE) {
589 sender = (char*)g_dbus_method_invocation_get_sender(context);
590 _bt_save_invocation_context(context, result, sender,
591 function_name, NULL);
595 case BT_GET_LOCAL_VERSION: {
596 result = _bt_get_local_version();
598 /* Save invocation */
599 if (result == BLUETOOTH_ERROR_NONE) {
600 sender = (char*)g_dbus_method_invocation_get_sender(context);
601 _bt_save_invocation_context(context, result, sender,
602 function_name, NULL);
606 case BT_GET_LOCAL_NAME: {
607 result = _bt_get_local_name();
609 /* Save invocation */
610 if (result == BLUETOOTH_ERROR_NONE) {
611 sender = (char*)g_dbus_method_invocation_get_sender(context);
612 _bt_save_invocation_context(context, result, sender,
613 function_name, NULL);
617 case BT_SET_LOCAL_NAME: {
618 bluetooth_device_name_t local_name = { {0} };
619 __bt_service_get_parameters(in_param1,
620 &local_name, sizeof(bluetooth_device_name_t));
621 result = _bt_set_local_name(local_name.name);
624 case BT_GET_DISCOVERABLE_MODE: {
625 int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
626 result = _bt_get_discoverable_mode(&discoverable_mode);
627 g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
630 case BT_GET_DISCOVERABLE_TIME: {
633 result = _bt_get_timeout_value(&timeout);
634 g_array_append_vals(*out_param1, &timeout, sizeof(int));
637 case BT_SET_DISCOVERABLE_MODE: {
638 int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
641 __bt_service_get_parameters(in_param1, &mode, sizeof(int));
642 __bt_service_get_parameters(in_param2, &time, sizeof(int));
644 result = _bt_set_discoverable_mode(mode, time);
647 case BT_IS_CONNECTABLE: {
648 gboolean is_connectable = FALSE;
650 is_connectable = _bt_is_connectable();
651 g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
654 case BT_GET_CONNECTABLE: {
655 result = _bt_get_connectable();
657 /* Save invocation */
658 if (result == BLUETOOTH_ERROR_NONE) {
659 sender = (char*)g_dbus_method_invocation_get_sender(context);
660 _bt_save_invocation_context(context, result, sender,
661 function_name, NULL);
665 case BT_SET_CONNECTABLE: {
666 gboolean is_connectable;
668 __bt_service_get_parameters(in_param1,
669 &is_connectable, sizeof(gboolean));
670 result = _bt_set_connectable(is_connectable);
673 case BT_IS_SERVICE_USED: {
676 uuid = (char *)g_variant_get_data(in_param1);
677 BT_INFO("UUID to be searched [%s]", uuid);
678 result = _bt_is_service_used();
680 /* Save invocation */
681 if (result == BLUETOOTH_ERROR_NONE) {
682 sender = (char*)g_dbus_method_invocation_get_sender(context);
683 _bt_save_invocation_context(context, result, sender,
684 function_name, g_strdup(uuid));
688 case BT_GET_BONDED_DEVICES: {
689 result = _bt_get_bonded_devices();
690 /* Save invocation */
691 if (result == BLUETOOTH_ERROR_NONE) {
692 sender = (char*)g_dbus_method_invocation_get_sender(context);
693 _bt_save_invocation_context(context, result, sender,
694 function_name, NULL);
698 case BT_GET_BONDED_DEVICE: {
699 bluetooth_device_address_t address = { {0} };
701 __bt_service_get_parameters(in_param1,
702 &address, sizeof(bluetooth_device_address_t));
704 result = _bt_get_bonded_device_info(&address);
705 /* Save invocation */
706 if (result == BLUETOOTH_ERROR_NONE) {
707 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
709 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
713 _bt_convert_addr_type_to_string(addr, address.addr);
714 sender = (char*)g_dbus_method_invocation_get_sender(context);
715 _bt_save_invocation_context(context, result, sender,
716 function_name, addr);
720 case BT_GET_PROFILE_CONNECTED_DEVICES: {
722 uuid = (char *)g_variant_get_data(in_param1);
723 result = _bt_get_profile_connected_devices(uuid);
725 /* Save invocation */
726 if (result == BLUETOOTH_ERROR_NONE) {
727 sender = (char *)g_dbus_method_invocation_get_sender(context);
728 _bt_save_invocation_context(context, result, sender,
729 function_name, NULL);
734 bluetooth_device_address_t address = { {0} };
735 const char *local_name;
737 __bt_service_get_parameters(in_param1,
738 &address, sizeof(bluetooth_device_address_t));
739 local_name = (const char *)g_variant_get_data(in_param2);
741 result = _bt_set_alias(&address, local_name);
744 case BT_BOND_DEVICE: {
745 bluetooth_device_address_t address = { {0} };
747 __bt_service_get_parameters(in_param1,
748 &address, sizeof(bluetooth_device_address_t));
749 result = _bt_bond_device(&address, BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
751 /* Save invocation */
752 if (result == BLUETOOTH_ERROR_NONE) {
753 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
754 _bt_convert_addr_type_to_string(addr, address.addr);
755 sender = (char*)g_dbus_method_invocation_get_sender(context);
756 _bt_save_invocation_context(context, result, sender,
757 function_name, (gpointer)addr);
759 bluetooth_device_info_t dev_info;
761 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
762 memcpy(&dev_info.device_address, &address,
763 sizeof(bluetooth_device_address_t));
764 g_array_append_vals(*out_param1, &dev_info,
765 sizeof(bluetooth_device_info_t));
769 case BT_BOND_DEVICE_BY_TYPE: {
770 bluetooth_device_address_t address = { {0} };
771 unsigned short conn_type = 0;
773 __bt_service_get_parameters(in_param1,
774 &address, sizeof(bluetooth_device_address_t));
775 __bt_service_get_parameters(in_param2,
776 &conn_type, sizeof(unsigned short));
778 result = _bt_bond_device(&address, conn_type, out_param1);
779 /* Save invocation */
780 if (result == BLUETOOTH_ERROR_NONE) {
781 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
782 _bt_convert_addr_type_to_string(addr, address.addr);
783 sender = (char*)g_dbus_method_invocation_get_sender(context);
784 _bt_save_invocation_context(context, result, sender,
785 function_name, (gpointer)addr);
787 bluetooth_device_info_t dev_info;
789 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
790 memcpy(&dev_info.device_address, &address,
791 sizeof(bluetooth_device_address_t));
792 g_array_append_vals(*out_param1, &dev_info,
793 sizeof(bluetooth_device_info_t));
797 case BT_UNBOND_DEVICE: {
798 bluetooth_device_address_t address = { {0} };
800 __bt_service_get_parameters(in_param1,
801 &address, sizeof(bluetooth_device_address_t));
802 result = _bt_unbond_device(&address, out_param1);
804 /* Save invocation */
805 if (result == BLUETOOTH_ERROR_NONE) {
806 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
807 _bt_convert_addr_type_to_string(addr, address.addr);
808 sender = (char*)g_dbus_method_invocation_get_sender(context);
809 _bt_save_invocation_context(context, result, sender,
810 function_name, (gpointer)addr);
812 g_array_append_vals(*out_param1, &address,
813 sizeof(bluetooth_device_address_t));
817 case BT_CANCEL_BONDING:{
818 result = _bt_cancel_bonding();
821 case BT_SEARCH_SERVICE: {
822 bluetooth_device_address_t address = { {0} };
823 __bt_service_get_parameters(in_param1,
824 &address, sizeof(bluetooth_device_address_t));
825 result = _bt_search_device(&address);
826 /* Save invocation */
827 if (result == BLUETOOTH_ERROR_NONE) {
828 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
829 _bt_convert_addr_type_to_string(addr, address.addr);
830 sender = (char*)g_dbus_method_invocation_get_sender(context);
831 _bt_save_invocation_context(context, result, sender,
832 function_name, (gpointer)addr);
834 bt_sdp_info_t sdp_info;
836 memset(&sdp_info, 0x00, sizeof(bt_sdp_info_t));
837 memcpy(&sdp_info.device_addr, &address,
838 sizeof(bluetooth_device_address_t));
839 g_array_append_vals(*out_param1, &sdp_info, sizeof(bt_sdp_info_t));
843 case BT_CANCEL_SEARCH_SERVICE: {
844 result = _bt_cancel_search_device();
847 case BT_SET_PASSKEY_NOTIFICATION: {
851 sender = (char *)g_dbus_method_invocation_get_sender(context);
852 __bt_service_get_parameters(in_param1,
853 &enable, sizeof(gboolean));
855 result = _bt_set_passkey_notification(sender, enable);
858 case BT_SET_PIN_CODE: {
859 bluetooth_device_address_t address = { {0} };
860 bluetooth_device_pin_code_t pin_code = { {0} };
862 __bt_service_get_parameters(in_param1,
863 &address, sizeof(bluetooth_device_address_t));
864 __bt_service_get_parameters(in_param2,
865 &pin_code, sizeof(bluetooth_device_pin_code_t));
867 result = _bt_set_pin_code(&address, &pin_code);
870 case BT_UNSET_PIN_CODE: {
871 bluetooth_device_address_t address = { {0} };
873 __bt_service_get_parameters(in_param1,
874 &address, sizeof(bluetooth_device_address_t));
876 result = _bt_unset_pin_code(&address);
879 case BT_PASSKEY_REPLY: {
880 const char *passkey = NULL;
881 gboolean authentication_reply = FALSE;
882 passkey = g_variant_get_data(in_param1);
883 __bt_service_get_parameters(in_param2,
884 &authentication_reply, sizeof(gboolean));
885 result = _bt_passkey_reply(passkey, authentication_reply);
888 case BT_PASSKEY_CONFIRMATION_REPLY: {
889 gboolean confirmation_reply = FALSE;
890 __bt_service_get_parameters(in_param1,
891 &confirmation_reply, sizeof(gboolean));
892 result = _bt_passkey_confirmation_reply(confirmation_reply);
895 case BT_GET_IS_ALIAS_SET: {
896 bluetooth_device_address_t address = { {0} };
898 __bt_service_get_parameters(in_param1,
899 &address, sizeof(bluetooth_device_address_t));
901 result = _bt_is_alias_set(&address);
902 if (result == BLUETOOTH_ERROR_NONE) {
903 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
905 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
909 _bt_convert_addr_type_to_string(addr, address.addr);
910 sender = (char*)g_dbus_method_invocation_get_sender(context);
911 _bt_save_invocation_context(context, result, sender,
912 function_name, addr);
916 case BT_SET_AUTHORIZATION: {
917 bluetooth_device_address_t address = { {0} };
919 __bt_service_get_parameters(in_param1,
920 &address, sizeof(bluetooth_device_address_t));
921 __bt_service_get_parameters(in_param2,
922 &authorize, sizeof(gboolean));
923 result = _bt_set_authorization(&address, authorize);
926 case BT_SET_LE_PRIVACY: {
927 gboolean set_privacy;
928 __bt_service_get_parameters(in_param1, &set_privacy,
930 result = _bt_set_le_privacy(set_privacy);
933 case BT_ADD_WHITE_LIST: {
934 bluetooth_device_address_t address = { {0} };
935 int address_type = 0;
937 __bt_service_get_parameters(in_param1,
938 &address, sizeof(bluetooth_device_address_t));
939 __bt_service_get_parameters(in_param2,
940 &address_type, sizeof(int));
941 result = _bt_set_white_list(&address, address_type, is_add);
944 case BT_REMOVE_WHITE_LIST: {
945 bluetooth_device_address_t address = { {0} };
946 int address_type = 0;
948 __bt_service_get_parameters(in_param1,
949 &address, sizeof(bluetooth_device_address_t));
950 __bt_service_get_parameters(in_param2,
951 &address_type, sizeof(int));
952 result = _bt_set_white_list(&address, address_type, is_add);
955 case BT_UPDATE_LE_CONNECTION_MODE: {
957 bluetooth_device_address_t remote_address = { { 0 } };
958 bluetooth_le_connection_param_t parameters = { 0 };
959 bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
961 __bt_service_get_parameters(in_param1, &remote_address,
962 sizeof(bluetooth_device_address_t));
963 __bt_service_get_parameters(in_param2, &mode,
964 sizeof(bluetooth_le_connection_mode_t));
966 result = _bt_get_le_connection_parameter(mode, ¶meters);
967 if (result != BLUETOOTH_ERROR_NONE)
970 sender = (char *)g_dbus_method_invocation_get_sender(context);
972 result = _bt_le_connection_update(sender,
974 parameters.interval_min,
975 parameters.interval_max,
980 case BT_SET_MANUFACTURER_DATA: {
981 bluetooth_manufacturer_data_t m_data = { 0 };
982 __bt_service_get_parameters(in_param1,
983 &m_data, sizeof(bluetooth_manufacturer_data_t));
984 result = _bt_set_manufacturer_data(&m_data);
988 case BT_IS_DEVICE_CONNECTED: {
989 bluetooth_device_address_t address = { {0} };
990 gboolean connected = FALSE;
993 __bt_service_get_parameters(in_param1,
994 &address, sizeof(bluetooth_device_address_t));
995 __bt_service_get_parameters(in_param2,
996 &service_type, sizeof(int));
998 #if defined(TIZEN_FEATURE_BT_PAN_NAP)
999 if ((service_type == BLUETOOTH_NAP_SERVICE) || (service_type == BLUETOOTH_NAP_SERVER_SERVICE))
1000 connected = _bt_is_nap_panu_device_connected(&address, service_type);
1002 connected = _bt_is_device_connected(&address, service_type);
1004 connected = _bt_is_device_connected(&address, service_type);
1006 BT_INFO("is_connected: %d", connected);
1007 g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
1010 case BT_GET_CONNECTED_LINK_TYPE: {
1011 bluetooth_device_address_t address = { {0} };
1013 __bt_service_get_parameters(in_param1,
1014 &address, sizeof(bluetooth_device_address_t));
1016 result = _bt_get_connected_link(&address);
1017 if (result == BLUETOOTH_ERROR_NONE) {
1018 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
1020 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
1024 _bt_convert_addr_type_to_string(addr, address.addr);
1025 sender = (char*)g_dbus_method_invocation_get_sender(context);
1026 _bt_save_invocation_context(context, result, sender,
1027 function_name, addr);
1031 case BT_IS_SCAN_FILTER_SUPPORTED:{
1032 int is_supported = 0;
1034 if (_bt_is_scan_filter_supported() == TRUE)
1037 g_array_append_vals(*out_param1,
1038 &is_supported, sizeof(int));
1042 case BT_ENABLE_RSSI: {
1043 bluetooth_device_address_t bd_addr;
1045 bt_rssi_threshold_t rssi_threshold;
1047 int in_range_threshold;
1050 BT_DBG("Enable RSSI");
1052 __bt_service_get_parameters(in_param1,
1053 &bd_addr, sizeof(bluetooth_device_address_t));
1054 __bt_service_get_parameters(in_param2,
1055 &link_type, sizeof(int));
1056 __bt_service_get_parameters(in_param3,
1057 &rssi_threshold, sizeof(bt_rssi_threshold_t));
1059 low_threshold = rssi_threshold.low_threshold;
1060 in_range_threshold = rssi_threshold.in_range_threshold;
1061 high_threshold = rssi_threshold.high_threshold;
1063 result = _bt_enable_rssi(&bd_addr, link_type, low_threshold,
1064 in_range_threshold, high_threshold);
1069 bluetooth_device_address_t bd_addr;
1071 BT_DBG("Get RSSI Strength");
1073 __bt_service_get_parameters(in_param1,
1074 &bd_addr, sizeof(bluetooth_device_address_t));
1075 __bt_service_get_parameters(in_param2,
1076 &link_type, sizeof(int));
1078 result = _bt_get_rssi_strength(&bd_addr, link_type);
1081 case BT_SET_PROFILE_TRUSTED: {
1082 bluetooth_device_address_t bd_addr = { {0} };
1086 __bt_service_get_parameters(in_param1, &bd_addr,
1087 sizeof(bluetooth_device_address_t));
1088 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1089 __bt_service_get_parameters(in_param3, &trust, sizeof(int));
1091 result = _bt_set_trust_profile(&bd_addr, profile, trust);
1094 case BT_GET_PROFILE_TRUSTED: {
1095 bluetooth_device_address_t bd_addr = { {0} };
1097 guint trusted_profile = 0;
1099 __bt_service_get_parameters(in_param1, &bd_addr,
1100 sizeof(bluetooth_device_address_t));
1101 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1103 result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
1104 BT_DBG("TRUST %d", trusted_profile);
1105 if (result == BLUETOOTH_ERROR_NONE) {
1106 g_array_append_vals(*out_param1, &trusted_profile,
1112 case BT_HID_CONNECT: {
1113 bluetooth_device_address_t address = { {0} };
1115 __bt_service_get_parameters(in_param1,
1116 &address, sizeof(bluetooth_device_address_t));
1118 result = _bt_hid_connect(&address);
1119 if (result != BLUETOOTH_ERROR_NONE) {
1120 g_array_append_vals(*out_param1, &address,
1121 sizeof(bluetooth_device_address_t));
1123 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1124 _bt_convert_addr_type_to_string(addr, address.addr);
1125 sender = (char*)g_dbus_method_invocation_get_sender(context);
1126 _bt_save_invocation_context(context, result, sender,
1127 function_name, (gpointer)addr);
1131 case BT_HID_DISCONNECT: {
1132 bluetooth_device_address_t address = { {0} };
1134 __bt_service_get_parameters(in_param1,
1135 &address, sizeof(bluetooth_device_address_t));
1137 result = _bt_hid_disconnect(&address);
1138 if (result != BLUETOOTH_ERROR_NONE) {
1139 g_array_append_vals(*out_param1, &address,
1140 sizeof(bluetooth_device_address_t));
1142 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1143 _bt_convert_addr_type_to_string(addr, address.addr);
1144 sender = (char*)g_dbus_method_invocation_get_sender(context);
1145 _bt_save_invocation_context(context, result, sender,
1146 function_name, (gpointer)addr);
1150 case BT_DPM_SET_ALLOW_BT_MODE: {
1151 dpm_bt_allow_t value = DPM_BT_ERROR;
1153 __bt_service_get_parameters(in_param1, &value,
1156 result = _bt_dpm_set_allow_bluetooth_mode(value);
1159 case BT_DPM_GET_ALLOW_BT_MODE: {
1160 int value = DPM_BT_ERROR;
1162 result = _bt_dpm_get_allow_bluetooth_mode(&value);
1163 g_array_append_vals(*out_param1, &value, sizeof(int));
1166 case BT_DPM_SET_DEVICE_RESTRITION: {
1167 dpm_status_t value = DPM_STATUS_ERROR;
1169 __bt_service_get_parameters(in_param1, &value,
1172 result = _bt_dpm_activate_bluetooth_device_restriction(value);
1175 case BT_DPM_GET_DEVICE_RESTRITION: {
1176 int value = DPM_STATUS_ERROR;
1178 result = _bt_dpm_is_bluetooth_device_restriction_active(&value);
1179 g_array_append_vals(*out_param1, &value, sizeof(int));
1182 case BT_DPM_SET_UUID_RESTRITION: {
1183 dpm_status_t value = DPM_STATUS_ERROR;
1185 __bt_service_get_parameters(in_param1, &value,
1188 result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
1191 case BT_DPM_GET_UUID_RESTRITION: {
1192 int value = DPM_STATUS_ERROR;
1194 result = _bt_dpm_is_bluetooth_uuid_restriction_active(&value);
1195 g_array_append_vals(*out_param1, &value, sizeof(int));
1198 case BT_DPM_ADD_DEVICES_BLACKLIST: {
1199 bluetooth_device_address_t address = { {0} };
1201 __bt_service_get_parameters(in_param1, &address,
1202 sizeof(bluetooth_device_address_t));
1204 result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
1207 case BT_DPM_ADD_DEVICES_WHITELIST: {
1208 bluetooth_device_address_t address = { {0} };
1210 __bt_service_get_parameters(in_param1, &address,
1211 sizeof(bluetooth_device_address_t));
1213 result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
1216 case BT_DPM_ADD_UUIDS_BLACKLIST: {
1217 const char *uuid = NULL;
1219 uuid = g_variant_get_data(in_param1);
1221 result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
1224 case BT_DPM_ADD_UUIDS_WHITELIST: {
1225 const char *uuid = NULL;
1227 uuid = g_variant_get_data(in_param1);
1229 result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
1232 case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
1233 result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
1236 case BT_DPM_CLEAR_DEVICES_WHITELIST: {
1237 result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
1240 case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
1241 result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
1244 case BT_DPM_CLEAR_UUIDS_WHITELIST: {
1245 result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
1248 case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
1249 bluetooth_device_address_t address = { {0} };
1251 __bt_service_get_parameters(in_param1, &address,
1252 sizeof(bluetooth_device_address_t));
1254 result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
1257 case BT_DPM_REMOVE_DEVICE_WHITELIST: {
1258 bluetooth_device_address_t address = { {0} };
1260 __bt_service_get_parameters(in_param1, &address,
1261 sizeof(bluetooth_device_address_t));
1263 result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
1266 case BT_DPM_REMOVE_UUID_BLACKLIST: {
1267 const char *uuid = NULL;
1269 uuid = g_variant_get_data(in_param1);
1271 result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
1274 case BT_DPM_REMOVE_UUID_WHITELIST: {
1275 const char *uuid = NULL;
1277 uuid = g_variant_get_data(in_param1);
1279 result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
1283 case BT_DPM_GET_DEVICES_BLACKLIST: {
1284 result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
1287 case BT_DPM_GET_DEVICES_WHITELIST: {
1288 result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
1291 case BT_DPM_GET_UUIDS_BLACKLIST: {
1292 result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
1295 case BT_DPM_GET_UUIDS_WHITELIST: {
1296 result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
1299 case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
1300 dpm_status_t value = DPM_STATUS_ERROR;
1302 __bt_service_get_parameters(in_param1, &value,
1305 result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
1309 case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
1310 int value = DPM_STATUS_ERROR;
1312 result = _bt_dpm_get_allow_bluetooth_outgoing_call(&value);
1313 g_array_append_vals(*out_param1, &value, sizeof(int));
1316 case BT_DPM_SET_PAIRING_STATE: {
1317 dpm_status_t value = DPM_STATUS_ERROR;
1319 __bt_service_get_parameters(in_param1, &value,
1322 result = _bt_dpm_set_bluetooth_pairing_state(value);
1326 case BT_DPM_GET_PAIRING_STATE: {
1327 int value = DPM_STATUS_ERROR;
1329 result = _bt_dpm_get_bluetooth_pairing_state(&value);
1330 g_array_append_vals(*out_param1, &value, sizeof(int));
1333 case BT_DPM_SET_PROFILE_STATE: {
1334 int value = DPM_STATUS_ERROR;
1335 int profile = DPM_PROFILE_NONE;
1337 __bt_service_get_parameters(in_param1, &profile,
1339 __bt_service_get_parameters(in_param2, &value,
1342 result = _bt_dpm_set_bluetooth_profile_state(profile, value);
1346 case BT_DPM_GET_PROFILE_STATE: {
1347 int value = DPM_STATUS_ERROR;
1348 int profile = DPM_PROFILE_NONE;
1350 __bt_service_get_parameters(in_param1, &profile,
1353 result = _bt_dpm_get_bluetooth_profile_state(profile, &value);
1354 g_array_append_vals(*out_param1, &value, sizeof(int));
1357 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
1358 int value = DPM_BT_ERROR;
1360 __bt_service_get_parameters(in_param1, &value,
1363 result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
1367 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
1368 int value = DPM_STATUS_ERROR;
1370 result = _bt_dpm_get_bluetooth_desktop_connectivity_state(&value);
1371 g_array_append_vals(*out_param1, &value, sizeof(int));
1374 case BT_DPM_SET_DISCOVERABLE_STATE: {
1375 int value = DPM_STATUS_ERROR;
1377 __bt_service_get_parameters(in_param1, &value,
1380 result = _bt_dpm_set_bluetooth_discoverable_state(value);
1384 case BT_DPM_GET_DISCOVERABLE_STATE: {
1385 int value = DPM_STATUS_ERROR;
1387 result = _bt_dpm_get_bluetooth_discoverable_state(&value);
1388 g_array_append_vals(*out_param1, &value, sizeof(int));
1391 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
1392 int value = DPM_STATUS_ERROR;
1394 __bt_service_get_parameters(in_param1, &value,
1397 result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
1401 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
1402 int value = DPM_STATUS_ERROR;
1404 result = _bt_dpm_get_bluetooth_limited_discoverable_state(&value);
1405 g_array_append_vals(*out_param1, &value, sizeof(int));
1408 case BT_DPM_SET_DATA_TRANSFER_STATE: {
1409 int value = DPM_STATUS_ERROR;
1411 __bt_service_get_parameters(in_param1, &value,
1414 result = _bt_dpm_set_bluetooth_data_transfer_state(value);
1418 case BT_DPM_GET_DATA_TRANSFER_STATE: {
1419 int value = DPM_STATUS_ERROR;
1421 result = _bt_dpm_get_allow_bluetooth_data_transfer_state(&value);
1422 g_array_append_vals(*out_param1, &value, sizeof(int));
1425 case BT_RFCOMM_CLIENT_CONNECT: {
1426 bluetooth_device_address_t address = { {0} };
1430 __bt_service_get_parameters(in_param1,
1431 &address, sizeof(bluetooth_device_address_t));
1432 input_string = (char *)g_variant_get_data(in_param2);
1433 __bt_service_get_parameters(in_param3, &connect_type, sizeof(int));
1435 if (connect_type == BT_RFCOMM_UUID)
1436 result = _bt_rfcomm_connect_using_uuid(&address, input_string);
1438 result = _bt_rfcomm_connect_using_channel(&address, input_string);
1440 if (result != BLUETOOTH_ERROR_NONE) {
1441 bluetooth_rfcomm_connection_t conn_info;
1443 BT_ERR("BT_RFCOMM_CLIENT_CONNECT failed, send error");
1444 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
1445 if (connect_type == BT_RFCOMM_UUID)
1446 g_strlcpy(conn_info.uuid, input_string, BLUETOOTH_UUID_STRING_MAX);
1448 g_strlcpy(conn_info.uuid, "not_used", BLUETOOTH_UUID_STRING_MAX);
1450 conn_info.device_role = RFCOMM_ROLE_CLIENT;
1451 conn_info.socket_fd = -1;
1452 g_array_append_vals(*out_param1, &conn_info,
1453 sizeof(bluetooth_rfcomm_connection_t));
1455 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1456 _bt_convert_addr_type_to_string(addr, address.addr);
1457 sender = (char*)g_dbus_method_invocation_get_sender(context);
1458 _bt_save_invocation_context(context, result, sender, function_name, addr);
1462 case BT_RFCOMM_SOCKET_DISCONNECT: {
1464 * Bluetooth RFCOMM socket disconnection will be done from bt-api, call to bt-service
1465 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
1467 result = BLUETOOTH_ERROR_NONE;
1470 case BT_RFCOMM_SOCKET_WRITE: {
1472 * This call to bt-service is only used for privilege check, so return
1473 * BLUETOOTH_ERROR_NONE from here.
1475 result = BLUETOOTH_ERROR_NONE;
1478 case BT_RFCOMM_CREATE_SOCKET: {
1480 * This call to bt-service is only used for privilege check, so return
1481 * BLUETOOTH_ERROR_NONE from here.
1483 result = BLUETOOTH_ERROR_NONE;
1486 case BT_RFCOMM_LISTEN_AND_ACCEPT: {
1490 sender = (char *)g_dbus_method_invocation_get_sender(context);
1491 uuid = (char *)g_variant_get_data(in_param1);
1493 result = _bt_rfcomm_socket_listen(sender, uuid, true);
1495 result = BLUETOOTH_ERROR_NONE;
1496 _bt_save_invocation_context(context,
1497 result, sender, function_name, NULL);
1499 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1503 case BT_RFCOMM_LISTEN: {
1507 sender = (char *)g_dbus_method_invocation_get_sender(context);
1508 uuid = (char *)g_variant_get_data(in_param1);
1510 result = _bt_rfcomm_socket_listen(sender, uuid, false);
1512 result = BLUETOOTH_ERROR_NONE;
1513 _bt_save_invocation_context(context,
1514 result, sender, function_name, NULL);
1516 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1520 case BT_RFCOMM_ACCEPT_CONNECTION: {
1523 address = (char *)g_variant_get_data(in_param1);
1524 result = _bt_rfcomm_reply_conn_authorization(address, TRUE);
1527 case BT_RFCOMM_REJECT_CONNECTION: {
1530 address = (char *)g_variant_get_data(in_param1);
1531 result = _bt_rfcomm_reply_conn_authorization(address, FALSE);
1534 case BT_RFCOMM_REMOVE_SOCKET: {
1536 * This call to bt-service is only used for privilege check, so return
1537 * BLUETOOTH_ERROR_NONE from here.
1539 result = BLUETOOTH_ERROR_NONE;
1542 case BT_RFCOMM_SEND_RX_DETAILS: {
1546 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1547 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1548 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1549 _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
1552 case BT_RFCOMM_SEND_TX_DETAILS: {
1556 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1557 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1558 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1559 _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
1562 case BT_RFCOMM_UPDATE_CONNECTION_INFO: {
1563 gboolean connected = FALSE;
1565 int role = RFCOMM_ROLE_SERVER;
1567 sender = (char *)g_dbus_method_invocation_get_sender(context);
1569 __bt_service_get_parameters(in_param1, &role, sizeof(int));
1570 __bt_service_get_parameters(in_param2, &connected, sizeof(gboolean));
1571 __bt_service_get_parameters(in_param3, &socket_fd, sizeof(int));
1573 if (connected == TRUE)
1574 result = _bt_rfcomm_conn_added(sender, role, socket_fd);
1576 result = _bt_rfcomm_conn_removed(sender, role, socket_fd);
1580 case BT_AUDIO_SELECT_ROLE: {
1581 bluetooth_audio_role_t role;
1583 __bt_service_get_parameters(in_param1,
1584 &role, sizeof(bluetooth_audio_role_t));
1586 result = _bt_audio_select_role(role);
1587 if (result == BLUETOOTH_ERROR_NONE) {
1588 sender = (char*)g_dbus_method_invocation_get_sender(context);
1589 _bt_save_invocation_context(context, result, sender,
1590 function_name, NULL);
1594 case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
1595 unsigned int volume = 0;
1597 __bt_service_get_parameters(in_param1,
1598 &volume, sizeof(unsigned int));
1600 result = _bt_audio_set_absolute_volume(volume);
1603 case BT_AUDIO_GET_ABSOLUTE_VOLUME: {
1604 unsigned int volume = 0;
1606 result = _bt_audio_get_absolute_volume(&volume);
1607 g_array_append_vals(*out_param1, &volume, sizeof(unsigned int));
1610 case BT_AUDIO_IS_AVC_ACTIVATED: {
1613 result = _bt_audio_is_avc_activated(&activated);
1614 g_array_append_vals(*out_param1, &activated, sizeof(bool));
1617 case BT_AV_CONNECT: {
1618 bluetooth_device_address_t address = { {0} };
1619 __bt_service_get_parameters(in_param1,
1620 &address, sizeof(bluetooth_device_address_t));
1622 result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
1624 if (result != BLUETOOTH_ERROR_NONE) {
1625 char addr[BT_ADDRESS_STRING_SIZE];
1626 _bt_convert_addr_type_to_string(addr, address.addr);
1627 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1629 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1630 _bt_convert_addr_type_to_string(addr, address.addr);
1631 sender = (char*)g_dbus_method_invocation_get_sender(context);
1632 _bt_save_invocation_context(context, result, sender,
1633 function_name, (gpointer)addr);
1637 case BT_AUDIO_CONNECT: {
1638 bluetooth_device_address_t address = { {0} };
1639 __bt_service_get_parameters(in_param1,
1640 &address, sizeof(bluetooth_device_address_t));
1642 result = _bt_audio_connect(BT_AUDIO_ALL, &address);
1644 if (result != BLUETOOTH_ERROR_NONE) {
1645 char addr[BT_ADDRESS_STRING_SIZE];
1646 _bt_convert_addr_type_to_string(addr, address.addr);
1647 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1649 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1650 _bt_convert_addr_type_to_string(addr, address.addr);
1651 sender = (char*)g_dbus_method_invocation_get_sender(context);
1652 _bt_save_invocation_context(context, result, sender,
1653 function_name, (gpointer)addr);
1657 case BT_AUDIO_DISCONNECT: {
1658 bluetooth_device_address_t address = { {0} };
1659 __bt_service_get_parameters(in_param1,
1660 &address, sizeof(bluetooth_device_address_t));
1662 result = _bt_audio_disconnect(BT_AUDIO_ALL, &address);
1664 if (result != BLUETOOTH_ERROR_NONE) {
1665 char addr[BT_ADDRESS_STRING_SIZE];
1666 _bt_convert_addr_type_to_string(addr, address.addr);
1667 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1669 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1670 _bt_convert_addr_type_to_string(addr, address.addr);
1671 sender = (char*)g_dbus_method_invocation_get_sender(context);
1672 _bt_save_invocation_context(context, result, sender,
1673 function_name, (gpointer)addr);
1677 case BT_AV_DISCONNECT: {
1678 bluetooth_device_address_t address = { {0} };
1679 __bt_service_get_parameters(in_param1,
1680 &address, sizeof(bluetooth_device_address_t));
1682 result = _bt_audio_disconnect(BT_AUDIO_A2DP, &address);
1684 if (result != BLUETOOTH_ERROR_NONE) {
1685 char addr[BT_ADDRESS_STRING_SIZE];
1686 _bt_convert_addr_type_to_string(addr, address.addr);
1687 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1689 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1690 _bt_convert_addr_type_to_string(addr, address.addr);
1691 sender = (char*)g_dbus_method_invocation_get_sender(context);
1692 _bt_save_invocation_context(context, result, sender,
1693 function_name, (gpointer)addr);
1697 case BT_AG_CONNECT: {
1698 bluetooth_device_address_t address = { {0} };
1699 __bt_service_get_parameters(in_param1,
1700 &address, sizeof(bluetooth_device_address_t));
1702 result = _bt_audio_connect(BT_AUDIO_HSP, &address);
1704 if (result != BLUETOOTH_ERROR_NONE) {
1705 char addr[BT_ADDRESS_STRING_SIZE];
1706 _bt_convert_addr_type_to_string(addr, address.addr);
1707 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1709 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1710 _bt_convert_addr_type_to_string(addr, address.addr);
1711 sender = (char*)g_dbus_method_invocation_get_sender(context);
1712 _bt_save_invocation_context(context, result, sender,
1713 function_name, (gpointer)addr);
1717 case BT_AG_DISCONNECT: {
1718 bluetooth_device_address_t address = { {0} };
1720 __bt_service_get_parameters(in_param1,
1721 &address, sizeof(bluetooth_device_address_t));
1723 result = _bt_audio_disconnect(BT_AUDIO_HSP, &address);
1725 if (result != BLUETOOTH_ERROR_NONE) {
1726 char addr[BT_ADDRESS_STRING_SIZE];
1727 _bt_convert_addr_type_to_string(addr, address.addr);
1728 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1730 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1731 _bt_convert_addr_type_to_string(addr, address.addr);
1732 sender = (char*)g_dbus_method_invocation_get_sender(context);
1733 _bt_save_invocation_context(context, result, sender,
1734 function_name, (gpointer)addr);
1738 case BT_AV_SOURCE_CONNECT: {
1739 bluetooth_device_address_t address = { {0} };
1741 __bt_service_get_parameters(in_param1,
1742 &address, sizeof(bluetooth_device_address_t));
1744 result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
1745 if (result != BLUETOOTH_ERROR_NONE) {
1746 char addr[BT_ADDRESS_STRING_SIZE];
1747 _bt_convert_addr_type_to_string(addr, address.addr);
1748 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1750 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1751 _bt_convert_addr_type_to_string(addr, address.addr);
1752 sender = (char*)g_dbus_method_invocation_get_sender(context);
1753 _bt_save_invocation_context(context, result, sender,
1754 function_name, (gpointer)addr);
1758 case BT_AV_SOURCE_DISCONNECT: {
1759 bluetooth_device_address_t address = { {0} };
1761 __bt_service_get_parameters(in_param1,
1762 &address, sizeof(bluetooth_device_address_t));
1764 result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &address);
1765 if (result != BLUETOOTH_ERROR_NONE) {
1766 char addr[BT_ADDRESS_STRING_SIZE];
1767 _bt_convert_addr_type_to_string(addr, address.addr);
1768 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1770 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1771 _bt_convert_addr_type_to_string(addr, address.addr);
1772 sender = (char*)g_dbus_method_invocation_get_sender(context);
1773 _bt_save_invocation_context(context, result, sender,
1774 function_name, (gpointer)addr);
1778 case BT_HF_CONNECT: {
1779 bluetooth_device_address_t address = { {0} };
1781 __bt_service_get_parameters(in_param1,
1782 &address, sizeof(bluetooth_device_address_t));
1784 result = _bt_hf_connect(&address);
1785 if (result != BLUETOOTH_ERROR_NONE) {
1786 char addr[BT_ADDRESS_STRING_SIZE];
1787 _bt_convert_addr_type_to_string(addr, address.addr);
1788 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1790 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1791 _bt_convert_addr_type_to_string(addr, address.addr);
1792 sender = (char*)g_dbus_method_invocation_get_sender(context);
1793 _bt_save_invocation_context(context, result, sender,
1794 function_name, (gpointer)addr);
1798 case BT_HF_DISCONNECT: {
1799 bluetooth_device_address_t address = { {0} };
1801 __bt_service_get_parameters(in_param1,
1802 &address, sizeof(bluetooth_device_address_t));
1804 result = _bt_hf_disconnect(&address);
1805 if (result != BLUETOOTH_ERROR_NONE) {
1806 char addr[BT_ADDRESS_STRING_SIZE];
1807 _bt_convert_addr_type_to_string(addr, address.addr);
1808 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1810 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1811 _bt_convert_addr_type_to_string(addr, address.addr);
1812 sender = (char*)g_dbus_method_invocation_get_sender(context);
1813 _bt_save_invocation_context(context, result, sender,
1814 function_name, (gpointer)addr);
1818 case BT_AVRCP_TARGET_CONNECT: {
1819 bluetooth_device_address_t address = { {0} };
1821 __bt_service_get_parameters(in_param1,
1822 &address, sizeof(bluetooth_device_address_t));
1824 result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
1825 if (result != BLUETOOTH_ERROR_NONE) {
1826 char addr[BT_ADDRESS_STRING_SIZE];
1827 _bt_convert_addr_type_to_string(addr, address.addr);
1828 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1830 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1831 _bt_convert_addr_type_to_string(addr, address.addr);
1832 sender = (char*)g_dbus_method_invocation_get_sender(context);
1833 _bt_save_invocation_context(context, result, sender,
1834 function_name, (gpointer)addr);
1838 case BT_AVRCP_TARGET_DISCONNECT: {
1839 bluetooth_device_address_t address = { {0} };
1841 __bt_service_get_parameters(in_param1,
1842 &address, sizeof(bluetooth_device_address_t));
1844 result = _bt_audio_disconnect(BT_AVRCP_TARGET, &address);
1845 if (result != BLUETOOTH_ERROR_NONE) {
1846 char addr[BT_ADDRESS_STRING_SIZE];
1847 _bt_convert_addr_type_to_string(addr, address.addr);
1848 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1850 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1851 _bt_convert_addr_type_to_string(addr, address.addr);
1852 sender = (char*)g_dbus_method_invocation_get_sender(context);
1853 _bt_save_invocation_context(context, result, sender,
1854 function_name, (gpointer)addr);
1858 case BT_AVRCP_CONTROL_CONNECT: {
1859 bluetooth_device_address_t address = { {0} };
1861 __bt_service_get_parameters(in_param1,
1862 &address, sizeof(bluetooth_device_address_t));
1864 result = _bt_audio_connect(BT_AVRCP, &address);
1865 if (result != BLUETOOTH_ERROR_NONE) {
1866 char addr[BT_ADDRESS_STRING_SIZE];
1867 _bt_convert_addr_type_to_string(addr, address.addr);
1868 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1870 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1871 _bt_convert_addr_type_to_string(addr, address.addr);
1872 sender = (char*)g_dbus_method_invocation_get_sender(context);
1873 _bt_save_invocation_context(context, result, sender,
1874 function_name, (gpointer)addr);
1878 case BT_AVRCP_CONTROL_DISCONNECT: {
1879 bluetooth_device_address_t address = { {0} };
1881 __bt_service_get_parameters(in_param1,
1882 &address, sizeof(bluetooth_device_address_t));
1884 result = _bt_audio_disconnect(BT_AVRCP, &address);
1885 if (result != BLUETOOTH_ERROR_NONE) {
1886 char addr[BT_ADDRESS_STRING_SIZE];
1887 _bt_convert_addr_type_to_string(addr, address.addr);
1888 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1890 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1891 _bt_convert_addr_type_to_string(addr, address.addr);
1892 sender = (char*)g_dbus_method_invocation_get_sender(context);
1893 _bt_save_invocation_context(context, result, sender,
1894 function_name, (gpointer)addr);
1898 case BT_AVRCP_HANDLE_CONTROL: {
1900 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1901 result = _bt_avrcp_control_cmd(key_code);
1904 case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
1906 bluetooth_device_address_t address = { { 0 } };
1908 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1909 __bt_service_get_parameters(in_param2,
1910 &address, sizeof(bluetooth_device_address_t));
1912 result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
1915 case BT_AVRCP_CONTROL_SET_PROPERTY: {
1919 __bt_service_get_parameters(in_param1,
1920 &type, sizeof(int));
1921 __bt_service_get_parameters(in_param2,
1922 &value, sizeof(unsigned int));
1924 result = _bt_avrcp_control_set_property(type, value);
1927 case BT_AVRCP_TRANSPORT_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_transport_set_property(type, value);
1941 case BT_AVRCP_CONTROL_GET_PROPERTY: {
1944 __bt_service_get_parameters(in_param1, &type, sizeof(int));
1946 result = _bt_avrcp_control_get_property(type);
1947 /* Save invocation */
1948 if (result == BLUETOOTH_ERROR_NONE) {
1949 sender = (char*)g_dbus_method_invocation_get_sender(context);
1950 _bt_save_invocation_context(context, result, sender,
1951 function_name, g_memdup(&type, sizeof(int)));
1955 case BT_AVRCP_GET_TRACK_INFO: {
1956 result = _bt_avrcp_control_get_track_info();
1957 /* Save invocation */
1958 if (result == BLUETOOTH_ERROR_NONE) {
1959 sender = (char*)g_dbus_method_invocation_get_sender(context);
1960 _bt_save_invocation_context(context, result, sender,
1961 function_name, NULL);
1965 case BT_HDP_REGISTER_SINK_APP: {
1966 unsigned short data_type;
1967 bt_hdp_role_type_t role;
1968 bt_hdp_qos_type_t channel_type;
1969 int *app_id = g_new0(int, 1);
1971 __bt_service_get_parameters(in_param1,
1972 &data_type, sizeof(short));
1973 __bt_service_get_parameters(in_param2,
1974 &role, sizeof(bt_hdp_role_type_t));
1975 __bt_service_get_parameters(in_param3,
1976 &channel_type, sizeof(bt_hdp_qos_type_t));
1977 sender = (char*)g_dbus_method_invocation_get_sender(context);
1979 result = _bt_hdp_app_register(role,
1980 channel_type, data_type, sender, app_id);
1981 if (result != BLUETOOTH_ERROR_NONE) {
1982 g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
1985 _bt_save_invocation_context(context, result, sender,
1986 function_name, (gpointer)app_id);
1990 case BT_HDP_UNREGISTER_SINK_APP: {
1992 int *app_id = g_new0(int, 1);
1994 app_handle = (char *)g_variant_get_data(in_param1);
1995 sscanf(app_handle, "health_app_%d", app_id);
1996 result = _bt_hdp_app_unregister(*app_id);
1997 if (result != BLUETOOTH_ERROR_NONE) {
2000 sender = (char*)g_dbus_method_invocation_get_sender(context);
2001 _bt_save_invocation_context(context, result, sender,
2002 function_name, (gpointer)app_id);
2006 case BT_HDP_CONNECT: {
2010 bt_hdp_connected_t *conn_info = NULL;
2012 conn_info = g_malloc0(sizeof(bt_hdp_connected_t));
2014 app_handle = (char *)g_variant_get_data(in_param1);
2015 conn_info->app_handle = app_handle;
2016 sscanf(app_handle, "health_app_%d", &app_id);
2018 __bt_service_get_parameters(in_param2,
2019 &(conn_info->type), sizeof(bt_hdp_qos_type_t));
2020 __bt_service_get_parameters(in_param3,
2021 &(conn_info->device_address),
2022 sizeof(bluetooth_device_address_t));
2024 result = _bt_hdp_connect(app_id, &(conn_info->device_address),
2025 conn_info->type, (int *)(&(conn_info->channel_id)));
2026 if (result != BLUETOOTH_ERROR_NONE) {
2027 g_array_append_vals(*out_param1, conn_info,
2028 sizeof(bt_hdp_connected_t));
2031 sender = (char*)g_dbus_method_invocation_get_sender(context);
2032 _bt_save_invocation_context(context, result, sender,
2033 function_name, (gpointer)conn_info);
2037 case BT_HDP_DISCONNECT: {
2038 bt_hdp_disconnected_t *hdp_disconn_info = NULL;
2040 hdp_disconn_info = g_malloc0(sizeof(bt_hdp_disconnected_t));
2042 __bt_service_get_parameters(in_param1,
2043 &(hdp_disconn_info->channel_id), sizeof(int));
2044 __bt_service_get_parameters(in_param2,
2045 &(hdp_disconn_info->device_address),
2046 sizeof(bluetooth_device_address_t));
2048 result = _bt_hdp_disconnect(hdp_disconn_info->channel_id);
2049 if (result != BLUETOOTH_ERROR_NONE) {
2050 g_array_append_vals(*out_param1, hdp_disconn_info,
2051 sizeof(bt_hdp_disconnected_t));
2052 g_free(hdp_disconn_info);
2054 sender = (char*)g_dbus_method_invocation_get_sender(context);
2055 _bt_save_invocation_context(context, result, sender,
2056 function_name, (gpointer)hdp_disconn_info);
2060 case BT_HDP_GET_FD: {
2061 int *channel_id = g_new0(int, 1);
2063 __bt_service_get_parameters(in_param1, channel_id, sizeof(int));
2065 result = _bt_hdp_get_fd(*channel_id);
2066 if (result != BLUETOOTH_ERROR_NONE) {
2069 sender = (char*)g_dbus_method_invocation_get_sender(context);
2070 _bt_save_invocation_context(context, result, sender,
2071 function_name, (gpointer)channel_id);
2075 case BT_HDP_SEND_DATA: {
2077 * This call to bt-service is only used for privilege check, so return
2078 * BLUETOOTH_ERROR_NONE from here.
2080 result = BLUETOOTH_ERROR_NONE;
2083 case BT_OOB_READ_LOCAL_DATA: { //208
2084 bt_oob_data_t local_oob_data;
2086 memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
2087 result = _bt_oob_read_local_data(&local_oob_data);
2089 g_array_append_vals(*out_param1, &local_oob_data,
2090 sizeof(bt_oob_data_t));
2094 case BT_OOB_ADD_REMOTE_DATA: { //209
2095 bluetooth_device_address_t address = { {0} };
2096 unsigned short address_type;
2097 bt_oob_data_t remote_oob_data;
2099 __bt_service_get_parameters(in_param1,
2100 &address, sizeof(bluetooth_device_address_t));
2101 __bt_service_get_parameters(in_param2,
2102 &address_type, sizeof(unsigned short));
2103 __bt_service_get_parameters(in_param3,
2104 &remote_oob_data, sizeof(bt_oob_data_t));
2106 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2110 case BT_OOB_REMOVE_REMOTE_DATA: { //210
2111 bluetooth_device_address_t address = { {0} };
2113 __bt_service_get_parameters(in_param1,
2114 &address, sizeof(bluetooth_device_address_t));
2116 result = _bt_oob_remove_remote_data(&address);
2120 case BT_LE_OOB_READ_LOCAL_DATA: {
2121 bt_oob_data_t local_oob_data;
2122 bt_oob_data_t *local_oob_cache_data;
2124 local_oob_cache_data = _bt_le_oob_get_local_cache_data();
2125 if (local_oob_cache_data && local_oob_cache_data->eir_len) {
2126 g_array_append_vals(*out_param1, local_oob_cache_data,
2127 sizeof(bt_oob_data_t));
2128 return BLUETOOTH_ERROR_NONE;
2131 /* We should modify this logic in later */
2132 if (_bt_is_le_static_random_address_enabled() == false) {
2133 /* Seperate BT & LE address */
2134 _bt_set_le_static_random_address(TRUE);
2137 result = _bt_le_oob_read_local_data(&local_oob_data);
2138 _bt_le_oob_set_local_cache_data(&local_oob_data);
2140 g_array_append_vals(*out_param1, &local_oob_data,
2141 sizeof(bt_oob_data_t));
2145 case BT_LE_OOB_ADD_REMOTE_DATA: {
2146 bluetooth_device_address_t address = { {0} };
2147 unsigned short address_type;
2148 bt_oob_data_t remote_oob_data;
2150 __bt_service_get_parameters(in_param1,
2151 &address, sizeof(bluetooth_device_address_t));
2152 __bt_service_get_parameters(in_param2,
2153 &address_type, sizeof(unsigned short));
2154 __bt_service_get_parameters(in_param3,
2155 &remote_oob_data, sizeof(bt_oob_data_t));
2157 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2161 case BT_AVRCP_SET_TRACK_INFO: {
2162 media_metadata_t data;
2163 media_metadata_attributes_t meta_data;
2165 memset(&data, 0x00, sizeof(media_metadata_t));
2166 memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
2168 __bt_service_get_parameters(in_param1,
2169 &data, sizeof(media_metadata_t));
2171 meta_data.title = g_strdup(data.title);
2172 meta_data.artist = g_strdup(data.artist);
2173 meta_data.album = g_strdup(data.album);
2174 meta_data.genre = g_strdup(data.genre);
2175 meta_data.total_tracks = data.total_tracks;
2176 meta_data.number = data.number;
2177 meta_data.duration = (int64_t) data.duration;
2179 result = _bt_avrcp_set_track_info(&meta_data);
2181 g_free((gpointer)meta_data.title);
2182 g_free((gpointer)meta_data.artist);
2183 g_free((gpointer)meta_data.album);
2184 g_free((gpointer)meta_data.genre);
2188 case BT_AVRCP_SET_PROPERTY: {
2192 sender = (char *)g_dbus_method_invocation_get_sender(context);
2194 __bt_service_get_parameters(in_param1,
2195 &type, sizeof(int));
2196 __bt_service_get_parameters(in_param2,
2197 &value, sizeof(unsigned int));
2199 if (value == STATUS_PLAYING) {
2200 if (current_sender_playing)
2201 g_free(current_sender_playing);
2202 current_sender_playing = g_strdup(sender);
2204 if (g_strcmp0(sender, current_sender_playing) == 0 ||
2205 current_sender_playing == NULL) {
2206 BT_INFO("Current Player Status %d type %d Sender %s", value, type, sender);
2208 BT_INFO("Current Player and this sender (%s) are different", sender);
2209 result = BLUETOOTH_ERROR_NONE;
2212 result = _bt_avrcp_set_property(type, value);
2216 case BT_AVRCP_SET_PROPERTIES: {
2217 media_player_settings_t properties;
2219 memset(&properties, 0x00, sizeof(media_player_settings_t));
2220 __bt_service_get_parameters(in_param1,
2221 &properties, sizeof(media_player_settings_t));
2223 result = _bt_avrcp_set_properties(&properties);
2227 case BT_SET_ADVERTISING_DATA: {
2230 bluetooth_advertising_data_t adv = { {0} };
2232 gboolean use_reserved_slot = FALSE;
2234 app = (char *)g_dbus_method_invocation_get_sender(context);
2235 adv_handle = g_malloc0(sizeof(int));
2237 __bt_service_get_parameters(in_param1,
2238 adv_handle, sizeof(int));
2239 __bt_service_get_parameters(in_param3,
2240 &length, sizeof(int));
2241 __bt_service_get_parameters(in_param2,
2243 __bt_service_get_parameters(in_param4,
2244 &use_reserved_slot, sizeof(gboolean));
2245 result = _bt_set_advertising_data(app, *adv_handle,
2246 &adv, length, use_reserved_slot);
2247 if (result != BLUETOOTH_ERROR_NONE) {
2248 BT_ERR("Set Advertising data failed!!");
2251 _bt_save_invocation_context(context, result, app,
2252 function_name, (gpointer)adv_handle);
2256 case BT_SET_SCAN_RESPONSE_DATA: {
2259 bluetooth_scan_resp_data_t rsp = { {0} };
2261 gboolean use_reserved_slot = FALSE;
2263 app = (char *)g_dbus_method_invocation_get_sender(context);
2264 adv_handle = g_malloc0(sizeof(int));
2266 __bt_service_get_parameters(in_param1,
2267 adv_handle, sizeof(int));
2268 __bt_service_get_parameters(in_param3,
2269 &length, sizeof(int));
2270 __bt_service_get_parameters(in_param2,
2272 __bt_service_get_parameters(in_param4,
2273 &use_reserved_slot, sizeof(gboolean));
2275 result = _bt_set_scan_response_data(app, *adv_handle,
2276 &rsp, length, use_reserved_slot);
2278 if (result != BLUETOOTH_ERROR_NONE) {
2279 BT_ERR("Set Scan Response Data failed!!");
2282 _bt_save_invocation_context(context, result, app,
2283 function_name, (gpointer)adv_handle);
2287 case BT_SET_ADVERTISING: {
2290 gboolean enable = FALSE;
2291 gboolean use_reserved_slot = FALSE;
2293 adv_handle = g_malloc0(sizeof(int));
2294 __bt_service_get_parameters(in_param1,
2295 adv_handle, sizeof(int));
2296 __bt_service_get_parameters(in_param2,
2297 &enable, sizeof(gboolean));
2298 __bt_service_get_parameters(in_param3,
2299 &use_reserved_slot, sizeof(gboolean));
2301 app = (char *)g_dbus_method_invocation_get_sender(context);
2303 result = _bt_set_advertising(app, *adv_handle,
2304 enable, use_reserved_slot);
2305 if (result != BLUETOOTH_ERROR_NONE) {
2306 BT_ERR("Start Advertising failed!!");
2309 _bt_save_invocation_context(context, result, app,
2310 function_name, (gpointer)adv_handle);
2314 case BT_SET_CUSTOM_ADVERTISING: {
2317 gboolean enable = FALSE;
2318 bluetooth_advertising_params_t adv_params;
2319 gboolean use_reserved_slot = FALSE;
2321 app = (char *)g_dbus_method_invocation_get_sender(context);
2322 adv_handle = g_malloc0(sizeof(int));
2324 __bt_service_get_parameters(in_param1, adv_handle,
2326 __bt_service_get_parameters(in_param2, &enable,
2328 __bt_service_get_parameters(in_param3, &adv_params,
2329 sizeof(bluetooth_advertising_params_t));
2330 __bt_service_get_parameters(in_param4, &use_reserved_slot,
2333 BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
2334 adv_params.interval_min, adv_params.interval_max,
2335 adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
2336 result = _bt_set_custom_advertising(app, *adv_handle,
2337 enable, &adv_params, use_reserved_slot);
2338 if (result != BLUETOOTH_ERROR_NONE) {
2339 BT_ERR("Start Custom Advertising failed!!");
2342 _bt_save_invocation_context(context, result, app,
2343 function_name, (gpointer)adv_handle);
2347 case BT_GET_SCAN_RESPONSE_DATA: {
2348 bluetooth_scan_resp_data_t rsp = { {0} };
2352 app = (char *)g_dbus_method_invocation_get_sender(context);
2354 __bt_service_get_parameters(in_param1, &adv_handle,
2357 result = _bt_get_scan_response_data(app, adv_handle, &rsp, &length);
2358 if (result == BLUETOOTH_ERROR_NONE)
2359 g_array_append_vals(*out_param1, rsp.data, length);
2363 case BT_GET_ADVERTISING_DATA: {
2364 bluetooth_advertising_data_t adv = { {0} };
2368 app = (char *)g_dbus_method_invocation_get_sender(context);
2370 __bt_service_get_parameters(in_param1, &adv_handle,
2373 result = _bt_get_advertising_data(app, adv_handle, &adv, &length);
2374 if (result == BLUETOOTH_ERROR_NONE)
2375 g_array_append_vals(*out_param1, adv.data, length);
2379 case BT_GATT_REGISTER_APPLICATION: {
2380 BT_DBG("Register GATT application:Unhandled!!");
2383 case BT_GATT_SERVER_REGISTER: {
2384 BT_DBG("GATT Server instance initialization");
2387 app = (char *)g_dbus_method_invocation_get_sender(context);
2388 BT_DBG("GATT Server Unique Name [%s]", app);
2390 /* No ADV handle: Set 0 */
2391 result = _bt_register_server_instance(app, 0);
2393 if (result != BLUETOOTH_ERROR_NONE) {
2394 BT_ERR("GATT Server registration failed. result %d", result);
2396 _bt_save_invocation_context(context, result, app,
2397 function_name, NULL);
2401 case BT_GATT_SERVER_DEREGISTER: {
2403 app = (char*)g_dbus_method_invocation_get_sender(context);
2405 result = _bt_unregister_server_instance(app, 0/* Adv Handle*/);
2408 case BT_GATT_SERVER_ADD_SERVICE: {
2409 BT_DBG("GATT Server Add Service");
2415 int *tmp_inst_id = NULL;
2417 app = (char *)g_dbus_method_invocation_get_sender(context);
2419 __bt_service_get_parameters(in_param1, &service_type,
2421 __bt_service_get_parameters(in_param2, &num_handles,
2423 svc_uuid = (char *)g_variant_get_data(in_param3);
2424 __bt_service_get_parameters(in_param4, &instance_id,
2427 result = _bt_gatt_server_add_service(app, service_type, num_handles, svc_uuid, instance_id);
2428 if (result != BLUETOOTH_ERROR_NONE) {
2429 BT_ERR("GATT Server Add Service failed!!");
2431 tmp_inst_id = g_malloc0(sizeof(int));
2432 *tmp_inst_id = instance_id;
2433 _bt_save_invocation_context(context, result, app,
2434 function_name, (gpointer)tmp_inst_id);
2438 case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
2439 BT_DBG("GATT Server Add Characteristic");
2442 int *tmp_inst_id = NULL;
2443 bluetooth_gatt_server_attribute_params_t param;
2444 memset(¶m, 0, sizeof(bluetooth_gatt_server_attribute_params_t));
2446 app = (char*)g_dbus_method_invocation_get_sender(context);
2448 __bt_service_get_parameters(in_param1, ¶m,
2449 sizeof(bluetooth_gatt_server_attribute_params_t));
2450 char_uuid = (char *)g_variant_get_data(in_param2);
2452 result = _bt_gatt_server_add_characteristic(app, char_uuid, ¶m);
2453 if (result != BLUETOOTH_ERROR_NONE) {
2454 BT_ERR("GATT Server Add Service failed!!");
2456 tmp_inst_id = g_malloc0(sizeof(int));
2457 *tmp_inst_id = param.instance_id;
2459 _bt_save_invocation_context(context, result, app,
2460 function_name, (gpointer)tmp_inst_id);
2464 case BT_GATT_SERVER_ADD_DESCRIPTOR: {
2465 BT_DBG("GATT Server Add Descriptor");
2469 bt_gatt_permission_t perm;
2471 int *tmp_inst_id = NULL;
2472 memset(&perm, 0, sizeof(bt_gatt_permission_t));
2474 app = (char *)g_dbus_method_invocation_get_sender(context);
2476 __bt_service_get_parameters(in_param1, &service_handle,
2478 __bt_service_get_parameters(in_param2, &instance_id,
2480 desc_uuid = (char *)g_variant_get_data(in_param4);
2481 __bt_service_get_parameters(in_param3, &perm,
2482 sizeof(bt_gatt_permission_t));
2484 result = _bt_gatt_server_add_descriptor(app, desc_uuid, &perm, service_handle, instance_id);
2485 if (result != BLUETOOTH_ERROR_NONE) {
2486 BT_ERR("GATT Server Add Service failed!!");
2488 tmp_inst_id = g_malloc0(sizeof(int));
2489 *tmp_inst_id = instance_id;
2490 _bt_save_invocation_context(context, result, app,
2491 function_name, (gpointer)tmp_inst_id);
2495 case BT_GATT_SERVER_START_SERVICE: {
2500 int *tmp_inst_id = NULL;
2501 app = (char*)g_dbus_method_invocation_get_sender(context);
2503 __bt_service_get_parameters(in_param1, &service_handle,
2505 __bt_service_get_parameters(in_param2, &instance_id,
2508 result = _bt_gatt_server_start_service(app, service_handle, instance_id);
2510 if (BLUETOOTH_ERROR_NONE == result) {
2511 tmp_inst_id = g_malloc0(sizeof(int));
2512 *tmp_inst_id = instance_id;
2513 _bt_save_invocation_context(context, result, app,
2514 function_name, (gpointer)tmp_inst_id);
2518 case BT_GATT_SERVER_STOP_SERVICE: {
2522 int *tmp_inst_id = NULL;
2523 app = (char*)g_dbus_method_invocation_get_sender(context);
2525 __bt_service_get_parameters(in_param1, &service_handle,
2527 __bt_service_get_parameters(in_param2, &instance_id,
2530 result = _bt_gatt_server_stop_service(app, service_handle, instance_id);
2532 if (BLUETOOTH_ERROR_NONE == result) {
2533 tmp_inst_id = g_malloc0(sizeof(int));
2534 *tmp_inst_id = instance_id;
2535 _bt_save_invocation_context(context, result, app,
2536 function_name, (gpointer)tmp_inst_id);
2540 case BT_GATT_SERVER_DELETE_SERVICE: {
2543 int *tmp_inst_id = NULL;
2545 app = (char*)g_dbus_method_invocation_get_sender(context);
2547 __bt_service_get_parameters(in_param1, &service_handle,
2549 __bt_service_get_parameters(in_param2, &instance_id,
2552 result = _bt_gatt_server_delete_service(app, service_handle, instance_id);
2554 if (BLUETOOTH_ERROR_NONE == result) {
2555 tmp_inst_id = g_malloc0(sizeof(int));
2556 *tmp_inst_id = instance_id;
2557 _bt_save_invocation_context(context, result, app,
2558 function_name, (gpointer)tmp_inst_id);
2562 case BT_GATT_SERVER_SEND_RESPONSE: {
2563 bluetooth_gatt_server_response_params_t param;
2564 bluetooth_gatt_att_data_t data;
2567 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_response_params_t));
2568 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2570 app = (char*)g_dbus_method_invocation_get_sender(context);
2572 __bt_service_get_parameters(in_param1, &data,
2573 sizeof(bluetooth_gatt_att_data_t));
2574 __bt_service_get_parameters(in_param2, ¶m,
2575 sizeof(bluetooth_gatt_server_response_params_t));
2577 result = _bt_gatt_server_send_response(app, &data, ¶m);
2581 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
2583 bluetooth_gatt_server_acquire_response_params_t param;
2586 msg = g_dbus_method_invocation_get_message(context);
2587 GUnixFDList *fd_list;
2592 fd_list = g_dbus_message_get_unix_fd_list(msg);
2594 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2596 app = (char*)g_dbus_method_invocation_get_sender(context);
2598 __bt_service_get_parameters(in_param1, ¶m,
2599 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2601 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2602 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2603 fd = fd_list_array[0];
2606 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2610 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
2612 bluetooth_gatt_server_acquire_response_params_t param;
2615 msg = g_dbus_method_invocation_get_message(context);
2616 GUnixFDList *fd_list;
2621 fd_list = g_dbus_message_get_unix_fd_list(msg);
2623 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2625 app = (char*)g_dbus_method_invocation_get_sender(context);
2627 __bt_service_get_parameters(in_param1, ¶m,
2628 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2630 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2631 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2632 fd = fd_list_array[0];
2635 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2639 case BT_GATT_SERVER_SEND_INDICATION: {
2640 bluetooth_gatt_server_indication_params_t param;
2641 bluetooth_gatt_att_data_t data;
2642 bluetooth_device_address_t address;
2645 app = (char*)g_dbus_method_invocation_get_sender(context);
2647 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_indication_params_t));
2648 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2649 memset(&address, 0x00, sizeof(bluetooth_device_address_t));
2651 __bt_service_get_parameters(in_param1, &data,
2652 sizeof(bluetooth_gatt_att_data_t));
2653 __bt_service_get_parameters(in_param2, ¶m,
2654 sizeof(bluetooth_gatt_server_indication_params_t));
2655 __bt_service_get_parameters(in_param3, &address,
2656 sizeof(bluetooth_device_address_t));
2658 result = _bt_gatt_server_send_indication(app, &address, &data, ¶m);
2662 case BT_GATT_SERVER_UPDATE_VALUE: {
2663 bluetooth_gatt_server_update_value_t param;
2667 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
2669 app = (char*)g_dbus_method_invocation_get_sender(context);
2671 __bt_service_get_parameters(in_param1, &instance_id,
2673 __bt_service_get_parameters(in_param2, ¶m,
2674 sizeof(bluetooth_gatt_server_update_value_t));
2676 result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
2679 case BT_GET_ATT_MTU: {
2680 bluetooth_device_address_t address = { {0} };
2681 unsigned int mtu = 0;
2683 __bt_service_get_parameters(in_param1,
2684 &address, sizeof(bluetooth_device_address_t));
2685 result = _bt_get_att_mtu(&address, &mtu);
2686 BT_DBG("MTU: %d", mtu);
2688 if (result == BLUETOOTH_ERROR_NONE) {
2689 g_array_append_vals(*out_param1, &mtu,
2690 sizeof(unsigned int));
2694 case BT_REQ_ATT_MTU: {
2695 bluetooth_device_address_t address = { {0} };
2699 sender = (char*)g_dbus_method_invocation_get_sender(context);
2701 __bt_service_get_parameters(in_param1,
2702 &address, sizeof(bluetooth_device_address_t));
2703 __bt_service_get_parameters(in_param2,
2704 &mtu, sizeof(unsigned int));
2705 BT_DBG("BT_REQ_ATT_MTU: %d", mtu);
2706 result = _bt_request_att_mtu(&address, mtu);
2707 if (BLUETOOTH_ERROR_NONE == result) {
2708 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2710 _bt_convert_addr_type_to_string(addr, address.addr);
2712 /* Save the informations to invocation */
2713 _bt_save_invocation_context(context, result, sender,
2714 function_name, (gpointer)addr);
2716 g_array_append_vals(*out_param1, &address,
2717 sizeof(bluetooth_device_address_t));
2721 case BT_GET_DEVICE_IDA: {
2722 bluetooth_device_address_t address = { {0} };
2723 bluetooth_device_address_t id_addr = { {0} };
2725 __bt_service_get_parameters(in_param1,
2726 &address, sizeof(bluetooth_device_address_t));
2728 result = _bt_device_get_ida(&address, &id_addr);
2730 if (result == BLUETOOTH_ERROR_NONE) {
2731 g_array_append_vals(*out_param1, &id_addr,
2732 sizeof(bluetooth_device_address_t));
2736 case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
2739 __bt_service_get_parameters(in_param1, &is_enable,
2742 result = _bt_set_le_static_random_address(is_enable);
2747 case BT_GATT_CLIENT_REGISTER: {
2748 bluetooth_device_address_t address = { {0} };
2751 sender = (char*)g_dbus_method_invocation_get_sender(context);
2753 __bt_service_get_parameters(in_param1,
2754 &address, sizeof(bluetooth_device_address_t));
2756 result = _bt_register_gatt_client_instance(sender, &address);
2757 if (BLUETOOTH_ERROR_NONE == result) {
2758 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2760 _bt_convert_addr_type_to_string(addr, address.addr);
2762 /* Save the informations to invocation */
2763 _bt_save_invocation_context(context, result, sender,
2764 function_name, (gpointer)addr);
2769 case BT_GATT_CLIENT_UNREGISTER: {
2772 sender = (char*)g_dbus_method_invocation_get_sender(context);
2773 __bt_service_get_parameters(in_param1,
2774 &client_id, sizeof(int));
2776 result = _bt_unregister_gatt_client_instance(sender, client_id);
2780 /* Async: Remote Interaction */
2781 case BT_GATT_ACQUIRE_WRITE: {
2785 bluetooth_gatt_client_char_prop_info_t param;
2787 sender = (char*)g_dbus_method_invocation_get_sender(context);
2789 __bt_service_get_parameters(in_param1, ¶m,
2790 sizeof(bluetooth_gatt_client_char_prop_info_t));
2793 result = _bt_gatt_acquire_write(¶m , &fd, &mtu);
2795 g_array_append_vals(*out_param1, &mtu, sizeof(int));
2797 if (BLUETOOTH_ERROR_NONE == result)
2798 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
2800 BT_ERR("GATT Client: gatt acquire write failed");
2804 GUnixFDList *fd_list = NULL;
2805 GError *error = NULL;
2807 /* Add socket fd to unix_fd_list */
2808 fd_list = g_unix_fd_list_new();
2809 g_unix_fd_list_append(fd_list, fd, &error);
2810 g_assert_no_error(error);
2812 _bt_service_method_return_with_unix_fd_list(
2813 context, *out_param1, result, fd_list);
2816 g_object_unref(fd_list);
2820 /* Async: Remote Interaction */
2821 case BT_CONNECT_LE: {
2822 bluetooth_device_address_t address = { {0} };
2823 gboolean auto_connect;
2827 sender = (char*)g_dbus_method_invocation_get_sender(context);
2829 __bt_service_get_parameters(in_param1,
2830 &address, sizeof(bluetooth_device_address_t));
2831 __bt_service_get_parameters(in_param2,
2832 &auto_connect, sizeof(gboolean));
2833 __bt_service_get_parameters(in_param3,
2834 &client_id, sizeof(int));
2836 BT_DBG("GATT Client: client_id[%d]", client_id);
2837 result = _bt_connect_le_device(&address, auto_connect, client_id);
2838 if (BLUETOOTH_ERROR_NONE == result) {
2839 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2840 _bt_convert_addr_type_to_string(addr, address.addr);
2842 /* Save the informations to invocation */
2843 _bt_save_invocation_context(context, result, sender,
2844 function_name, (gpointer)addr);
2847 _bt_handle_invocation_context(function_name, (void *)addr);
2849 BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
2850 g_array_append_vals(*out_param1, &address,
2851 sizeof(bluetooth_device_address_t));
2855 /* Async: Remote Interaction */
2856 case BT_DISCONNECT_LE: {
2857 bluetooth_device_address_t address = { {0} };
2861 sender = (char*)g_dbus_method_invocation_get_sender(context);
2863 __bt_service_get_parameters(in_param1,
2864 &address, sizeof(bluetooth_device_address_t));
2865 __bt_service_get_parameters(in_param2,
2866 &client_id, sizeof(int));
2868 BT_INFO("GATT Disconnect using client Interface [%d]", client_id);
2869 result = _bt_disconnect_le_device(&address, client_id);
2870 if (BLUETOOTH_ERROR_NONE == result) {
2871 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2873 _bt_convert_addr_type_to_string(addr, address.addr);
2875 /* Save the informations to invocation */
2876 _bt_save_invocation_context(context, result, sender,
2877 function_name, (gpointer)addr);
2879 g_array_append_vals(*out_param1, &address,
2880 sizeof(bluetooth_device_address_t));
2885 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS: {
2886 guint available_packets = 0;
2888 result = _bt_gatt_get_data_batching_available_packets(&available_packets);
2889 BT_DBG("LE batching available packets %u", available_packets);
2890 if (result == BLUETOOTH_ERROR_NONE) {
2891 g_array_append_vals(*out_param1, &available_packets,
2898 case BT_ENABLE_GATT_DATA_BATCHING: {
2899 bluetooth_device_address_t address = { {0} };
2900 int packet_threshold;
2903 __bt_service_get_parameters(in_param1,
2904 &address, sizeof(bluetooth_device_address_t));
2905 __bt_service_get_parameters(in_param2,
2906 &packet_threshold, sizeof(int));
2907 __bt_service_get_parameters(in_param3,
2908 &timeout, sizeof(int));
2909 result = _bt_gatt_enable_data_batching(&address, packet_threshold, timeout);
2914 case BT_DISABLE_GATT_DATA_BATCHING: {
2915 bluetooth_device_address_t address = { {0} };
2917 __bt_service_get_parameters(in_param1,
2918 &address, sizeof(bluetooth_device_address_t));
2919 result = _bt_gatt_disable_data_batching(&address);
2924 case BT_GATT_GET_PRIMARY_SERVICES: {
2927 sender = (char*)g_dbus_method_invocation_get_sender(context);
2928 bluetooth_device_address_t address = { {0} };
2930 __bt_service_get_parameters(in_param1, &address,
2931 sizeof(bluetooth_device_address_t));
2933 addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
2934 _bt_convert_addr_type_to_string(addr, address.addr);
2936 result = _bt_gatt_get_primary_services(addr);
2937 if (BLUETOOTH_ERROR_NONE == result) {
2938 _bt_save_invocation_context(context, result, sender,
2939 function_name, (gpointer)addr);
2945 case BT_GATT_GET_SERVICE_PROPERTIES: {
2946 bluetooth_gatt_client_svc_prop_info_t param;
2948 sender = (char*)g_dbus_method_invocation_get_sender(context);
2949 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_svc_prop_info_t));
2951 __bt_service_get_parameters(in_param1, ¶m,
2952 sizeof(bluetooth_gatt_client_svc_prop_info_t));
2954 result = _bt_gatt_get_all_characteristic(¶m);
2955 if (BLUETOOTH_ERROR_NONE == result) {
2956 /* Save the informations to invocation */
2957 _bt_save_invocation_context(context, result, sender,
2959 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
2963 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
2964 bluetooth_gatt_client_char_prop_info_t param;
2966 sender = (char*)g_dbus_method_invocation_get_sender(context);
2967 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2969 __bt_service_get_parameters(in_param1, ¶m,
2970 sizeof(bluetooth_gatt_client_char_prop_info_t));
2972 result = _bt_gatt_get_all_characteristic_properties(¶m);
2973 if (BLUETOOTH_ERROR_NONE == result) {
2974 /* Save the informations to invocation */
2975 _bt_save_invocation_context(context, result, sender,
2977 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
2981 /* Async: Remote Interaction */
2982 case BT_GATT_READ_CHARACTERISTIC: {
2983 bluetooth_gatt_client_char_prop_info_t param;
2985 sender = (char*)g_dbus_method_invocation_get_sender(context);
2986 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2988 __bt_service_get_parameters(in_param1, ¶m,
2989 sizeof(bluetooth_gatt_client_char_prop_info_t));
2991 result = _bt_gatt_read_characteristic_value(¶m);
2992 if (BLUETOOTH_ERROR_NONE == result) {
2993 /* Save the informations to invocation */
2994 _bt_save_invocation_context(context, result, sender,
2996 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3000 /* Async: Remote Interaction */
3001 case BT_GATT_READ_DESCRIPTOR_VALUE: {
3002 bluetooth_gatt_client_desc_prop_info_t param;
3004 sender = (char*)g_dbus_method_invocation_get_sender(context);
3005 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3007 __bt_service_get_parameters(in_param1, ¶m,
3008 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3010 result = _bt_gatt_read_descriptor_value(¶m);
3011 if (BLUETOOTH_ERROR_NONE == result) {
3012 /* Save the informations to invocation */
3013 _bt_save_invocation_context(context, result, sender,
3015 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3019 /* Async: Remote Interaction */
3020 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
3021 bluetooth_gatt_client_char_prop_info_t param;
3022 bluetooth_gatt_att_data_t data;
3023 bluetooth_gatt_write_type_e write_type;
3025 sender = (char*)g_dbus_method_invocation_get_sender(context);
3027 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3028 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3030 __bt_service_get_parameters(in_param1, ¶m,
3031 sizeof(bluetooth_gatt_client_char_prop_info_t));
3032 __bt_service_get_parameters(in_param2, &data,
3033 sizeof(bluetooth_gatt_att_data_t));
3034 __bt_service_get_parameters(in_param3, &write_type,
3035 sizeof(bluetooth_gatt_write_type_e));
3037 result = _bt_gatt_write_characteristic_value_by_type(¶m , &data, write_type);
3038 if (BLUETOOTH_ERROR_NONE == result) {
3039 /* Save the informations to invocation */
3040 _bt_save_invocation_context(context, result, sender,
3042 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3046 /* Async: Remote Interaction */
3047 case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
3048 bluetooth_gatt_client_desc_prop_info_t param;
3049 bluetooth_gatt_att_data_t data;
3050 bluetooth_gatt_write_type_e write_type;
3052 sender = (char*)g_dbus_method_invocation_get_sender(context);
3053 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3054 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3056 __bt_service_get_parameters(in_param1, ¶m,
3057 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3058 __bt_service_get_parameters(in_param2, &data,
3059 sizeof(bluetooth_gatt_att_data_t));
3060 __bt_service_get_parameters(in_param3, &write_type,
3061 sizeof(bluetooth_gatt_write_type_e));
3063 result = _bt_gatt_write_descriptor_value_by_type(¶m, &data, write_type);
3064 if (BLUETOOTH_ERROR_NONE == result) {
3065 /* Save the informations to invocation */
3066 _bt_save_invocation_context(context, result, sender,
3068 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3073 case BT_GATT_WATCH_CHARACTERISTIC: {
3074 bluetooth_gatt_client_char_prop_info_t param;
3079 gboolean is_indicate;
3082 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3084 sender = (char*)g_dbus_method_invocation_get_sender(context);
3086 __bt_service_get_parameters(in_param1, ¶m,
3087 sizeof(bluetooth_gatt_client_char_prop_info_t));
3088 __bt_service_get_parameters(in_param2, &client_id,
3090 __bt_service_get_parameters(in_param3, &is_notify,
3092 __bt_service_get_parameters(in_param4, &is_indicate,
3095 #ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
3099 if (is_indicate == false) {
3100 result = _bt_gatt_acquire_notify(¶m , &fd, &mtu);
3101 if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
3102 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
3104 GUnixFDList *fd_list = NULL;
3105 GError *error = NULL;
3107 g_array_append_vals(*out_param1, &mtu, sizeof(int));
3108 /* Add socket fd to unix_fd_list */
3109 fd_list = g_unix_fd_list_new();
3110 g_unix_fd_list_append(fd_list, fd, &error);
3111 g_assert_no_error(error);
3113 _bt_service_method_return_with_unix_fd_list(
3114 context, *out_param1, result, fd_list);
3116 g_object_unref(fd_list);
3122 result = _bt_gatt_watch_characteristic(¶m , client_id, is_notify);
3123 if (BLUETOOTH_ERROR_NONE == result) {
3124 /* Save the informations to invocation */
3125 _bt_save_invocation_context(context, result, sender, function_name,
3126 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3131 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: {
3132 gboolean is_enabled;
3133 bluetooth_device_address_t address;
3135 sender = (char*)g_dbus_method_invocation_get_sender(context);
3137 __bt_service_get_parameters(in_param1,
3138 &address, sizeof(bluetooth_device_address_t));
3139 __bt_service_get_parameters(in_param2, &is_enabled,
3141 result = _bt_gatt_watch_service_changed_indication(sender, &address, is_enabled);
3142 BT_INFO("Service changed indication from app [%s]", sender);
3146 case BT_LE_CONN_UPDATE: {
3147 char *sender = NULL;
3148 bluetooth_device_address_t local_address = { {0} };
3149 bluetooth_le_connection_param_t parameters = {0};
3151 sender = (char *)g_dbus_method_invocation_get_sender(context);
3153 __bt_service_get_parameters(in_param1, &local_address,
3154 sizeof(bluetooth_device_address_t));
3155 __bt_service_get_parameters(in_param2, ¶meters,
3156 sizeof(bluetooth_le_connection_param_t));
3158 result = _bt_le_connection_update(sender,
3160 parameters.interval_min,
3161 parameters.interval_max,
3163 parameters.timeout);
3166 case BT_START_LE_DISCOVERY: {
3170 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3172 sender = (char *)g_dbus_method_invocation_get_sender(context);
3174 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3175 BT_ERR("Fail to get the sender pid");
3177 result = _bt_start_le_scan(sender, uid, pid);
3178 if (result == BLUETOOTH_ERROR_NONE) {
3179 _bt_save_invocation_context(context, result, sender,
3180 function_name, NULL);
3182 BT_DBG("Remeber pid / uid for the scan operation");
3183 _bt_bm_add_scan_app(SCAN_LE, uid, pid);
3187 case BT_STOP_LE_DISCOVERY: {
3191 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3193 sender = (char *)g_dbus_method_invocation_get_sender(context);
3195 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3196 BT_ERR("Fail to get the sender pid");
3198 result = _bt_stop_le_scan(sender);
3199 if (result == BLUETOOTH_ERROR_NONE) {
3200 _bt_save_invocation_context(context, result, sender,
3201 function_name, NULL);
3204 BT_DBG("Remove pid / uid for the scan operation");
3205 _bt_bm_remove_scan_app(SCAN_LE, uid, pid);
3209 case BT_IS_LE_DISCOVERYING: {
3210 gboolean le_discovering = FALSE;
3212 le_discovering = _bt_is_le_scanning();
3213 g_array_append_vals(*out_param1,
3214 &le_discovering, sizeof(gboolean));
3217 case BT_SET_SCAN_PARAMETERS: {
3218 bluetooth_le_scan_params_t scan_params;
3220 __bt_service_get_parameters(in_param1, &scan_params,
3221 sizeof(bluetooth_le_scan_params_t));
3223 BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
3224 scan_params.interval, scan_params.window,
3227 result = _bt_prepare_scan_parameters(&scan_params, 0);
3230 case BT_SET_SCAN_TYPE: {
3232 __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
3234 BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
3235 result = _bt_prepare_scan_parameters(NULL, scan_type);
3238 #ifdef TIZEN_FEATURE_BT_PAN_NAP
3239 case BT_NETWORK_ACTIVATE:
3240 BT_DBG("BT_NETWORK_ACTIVATE Request recieved Request Handler ");
3241 result = _bt_network_activate();
3243 case BT_NETWORK_DEACTIVATE:
3244 result = _bt_network_deactivate();
3246 case BT_NETWORK_CONNECT: {
3247 bluetooth_device_address_t address = { {0} };
3250 __bt_service_get_parameters(in_param1,
3251 &address, sizeof(bluetooth_device_address_t));
3252 __bt_service_get_parameters(in_param2,
3253 &role, sizeof(int));
3255 result = _bt_network_connect(request_id, role, &address);
3256 if (result != BLUETOOTH_ERROR_NONE) {
3257 g_array_append_vals(*out_param1, &address,
3258 sizeof(bluetooth_device_address_t));
3262 case BT_NETWORK_DISCONNECT: {
3263 bluetooth_device_address_t address = { {0} };
3265 __bt_service_get_parameters(in_param1,
3266 &address, sizeof(bluetooth_device_address_t));
3268 result = _bt_network_disconnect(request_id, &address);
3269 if (result != BLUETOOTH_ERROR_NONE) {
3270 g_array_append_vals(*out_param1, &address,
3271 sizeof(bluetooth_device_address_t));
3275 case BT_NETWORK_SERVER_DISCONNECT: {
3276 bluetooth_device_address_t address = { {0} };
3278 __bt_service_get_parameters(in_param1,
3279 &address, sizeof(bluetooth_device_address_t));
3281 result = _bt_network_server_disconnect(request_id, &address);
3282 if (result != BLUETOOTH_ERROR_NONE) {
3283 g_array_append_vals(*out_param1, &address,
3284 sizeof(bluetooth_device_address_t));
3290 #ifdef TIZEN_FEATURE_BT_IPSP
3291 case BT_LE_IPSP_INIT:
3292 result = _bt_initialize_ipsp();
3294 case BT_LE_IPSP_DEINIT:
3295 result = _bt_deinitialize_ipsp();
3297 case BT_LE_IPSP_CONNECT: {
3298 bluetooth_device_address_t address = { {0} };
3299 __bt_service_get_parameters(in_param1, &address,
3300 sizeof(bluetooth_device_address_t));
3301 result = _bt_connect_le_ipsp_device(&address);
3304 case BT_LE_IPSP_DISCONNECT: {
3305 bluetooth_device_address_t address = { {0} };
3306 __bt_service_get_parameters(in_param1, &address,
3307 sizeof(bluetooth_device_address_t));
3308 result = _bt_disconnect_le_ipsp_device(&address);
3312 case BT_IS_ADVERTISING: {
3313 gboolean advertising = FALSE;
3314 advertising = _bt_is_advertising();
3315 g_array_append_vals(*out_param1, &advertising,
3319 case BT_IS_LE_2M_PHY_SUPPORTED: {
3320 gboolean is_2m_phy_supported = FALSE;
3322 is_2m_phy_supported = _bt_is_le_2m_phy_supported();
3323 g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean));
3326 case BT_IS_LE_CODED_PHY_SUPPORTED: {
3327 gboolean is_coded_phy_supported = FALSE;
3329 is_coded_phy_supported = _bt_is_le_coded_phy_supported();
3330 g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
3333 case BT_DISCONNECT_DEVICE: {
3334 bluetooth_device_address_t address = { {0} };
3336 __bt_service_get_parameters(in_param1,
3337 &address, sizeof(bluetooth_device_address_t));
3339 result = _bt_disconnect_device(&address);
3342 case BT_REGISTER_SCAN_FILTER: {
3343 bluetooth_le_scan_filter_t scan_filter;
3345 sender = (char*)g_dbus_method_invocation_get_sender(context);
3346 __bt_service_get_parameters(in_param1, &scan_filter,
3347 sizeof(bluetooth_le_scan_filter_t));
3349 BT_DBG("bluetooth_le_scan_filter_t [features : 0x%.2x]",
3350 scan_filter.added_features);
3352 result = _bt_register_scan_filter(sender, &scan_filter);
3358 result = _bt_mesh_init();
3361 case BT_MESH_DEINIT:
3362 result = _bt_mesh_deinit();
3365 case BT_MESH_NETWORK_CREATE: {
3366 bluetooth_mesh_node_t node;
3367 GSList *model_list = NULL;
3368 int total_models = 0;
3371 const char *network_name = NULL;
3372 bluetooth_mesh_network_t *network;
3374 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3375 sender = (char*)g_dbus_method_invocation_get_sender(context);
3377 __bt_service_get_parameters(in_param1,
3378 &node, sizeof(bluetooth_mesh_node_t));
3379 network_name = (const char *)g_variant_get_data(in_param2);
3380 BT_INFO("MESH: Network name [%s]", network_name);
3382 param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
3383 __bt_fill_garray_from_variant(in_param3, param3);
3385 total_models = (param3->len) / sizeof(bluetooth_mesh_model_t);
3386 for (i = 0; i < total_models; i++) {
3387 bluetooth_mesh_model_t *info = NULL;
3388 bluetooth_mesh_model_t *mod = NULL;
3390 info = &g_array_index(param3,
3391 bluetooth_mesh_model_t, i);
3393 mod = g_memdup(info, sizeof(bluetooth_mesh_model_t));
3396 model_list = g_slist_append(model_list,
3399 result = _bt_mesh_network_create(requester_unique_creds,
3400 sender, network_name, &node, model_list);
3402 /* Save invocation */
3403 if (result == BLUETOOTH_ERROR_NONE) {
3404 BT_INFO("Mesh: Save Invoation");
3405 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3407 /* Save Network name & UUID, Token will be received in event */
3408 _bt_mesh_util_convert_hex_to_string(
3409 (uint8_t *) node.uuid, 16,
3411 BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
3412 BT_INFO("Mesh: Mesh Netwok UUID [%s]", network->uuid);
3413 g_strlcpy(network->name.name, network_name,
3414 sizeof(network->name.name));
3415 g_strlcpy(network->app_cred,
3416 requester_unique_creds,
3417 sizeof(network->app_cred));
3418 sender = (char*)g_dbus_method_invocation_get_sender(context);
3419 _bt_save_invocation_context(context,
3421 function_name, (gpointer)network);
3423 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3424 BT_ERR("Mesh: Mesh Network creation schedule failed");
3425 g_slist_free_full(model_list, g_free);
3429 BT_INFO("Mesh: Cleanup");
3430 g_free((gpointer)requester_unique_creds);
3431 g_array_free(param3, TRUE);
3432 BT_INFO("Mesh: Cleanup Done");
3435 case BT_MESH_NETWORK_DESTROY: {
3436 bluetooth_mesh_network_t network;
3437 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3439 __bt_service_get_parameters(in_param1,
3440 &network, sizeof(bluetooth_mesh_network_t));
3442 BT_INFO("Mesh: Destroy Network");
3443 result = _bt_mesh_network_destroy(requester_unique_creds,
3446 if (result != BLUETOOTH_ERROR_NONE) {
3447 g_array_append_vals(*out_param1,
3448 &network, sizeof(bluetooth_mesh_network_t));
3450 BT_INFO("Mesh: Destroy Network scheduled: add invocation");
3451 bluetooth_mesh_network_t *net = \
3452 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3454 sender = (char*)g_dbus_method_invocation_get_sender(context);
3455 _bt_save_invocation_context(context, result, sender,
3456 function_name, (gpointer)net);
3460 case BT_MESH_NETWORK_LOAD: {
3462 bluetooth_mesh_network_t *network;
3463 token = (char *)g_variant_get_data(in_param1);
3464 BT_INFO("MESH: Network Load: Token string [%s]", token);
3465 result = _bt_mesh_network_load(requester_unique_creds, sender, token);
3466 /* Save invocation */
3467 if (result == BLUETOOTH_ERROR_NONE) {
3468 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3469 g_strlcpy(network->token.token, token, strlen(token));
3470 g_strlcpy(network->app_cred, requester_unique_creds, strlen(requester_unique_creds));
3472 sender = (char*)g_dbus_method_invocation_get_sender(context);
3473 _bt_save_invocation_context(context, result, sender,
3474 function_name, (gpointer)network);
3476 g_free((gpointer)requester_unique_creds);
3479 case BT_MESH_NETWORK_SCAN: {
3480 bluetooth_mesh_network_t network;
3481 bluetooth_mesh_scan_param_t param;
3482 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3483 memset(¶m, 0x00, sizeof(bluetooth_mesh_scan_param_t));
3485 __bt_service_get_parameters(in_param1,
3486 &network, sizeof(bluetooth_mesh_network_t));
3488 __bt_service_get_parameters(in_param2,
3489 ¶m, sizeof(bluetooth_mesh_scan_param_t));
3491 result = _bt_mesh_network_scan(requester_unique_creds,
3492 sender, &network, ¶m);
3494 if (result != BLUETOOTH_ERROR_NONE) {
3495 g_array_append_vals(*out_param1,
3496 &network, sizeof(bluetooth_mesh_network_t));
3498 bluetooth_mesh_network_t *net = \
3499 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3501 sender = (char*)g_dbus_method_invocation_get_sender(context);
3502 _bt_save_invocation_context(context, result, sender,
3503 function_name, (gpointer)net);
3507 case BT_MESH_NETWORK_CANCEL_SCAN: {
3508 bluetooth_mesh_network_t network;
3509 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3511 __bt_service_get_parameters(in_param1,
3512 &network, sizeof(bluetooth_mesh_network_t));
3514 result = _bt_mesh_network_scan_cancel(requester_unique_creds,
3517 if (result != BLUETOOTH_ERROR_NONE)
3518 g_array_append_vals(*out_param1,
3519 &network, sizeof(bluetooth_mesh_network_t));
3522 case BT_MESH_NETWORK_SET_CAPABILITIES: {
3523 bluetooth_mesh_network_t network;
3524 bluetooth_mesh_provisioner_caps_t caps;
3525 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3526 memset(&caps, 0x00, sizeof(bluetooth_mesh_provisioner_caps_t));
3528 __bt_service_get_parameters(in_param1,
3529 &network, sizeof(bluetooth_mesh_network_t));
3531 __bt_service_get_parameters(in_param2,
3532 &caps, sizeof(bluetooth_mesh_provisioner_caps_t));
3534 result = _bt_mesh_network_set_provisioner_caps(
3535 requester_unique_creds, sender, &network, &caps);
3539 case BT_MESH_NETWORK_PROVISION_DEVICE: {
3540 bluetooth_mesh_provisioning_request_t req;
3541 memset(&req, 0x00, sizeof(bluetooth_mesh_provisioning_request_t));
3543 __bt_service_get_parameters(in_param1,
3544 &req, sizeof(bluetooth_mesh_provisioning_request_t));
3546 BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
3547 BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
3549 result = _bt_mesh_network_provision_device(
3550 requester_unique_creds, sender, &req);
3552 /* Save invocation */
3553 if (result != BLUETOOTH_ERROR_NONE) {
3554 g_array_append_vals(*out_param1, &req,
3555 sizeof(bluetooth_mesh_provisioning_request_t));
3557 bluetooth_mesh_provisioning_request_t *param = \
3558 g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t));
3560 sender = (char*)g_dbus_method_invocation_get_sender(context);
3561 _bt_save_invocation_context(context, result, sender,
3562 function_name, (gpointer)param);
3566 case BT_MESH_AUTHENTICATION_REPLY: {
3567 BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
3568 const char *auth_value = NULL;
3569 gboolean authentication_reply = FALSE;
3571 auth_value = g_variant_get_data(in_param2);
3572 __bt_service_get_parameters(in_param3,
3573 &authentication_reply, sizeof(gboolean));
3574 __bt_service_get_parameters(in_param1,
3575 &auth_type, sizeof(int));
3576 BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
3577 BT_INFO("Mesh: Auth Value [%s]", auth_value);
3578 BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
3579 result = _bt_mesh_authentication_reply(auth_type,
3580 auth_value, authentication_reply);
3583 case BT_MESH_NETWORK_SET_NAME: {
3584 bluetooth_mesh_network_t network;
3585 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3587 __bt_service_get_parameters(in_param1,
3588 &network, sizeof(bluetooth_mesh_network_t));
3590 result = _bt_mesh_network_set_name(requester_unique_creds, sender, &network);
3594 case BT_MESH_NETWORK_ADD_NETKEY: {
3595 bluetooth_mesh_network_t network;
3596 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3598 __bt_service_get_parameters(in_param1,
3599 &network, sizeof(bluetooth_mesh_network_t));
3601 result = _bt_mesh_network_add_netkey(requester_unique_creds,
3604 if (result != BLUETOOTH_ERROR_NONE) {
3605 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3607 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3609 sender = (char*)g_dbus_method_invocation_get_sender(context);
3610 _bt_save_invocation_context(context, result, sender,
3611 function_name, (gpointer)net);
3615 case BT_MESH_NETWORK_DELETE_NETKEY: {
3616 bluetooth_mesh_network_t network;
3619 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3621 __bt_service_get_parameters(in_param1,
3622 &network, sizeof(bluetooth_mesh_network_t));
3623 __bt_service_get_parameters(in_param2,
3624 &index, sizeof(guint16));
3626 result = _bt_mesh_network_delete_netkey(requester_unique_creds,
3627 sender, &network, index);
3629 if (result != BLUETOOTH_ERROR_NONE) {
3630 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3632 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3634 sender = (char*)g_dbus_method_invocation_get_sender(context);
3635 _bt_save_invocation_context(context, result, sender,
3636 function_name, (gpointer)net);
3640 case BT_MESH_NETWORK_UPDATE_NETKEY: {
3641 bluetooth_mesh_network_t network;
3644 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3646 __bt_service_get_parameters(in_param1,
3647 &network, sizeof(bluetooth_mesh_network_t));
3648 __bt_service_get_parameters(in_param2,
3649 &index, sizeof(guint16));
3651 result = _bt_mesh_network_update_netkey(requester_unique_creds,
3652 sender, &network, index);
3654 if (result != BLUETOOTH_ERROR_NONE) {
3655 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3657 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3659 sender = (char*)g_dbus_method_invocation_get_sender(context);
3660 _bt_save_invocation_context(context, result, sender,
3661 function_name, (gpointer)net);
3665 case BT_MESH_NETWORK_ADD_APPKEY: {
3666 bluetooth_mesh_network_t network;
3669 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3671 __bt_service_get_parameters(in_param1,
3672 &network, sizeof(bluetooth_mesh_network_t));
3673 __bt_service_get_parameters(in_param2,
3674 &net_idx, sizeof(guint16));
3676 result = _bt_mesh_network_add_appkey(requester_unique_creds,
3677 sender, &network, net_idx);
3679 if (result != BLUETOOTH_ERROR_NONE) {
3680 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3682 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3684 sender = (char*)g_dbus_method_invocation_get_sender(context);
3685 _bt_save_invocation_context(context, result, sender,
3686 function_name, (gpointer)net);
3690 case BT_MESH_NETWORK_UPDATE_APPKEY: {
3691 bluetooth_mesh_network_t network;
3695 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3697 __bt_service_get_parameters(in_param1,
3698 &network, sizeof(bluetooth_mesh_network_t));
3699 __bt_service_get_parameters(in_param2,
3700 &net_idx, sizeof(guint16));
3701 __bt_service_get_parameters(in_param3,
3702 &app_idx, sizeof(guint16));
3704 result = _bt_mesh_network_update_appkey(requester_unique_creds,
3705 sender, &network, net_idx, app_idx);
3707 if (result != BLUETOOTH_ERROR_NONE) {
3708 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3710 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3712 sender = (char*)g_dbus_method_invocation_get_sender(context);
3713 _bt_save_invocation_context(context, result, sender,
3714 function_name, (gpointer)net);
3718 case BT_MESH_NETWORK_DELETE_APPKEY: {
3719 bluetooth_mesh_network_t network;
3723 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3725 __bt_service_get_parameters(in_param1,
3726 &network, sizeof(bluetooth_mesh_network_t));
3727 __bt_service_get_parameters(in_param2,
3728 &net_idx, sizeof(guint16));
3729 __bt_service_get_parameters(in_param3,
3730 &app_idx, sizeof(guint16));
3732 result = _bt_mesh_network_delete_appkey(requester_unique_creds,
3733 sender, &network, net_idx, app_idx);
3735 if (result != BLUETOOTH_ERROR_NONE) {
3736 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3738 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3740 sender = (char*)g_dbus_method_invocation_get_sender(context);
3741 _bt_save_invocation_context(context, result, sender,
3742 function_name, (gpointer)net);
3746 case BT_MESH_NETWORK_GET_NETKEYS: {
3747 bluetooth_mesh_network_t network;
3748 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3749 __bt_service_get_parameters(in_param1,
3750 &network, sizeof(bluetooth_mesh_network_t));
3751 result = _bt_mesh_network_get_netkeys(requester_unique_creds,
3752 sender, &network, out_param1);
3755 case BT_MESH_NETWORK_GET_APPKEYS: {
3756 bluetooth_mesh_network_t network;
3759 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3760 __bt_service_get_parameters(in_param1,
3761 &network, sizeof(bluetooth_mesh_network_t));
3762 __bt_service_get_parameters(in_param2,
3763 &net_idx, sizeof(guint16));
3764 result = _bt_mesh_network_get_appkeys(
3765 requester_unique_creds, sender,
3766 &network, net_idx, out_param1);
3769 case BT_MESH_NETWORK_GET_NODES: {
3770 bluetooth_mesh_network_t network;
3771 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3772 __bt_service_get_parameters(in_param1,
3773 &network, sizeof(bluetooth_mesh_network_t));
3774 result = _bt_mesh_network_get_nodes(
3775 requester_unique_creds, sender,
3776 &network, out_param1);
3779 case BT_MESH_ELEMENT_GET_MODELS: {
3780 bluetooth_mesh_network_t network;
3784 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3785 __bt_service_get_parameters(in_param1,
3786 &network, sizeof(bluetooth_mesh_network_t));
3787 __bt_service_get_parameters(in_param2,
3788 &node_addr, sizeof(guint16));
3789 __bt_service_get_parameters(in_param3,
3790 &elem_idx, sizeof(int));
3791 result = _bt_mesh_element_get_models(requester_unique_creds, sender,
3792 &network, node_addr, elem_idx, out_param1);
3795 case BT_MESH_NODE_BROWSE: {
3796 bluetooth_mesh_node_discover_t req;
3797 memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3799 __bt_service_get_parameters(in_param1,
3800 &req, sizeof(bluetooth_mesh_node_discover_t));
3802 result = _bt_mesh_browse_remote_node(
3803 requester_unique_creds, sender, &req);
3805 /* Save invocation */
3806 if (result != BLUETOOTH_ERROR_NONE) {
3807 g_array_append_vals(*out_param1, &req,
3808 sizeof(bluetooth_mesh_node_discover_t));
3810 bluetooth_mesh_node_discover_t *param = \
3811 g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
3813 sender = (char*)g_dbus_method_invocation_get_sender(context);
3814 _bt_save_invocation_context(context, result, sender,
3815 function_name, (gpointer)param);
3819 case BT_MESH_NODE_GET_VENDOR_FEATURES: {
3820 bluetooth_mesh_node_features_t req;
3821 memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
3823 __bt_service_get_parameters(in_param1,
3824 &req, sizeof(bluetooth_mesh_node_features_t));
3826 result = _bt_mesh_node_discover_vendor_features(
3827 requester_unique_creds, sender, &req);
3829 /* Save invocation */
3830 if (result != BLUETOOTH_ERROR_NONE) {
3831 g_array_append_vals(*out_param1,
3832 &req, sizeof(bluetooth_mesh_node_features_t));
3834 bluetooth_mesh_node_features_t *param = \
3835 g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
3837 sender = (char*)g_dbus_method_invocation_get_sender(context);
3838 _bt_save_invocation_context(context, result, sender,
3839 function_name, (gpointer)param);
3843 case BT_MESH_NODE_CONFIGURE_KEY: {
3844 bluetooth_mesh_key_configure_t req;
3846 memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
3848 __bt_service_get_parameters(in_param1,
3849 &req, sizeof(bluetooth_mesh_key_configure_t));
3851 result = _bt_mesh_node_configure_key(
3852 requester_unique_creds, sender, &req);
3854 /* Save invocation */
3855 if (result != BLUETOOTH_ERROR_NONE) {
3856 g_array_append_vals(*out_param1,
3857 &req, sizeof(bluetooth_mesh_key_configure_t));
3859 bluetooth_mesh_key_configure_t *param = \
3860 g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
3862 sender = (char*)g_dbus_method_invocation_get_sender(context);
3863 _bt_save_invocation_context(context, result, sender,
3864 function_name, (gpointer)param);
3868 case BT_MESH_NODE_TTL_EXECUTE: {
3869 bluetooth_mesh_node_ttl_info_t req;
3871 memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
3873 __bt_service_get_parameters(in_param1,
3874 &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3876 result = _bt_mesh_ttl_execute_remote_node(
3877 requester_unique_creds, sender, &req);
3879 /* Save invocation */
3880 if (result != BLUETOOTH_ERROR_NONE) {
3881 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3883 bluetooth_mesh_node_ttl_info_t *param = \
3884 g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
3886 sender = (char*)g_dbus_method_invocation_get_sender(context);
3887 _bt_save_invocation_context(context, result, sender,
3888 function_name, (gpointer)param);
3892 case BT_MESH_MODEL_CONFIGURE_APPKEY: {
3893 bluetooth_mesh_model_configure_t req;
3895 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3897 __bt_service_get_parameters(in_param1,
3898 &req, sizeof(bluetooth_mesh_model_configure_t));
3900 result = _bt_mesh_node_model_appkey_execute(
3901 requester_unique_creds, sender, &req);
3903 /* Save invocation */
3904 if (result != BLUETOOTH_ERROR_NONE) {
3905 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3907 bluetooth_mesh_model_configure_t *param = \
3908 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3910 sender = (char*)g_dbus_method_invocation_get_sender(context);
3911 _bt_save_invocation_context(context, result, sender,
3912 function_name, (gpointer)param);
3916 case BT_MESH_MODEL_EXECUTE_MSG: {
3917 bluetooth_mesh_model_msg_t req;
3919 memset(&req, 0x00, sizeof(bluetooth_mesh_model_msg_t));
3921 __bt_service_get_parameters(in_param1,
3922 &req, sizeof(bluetooth_mesh_model_msg_t));
3924 result = _bt_mesh_model_execute_msg(
3925 requester_unique_creds, sender, &req);
3927 /* Save invocation */
3928 if (result != BLUETOOTH_ERROR_NONE) {
3929 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t));
3931 bluetooth_mesh_model_msg_t *param = \
3932 g_memdup(&req, sizeof(bluetooth_mesh_model_msg_t));
3934 sender = (char*)g_dbus_method_invocation_get_sender(context);
3935 _bt_save_invocation_context(context, result, sender,
3936 function_name, (gpointer)param);
3940 case BT_MESH_NODE_GET_NETKEYS: {
3941 bluetooth_mesh_node_discover_t node;
3942 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3943 __bt_service_get_parameters(in_param1,
3944 &node, sizeof(bluetooth_mesh_node_discover_t));
3945 result = _bt_mesh_network_node_get_netkeys(
3946 requester_unique_creds, &node, out_param1);
3949 case BT_MESH_NODE_GET_APPKEYS: {
3950 bluetooth_mesh_node_discover_t node;
3951 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3952 __bt_service_get_parameters(in_param1,
3953 &node, sizeof(bluetooth_mesh_node_discover_t));
3954 result = _bt_mesh_network_node_get_appkeys(
3955 requester_unique_creds, sender, &node, out_param1);
3958 case BT_MESH_NODE_RESET: {
3959 bluetooth_mesh_node_info_t node;
3960 memset(&node, 0x00, sizeof(bluetooth_mesh_node_info_t));
3962 __bt_service_get_parameters(in_param1,
3963 &node, sizeof(bluetooth_mesh_node_info_t));
3965 BT_INFO("Mesh: Reset the Node");
3966 result = _bt_mesh_network_reset_node(requester_unique_creds,
3971 case BT_MESH_MODEL_GET_APPKEY_LIST: {
3972 bluetooth_mesh_model_configure_t req;
3974 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3976 __bt_service_get_parameters(in_param1,
3977 &req, sizeof(bluetooth_mesh_model_configure_t));
3979 result = _bt_mesh_node_model_get_appkey_list(
3980 requester_unique_creds, sender, &req);
3982 /* Save invocation */
3983 if (result != BLUETOOTH_ERROR_NONE) {
3984 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3986 bluetooth_mesh_model_configure_t *param = \
3987 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3989 sender = (char*)g_dbus_method_invocation_get_sender(context);
3990 _bt_save_invocation_context(context, result, sender,
3991 function_name, (gpointer)param);
3995 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
3996 bluetooth_mesh_model_configure_t req;
3998 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4000 __bt_service_get_parameters(in_param1,
4001 &req, sizeof(bluetooth_mesh_model_configure_t));
4003 result = _bt_mesh_node_model_get_subscription_list(
4004 requester_unique_creds, sender, &req);
4006 /* Save invocation */
4007 if (result != BLUETOOTH_ERROR_NONE) {
4008 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4010 bluetooth_mesh_model_configure_t *param = \
4011 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4013 sender = (char*)g_dbus_method_invocation_get_sender(context);
4014 _bt_save_invocation_context(context, result, sender,
4015 function_name, (gpointer)param);
4020 case BT_MESH_NETWORK_CREATE_GROUP: {
4021 bluetooth_mesh_network_t net;
4022 bluetooth_mesh_network_group_info_t res;
4023 gboolean is_virtual;
4026 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4027 memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4029 __bt_service_get_parameters(in_param1,
4030 &net, sizeof(bluetooth_mesh_network_t));
4031 __bt_service_get_parameters(in_param2,
4032 &is_virtual, sizeof(gboolean));
4033 __bt_service_get_parameters(in_param3,
4034 &grp_addr, sizeof(guint16));
4036 result = _bt_mesh_network_create_group(
4037 requester_unique_creds, sender, &net,
4038 is_virtual, grp_addr, &res);
4040 if (result == BLUETOOTH_ERROR_NONE)
4041 g_array_append_vals(*out_param1, &res,
4042 sizeof(bluetooth_mesh_network_group_info_t));
4045 case BT_MESH_NETWORK_REMOVE_GROUP: {
4046 bluetooth_mesh_network_t net;
4047 bluetooth_mesh_network_group_info_t req;
4049 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4050 memset(&req, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4052 __bt_service_get_parameters(in_param1,
4053 &net, sizeof(bluetooth_mesh_network_t));
4054 __bt_service_get_parameters(in_param2,
4055 &req, sizeof(bluetooth_mesh_network_group_info_t));
4057 result = _bt_mesh_network_remove_group(
4058 requester_unique_creds, sender, &net, &req);
4062 case BT_MESH_MODEL_CONFIG_GROUP_SUB: {
4063 bluetooth_mesh_model_configure_t req;
4065 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4067 __bt_service_get_parameters(in_param1,
4068 &req, sizeof(bluetooth_mesh_model_configure_t));
4070 result = _bt_mesh_model_configure_group_subscription(
4071 requester_unique_creds, sender, &req);
4073 /* Save invocation */
4074 if (result != BLUETOOTH_ERROR_NONE) {
4075 g_array_append_vals(*out_param1,
4076 &req, sizeof(bluetooth_mesh_model_configure_t));
4078 bluetooth_mesh_model_configure_t *param = \
4079 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4081 sender = (char*)g_dbus_method_invocation_get_sender(context);
4082 _bt_save_invocation_context(context, result, sender,
4083 function_name, (gpointer)param);
4087 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
4088 bluetooth_mesh_model_configure_t req;
4090 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4092 __bt_service_get_parameters(in_param1,
4093 &req, sizeof(bluetooth_mesh_model_configure_t));
4095 result = _bt_mesh_model_configure_virtual_group_subscription(
4096 requester_unique_creds, sender, &req);
4098 /* Save invocation */
4099 if (result != BLUETOOTH_ERROR_NONE) {
4100 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4102 bluetooth_mesh_model_configure_t *param = \
4103 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4105 sender = (char*)g_dbus_method_invocation_get_sender(context);
4106 _bt_save_invocation_context(context, result, sender,
4107 function_name, (gpointer)param);
4111 case BT_MESH_MODEL_SET_PUBLICATION: {
4112 bluetooth_mesh_model_configure_t req;
4114 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4116 __bt_service_get_parameters(in_param1,
4117 &req, sizeof(bluetooth_mesh_model_configure_t));
4119 result = _bt_mesh_model_set_publication(
4120 requester_unique_creds, sender, &req);
4122 /* Save invocation */
4123 if (result != BLUETOOTH_ERROR_NONE) {
4124 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4126 bluetooth_mesh_model_configure_t *param = g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4128 sender = (char*)g_dbus_method_invocation_get_sender(context);
4129 _bt_save_invocation_context(context, result, sender,
4130 function_name, (gpointer)param);
4134 case BT_MESH_MODEL_GET_PUBLICATION: {
4135 bluetooth_mesh_model_configure_t req;
4137 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4139 __bt_service_get_parameters(in_param1,
4140 &req, sizeof(bluetooth_mesh_model_configure_t));
4142 result = _bt_mesh_model_get_publication(
4143 requester_unique_creds, sender, &req);
4145 /* Save invocation */
4146 if (result != BLUETOOTH_ERROR_NONE) {
4147 g_array_append_vals(*out_param1,
4148 &req, sizeof(bluetooth_mesh_model_configure_t));
4150 bluetooth_mesh_model_configure_t *param = \
4151 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4153 sender = (char*)g_dbus_method_invocation_get_sender(context);
4154 _bt_save_invocation_context(context, result, sender,
4155 function_name, (gpointer)param);
4159 case BT_MESH_NETWORK_GET_GROUPS: {
4160 bluetooth_mesh_network_t network;
4161 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4162 __bt_service_get_parameters(in_param1,
4163 &network, sizeof(bluetooth_mesh_network_t));
4164 BT_INFO("Mesh: Request:: Get Groups");
4165 result = _bt_mesh_network_get_groups(
4166 requester_unique_creds, sender, &network, out_param1);
4170 BT_INFO("UnSupported function [%d]", function_name);
4171 result = BLUETOOTH_ERROR_NOT_SUPPORT;
4177 #ifdef TIZEN_FEATURE_BT_OBEX
4178 /* Function definitions*/
4179 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
4184 size = g_variant_get_size(var);
4186 data = (char *)g_variant_get_data(var);
4188 param = g_array_append_vals(param, data, size);
4194 int __bt_obexd_request(int function_name,
4197 GDBusMethodInvocation *context,
4198 GVariant *in_param1,
4199 GVariant *in_param2,
4200 GVariant *in_param3,
4201 GVariant *in_param4,
4202 GArray **out_param1)
4206 int result = BLUETOOTH_ERROR_NONE;
4208 BT_DBG("function_name : %x", function_name);
4210 switch (function_name) {
4211 case BT_OPP_PUSH_FILES: {
4212 BT_DBG("BT_OPP_PUSH_FILES");
4214 bluetooth_device_address_t address = { {0} };
4215 bt_file_path_t *path;
4220 __bt_service_get_parameters(in_param1, &address,
4221 sizeof(bluetooth_device_address_t));
4222 __bt_service_get_parameters(in_param3, &file_count,
4225 file_path = g_new0(char *, file_count + 1);
4227 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
4228 __bt_fill_garray_from_variant(in_param2, param2);
4230 for (i = 0; i < file_count; i++) {
4231 path = &g_array_index(param2, bt_file_path_t, i);
4232 file_path[i] = g_strdup(path->path);
4234 BT_DBG("_bt_opp_client_push_files");
4235 result = _bt_opp_client_push_files(request_id, context,
4236 &address, file_path,
4239 for (i = 0; i < file_count; i++)
4240 g_free(file_path[i]);
4243 g_array_free(param2, TRUE);
4247 case BT_OPP_CANCEL_PUSH: {
4248 result = _bt_opp_client_cancel_push();
4252 case BT_OPP_IS_PUSHING_FILES: {
4253 gboolean is_sending = FALSE;
4255 result = _bt_opp_client_is_sending(&is_sending);
4257 g_array_append_vals(*out_param1, &is_sending,
4261 case BT_OPP_GET_TRANSFER_PROGRESS: {
4264 guint8 progress = 0;
4266 __bt_service_get_parameters(in_param1, &direction,
4268 __bt_service_get_parameters(in_param2, &transfer_id,
4271 result = _bt_opp_get_client_progress(&progress);
4273 result = _bt_opp_get_server_progress(transfer_id, &progress);
4275 g_array_append_vals(*out_param1, &progress,
4281 case BT_MAP_CREATE_SESSION: {
4282 BT_DBG("BT_MAP_CREATE_SESSION");
4283 char *address = (char *)g_variant_get_data(in_param1);
4284 char *session_id = NULL;
4285 result = _bt_create_session_sync(address, &session_id);
4286 if (result == BLUETOOTH_ERROR_NONE)
4287 g_array_append_vals(*out_param1, session_id, strlen(session_id)+1);
4291 case BT_MAP_DESTROY_SESSION: {
4292 BT_DBG("BT_MAP_DESTROY_SESSION");
4293 char* session_id = (char *)g_variant_get_data(in_param1);
4294 result = _bt_destroy_session_sync(session_id);
4295 if (result == BLUETOOTH_ERROR_NONE)
4296 BT_DBG("successfully destroyed session");
4300 case BT_MAP_SET_FOLDER: {
4301 BT_DBG("BT_MAP_SET_FOLDER");
4302 char *session_id = (char *)g_variant_get_data(in_param1);
4303 char *name = (char *)g_variant_get_data(in_param2);
4304 result = _bt_map_client_set_folder(session_id, name);
4308 case BT_MAP_LIST_FOLDERS: {
4309 BT_DBG("BT_MAP_LIST_FOLDERS");
4311 char* session_id = (char *)g_variant_get_data(in_param1);
4312 char* filter_serialized = (char*)g_variant_get_data(in_param2);
4314 result = _bt_map_client_list_folders(request_id, context, session_id, filter_serialized);
4315 if (result == BLUETOOTH_ERROR_NONE)
4316 BT_DBG("_bt_map_client_list_folders succeed");
4321 case BT_MAP_LIST_FILTER_FIELDS: {
4322 BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
4324 char* session_id = (char *)g_variant_get_data(in_param1);
4326 result = _bt_map_client_list_filter_fields(request_id, context, session_id);
4327 if (result == BLUETOOTH_ERROR_NONE)
4328 BT_DBG("_bt_map_client_list_filter_fields succeed");
4333 case BT_MAP_LIST_MESSAGES: {
4334 BT_DBG("BT_MAP_LIST_MESSAGES");
4336 char* session_id = (char*)g_variant_get_data(in_param1);
4337 char* folder = (char*)g_variant_get_data(in_param2);
4338 char* filter_serialized = (char*)g_variant_get_data(in_param3);
4340 result = _bt_map_client_list_messages(request_id, context, session_id, folder, filter_serialized);
4341 if (result == BLUETOOTH_ERROR_NONE)
4342 BT_DBG("_bt_map_client_list_messages succeed");
4344 BT_DBG("_bt_map_client_list_messages failed");
4349 case BT_MAP_UPDATE_INBOX: {
4350 BT_DBG("BT_MAP_UPDATE_INBOX");
4351 char* session_id = (char *)g_variant_get_data(in_param1);
4352 result = _bt_map_client_update_inbox(session_id);
4356 case BT_MAP_PUSH_MESSAGE: {
4357 BT_DBG("BT_MAP_PUSH_MESSAGE");
4359 char* session_id = (char *)g_variant_get_data(in_param1);
4360 char* source_file = (char *)g_variant_get_data(in_param2);
4361 char* folder = (char *)g_variant_get_data(in_param3);
4362 char* args_serialized = (char *)g_variant_get_data(in_param4);
4364 result = _bt_map_client_push_message(
4365 request_id, context, session_id, source_file, folder, args_serialized);
4366 if (result == BLUETOOTH_ERROR_NONE)
4367 BT_DBG("_bt_map_client_push_message succeed");
4369 BT_ERR("_bt_map_client_push_message failed");
4374 case BT_MAP_GET_MESSAGE: {
4375 BT_DBG("BT_MAP_GET_MESSAGE");
4376 // TODO session currently is not used, but should be valid
4377 //char* session_id = (char *)g_variant_get_data(in_param1);
4378 char* message_object = (char *)g_variant_get_data(in_param2);
4379 char* target_file = (char *)g_variant_get_data(in_param3);
4380 bool attachment = false;
4381 __bt_service_get_parameters(in_param4, &attachment, sizeof(bool));
4383 result = _bt_map_client_get_message(request_id, context, message_object,
4384 target_file, attachment);
4385 if (result == BLUETOOTH_ERROR_NONE)
4386 BT_DBG("_bt_map_client_get_message succeed");
4391 case BT_OBEX_SERVER_ALLOCATE: {
4397 sender = (char *)g_dbus_method_invocation_get_sender(context);
4399 path = (char *)g_variant_get_data(in_param1);
4400 __bt_service_get_parameters(in_param2, &is_native,
4402 __bt_service_get_parameters(in_param3, &app_pid,
4405 result = _bt_obex_server_allocate(sender,
4406 path, app_pid, is_native);
4410 case BT_OBEX_SERVER_DEALLOCATE: {
4414 __bt_service_get_parameters(in_param1, &is_native,
4416 __bt_service_get_parameters(in_param2, &app_pid,
4419 result = _bt_obex_server_deallocate(app_pid, is_native);
4422 case BT_OBEX_SERVER_IS_ACTIVATED: {
4423 gboolean is_activated = FALSE;
4425 result = _bt_obex_server_is_activated(&is_activated);
4427 g_array_append_vals(*out_param1, &is_activated,
4432 case BT_OBEX_SERVER_ACCEPT_CONNECTION: {
4433 result = _bt_obex_server_accept_connection(request_id);
4437 case BT_OBEX_SERVER_REJECT_CONNECTION: {
4438 result = _bt_obex_server_reject_connection();
4442 case BT_OBEX_SERVER_ACCEPT_FILE: {
4445 file_name = (char *)g_variant_get_data(in_param1);
4447 result = _bt_obex_server_accept_authorize(file_name, TRUE);
4451 case BT_OBEX_SERVER_REJECT_FILE: {
4452 result = _bt_obex_server_reject_authorize();
4456 case BT_OBEX_SERVER_SET_PATH: {
4458 char *destination_path;
4460 destination_path = (char *)g_variant_get_data(in_param1);
4461 __bt_service_get_parameters(in_param2, &is_native,
4464 result = _bt_obex_server_set_destination_path(destination_path,
4469 case BT_OBEX_SERVER_SET_ROOT: {
4472 root = (char *)g_variant_get_data(in_param1);
4474 result = _bt_obex_server_set_root(root);
4478 case BT_OBEX_SERVER_CANCEL_TRANSFER: {
4481 __bt_service_get_parameters(in_param1, &transfer_id,
4484 result = _bt_obex_server_cancel_transfer(transfer_id);
4488 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS: {
4489 result = _bt_obex_server_cancel_all_transfers();
4493 case BT_OBEX_SERVER_IS_RECEIVING: {
4494 gboolean is_receiving = FALSE;
4496 result = _bt_obex_server_is_receiving(&is_receiving);
4498 g_array_append_vals(*out_param1, &is_receiving,
4502 case BT_PBAP_CONNECT: {
4503 bluetooth_device_address_t address = { {0} };
4505 __bt_service_get_parameters(in_param1, &address,
4506 sizeof(bluetooth_device_address_t));
4508 result = _bt_pbap_connect(&address);
4511 case BT_PBAP_DISCONNECT: {
4512 bluetooth_device_address_t address = { {0} };
4514 __bt_service_get_parameters(in_param1, &address,
4515 sizeof(bluetooth_device_address_t));
4517 result = _bt_pbap_disconnect(&address);
4520 case BT_PBAP_GET_PHONEBOOK_SIZE: {
4521 bluetooth_device_address_t address = { {0} };
4522 bt_pbap_folder_t folder = { 0, };
4524 __bt_service_get_parameters(in_param1, &address,
4525 sizeof(bluetooth_device_address_t));
4526 __bt_service_get_parameters(in_param2, &folder,
4527 sizeof(bt_pbap_folder_t));
4529 result = _bt_pbap_get_phonebook_size(&address,
4530 folder.addressbook, folder.folder_type);
4533 case BT_PBAP_GET_PHONEBOOK: {
4534 bluetooth_device_address_t address = { {0} };
4535 bt_pbap_folder_t folder = { 0, };
4536 bt_pbap_pull_parameters_t app_param = { 0, };
4538 __bt_service_get_parameters(in_param1, &address,
4539 sizeof(bluetooth_device_address_t));
4540 __bt_service_get_parameters(in_param2, &folder,
4541 sizeof(bt_pbap_folder_t));
4542 __bt_service_get_parameters(in_param3, &app_param,
4543 sizeof(bt_pbap_pull_parameters_t));
4545 result = _bt_pbap_get_phonebook(&address, folder.addressbook,
4546 folder.folder_type, &app_param);
4549 case BT_PBAP_GET_LIST: {
4550 bluetooth_device_address_t address = { {0} };
4551 bt_pbap_folder_t folder = { 0, };
4552 bt_pbap_list_parameters_t app_param = { 0, };
4554 __bt_service_get_parameters(in_param1, &address,
4555 sizeof(bluetooth_device_address_t));
4556 __bt_service_get_parameters(in_param2, &folder,
4557 sizeof(bt_pbap_folder_t));
4558 __bt_service_get_parameters(in_param3, &app_param,
4559 sizeof(bt_pbap_list_parameters_t));
4561 result = _bt_pbap_get_list(&address, folder.addressbook,
4562 folder.folder_type, &app_param);
4565 case BT_PBAP_PULL_VCARD: {
4566 bluetooth_device_address_t address = { {0} };
4567 bt_pbap_folder_t folder = { 0, };
4568 bt_pbap_pull_vcard_parameters_t app_param = { 0, };
4570 __bt_service_get_parameters(in_param1, &address,
4571 sizeof(bluetooth_device_address_t));
4572 __bt_service_get_parameters(in_param2, &folder,
4573 sizeof(bt_pbap_folder_t));
4574 __bt_service_get_parameters(in_param3, &app_param,
4575 sizeof(bt_pbap_pull_vcard_parameters_t));
4577 result = _bt_pbap_pull_vcard(&address, folder.addressbook,
4578 folder.folder_type, &app_param);
4581 case BT_PBAP_PHONEBOOK_SEARCH: {
4582 bluetooth_device_address_t address = { {0} };
4583 bt_pbap_folder_t folder = { 0, };
4584 bt_pbap_search_parameters_t app_param = { 0, };
4586 __bt_service_get_parameters(in_param1, &address,
4587 sizeof(bluetooth_device_address_t));
4588 __bt_service_get_parameters(in_param2, &folder,
4589 sizeof(bt_pbap_folder_t));
4590 __bt_service_get_parameters(in_param3, &app_param,
4591 sizeof(bt_pbap_search_parameters_t));
4593 result = _bt_pbap_phonebook_search(&address, folder.addressbook,
4594 folder.folder_type, &app_param);
4599 BT_ERR("Unknown function!");
4600 result = BLUETOOTH_ERROR_INTERNAL;
4609 int __bt_agent_request(int function_name,
4612 GDBusMethodInvocation *context,
4613 GVariant *in_param1,
4614 GVariant *in_param2,
4615 GVariant *in_param3,
4616 GVariant *in_param4,
4617 GArray **out_param1)
4620 switch (function_name) {
4621 case BT_SET_AUTHORIZATION: {
4628 sender = (char *)g_dbus_method_invocation_get_sender(context);
4629 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4630 uuid = (char *)g_variant_get_data(in_param2);
4631 path = (char *)g_variant_get_data(in_param3);
4632 __bt_service_get_parameters(in_param4, &fd, sizeof(int));
4634 result = _bt_register_osp_server_in_agent(sender, type, uuid, path, fd);
4637 case BT_UNSET_AUTHORIZATION: {
4641 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4642 uuid = (char *)g_variant_get_data(in_param2);
4644 result = _bt_unregister_osp_server_in_agent(type, uuid);
4648 BT_ERR("Unknown function!");
4649 result = BLUETOOTH_ERROR_INTERNAL;
4656 int __bt_core_request(int function_name,
4659 GDBusMethodInvocation *context,
4660 GVariant *in_param1)
4664 switch (function_name) {
4665 case BT_ENABLE_ADAPTER:
4668 _bt_set_adapter_request_state(TRUE);
4669 status = _bt_adapter_get_status();
4671 if (status == BT_ACTIVATING) {
4672 BT_DBG("Enabling in progress");
4673 result = BLUETOOTH_ERROR_IN_PROGRESS;
4674 } else if (status == BT_ACTIVATED) {
4675 BT_DBG("Already enabled");
4676 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4678 _bt_adapter_set_status(BT_ACTIVATING);
4679 result = BLUETOOTH_ERROR_NONE;
4684 case BT_DISABLE_ADAPTER:
4688 status = _bt_adapter_get_status();
4689 if (status == BT_DEACTIVATING) {
4690 BT_DBG("Disabling in progress");
4691 result = BLUETOOTH_ERROR_IN_PROGRESS;
4692 } else if (status == BT_DEACTIVATED) {
4693 BT_DBG("Already disabled");
4694 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4696 _bt_adapter_set_status(BT_DEACTIVATING);
4697 result = BLUETOOTH_ERROR_NONE;
4702 case BT_ENABLE_ADAPTER_LE:
4704 bt_le_status_t le_status;
4705 _bt_set_le_request_state(TRUE);
4706 le_status = _bt_adapter_get_le_status();
4707 if (le_status == BT_LE_ACTIVATING) {
4708 BT_DBG("Enabling in progress");
4709 result = BLUETOOTH_ERROR_IN_PROGRESS;
4710 } else if (le_status == BT_LE_ACTIVATED) {
4711 BT_DBG("Already enabled");
4712 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4714 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
4715 result = BLUETOOTH_ERROR_NONE;
4720 case BT_DISABLE_ADAPTER_LE:
4722 bt_le_status_t le_status;
4724 le_status = _bt_adapter_get_le_status();
4725 if (le_status == BT_LE_DEACTIVATING) {
4726 BT_DBG("Disabling in progress");
4727 result = BLUETOOTH_ERROR_IN_PROGRESS;
4728 } else if (le_status == BT_LE_DEACTIVATED) {
4729 BT_DBG("Already disabled");
4730 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4732 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
4733 result = BLUETOOTH_ERROR_NONE;
4739 BT_ERR("Unknown function!");
4740 result = BLUETOOTH_ERROR_INTERNAL;
4747 static int __bt_service_get_requester_app_id(const char *unique_name, char *app_id, int len)
4752 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
4753 retv_if(unique_name == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
4755 ret = __bt_service_get_sender_pid(unique_name, &pid);
4756 if (ret != BLUETOOTH_ERROR_NONE) {
4757 BT_ERR("Fail to get the sender pid");
4761 ret = aul_app_get_appid_bypid(pid, app_id, len);
4762 if (ret != AUL_R_OK) {
4763 BT_ERR("app_id not found");
4764 return BLUETOOTH_ERROR_NOT_SUPPORT;
4766 BT_DBG("Sender app_id: %s", app_id);
4768 return BLUETOOTH_ERROR_NONE;
4771 gboolean __bt_service_check_privilege(int function_name,
4773 const char *unique_name)
4776 gboolean result = TRUE;
4777 char *client_creds = NULL;
4778 char *user_creds = NULL;
4779 char *client_session = "";
4780 enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
4781 enum cynara_user_creds user_creds_method = USER_METHOD_UID;
4782 char err_msg[256] = {0, };
4784 retv_if(unique_name == NULL, FALSE);
4785 retv_if(bt_service_conn == NULL, FALSE);
4787 ret_val = cynara_creds_get_default_client_method(&client_creds_method);
4788 if (ret_val != CYNARA_API_SUCCESS) {
4789 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4790 BT_ERR("Fail to get default client method: %s", err_msg);
4794 ret_val = cynara_creds_get_default_user_method(&user_creds_method);
4795 if (ret_val != CYNARA_API_SUCCESS) {
4796 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4797 BT_ERR("Fail to get default user method: %s", err_msg);
4801 ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
4802 if (ret_val != CYNARA_API_SUCCESS) {
4803 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4804 BT_ERR("Fail to get client credential: %s", err_msg);
4808 ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
4809 if (ret_val != CYNARA_API_SUCCESS) {
4810 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4811 BT_ERR("Fail to get user credential: %s", err_msg);
4817 BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
4819 switch (function_name) {
4820 case BT_SET_LOCAL_NAME:
4821 case BT_START_DISCOVERY:
4822 case BT_START_CUSTOM_DISCOVERY:
4823 case BT_CANCEL_DISCOVERY:
4824 case BT_OOB_ADD_REMOTE_DATA:
4825 case BT_OOB_REMOVE_REMOTE_DATA:
4826 case BT_OOB_READ_LOCAL_DATA:
4827 case BT_SET_ADVERTISING:
4828 case BT_SET_CUSTOM_ADVERTISING:
4829 case BT_SET_ADVERTISING_PARAMETERS:
4830 case BT_START_LE_DISCOVERY:
4831 case BT_STOP_LE_DISCOVERY:
4832 case BT_SET_SCAN_PARAMETERS:
4833 case BT_SET_SCAN_TYPE:
4835 case BT_BOND_DEVICE:
4836 case BT_CANCEL_BONDING:
4837 case BT_UNBOND_DEVICE:
4839 case BT_SET_AUTHORIZATION:
4840 case BT_UNSET_AUTHORIZATION:
4841 case BT_SEARCH_SERVICE:
4843 case BT_RFCOMM_CLIENT_CONNECT:
4844 if (function_name == BT_RFCOMM_CLIENT_CONNECT)
4845 BT_PERMANENT_LOG("Connect socket");
4846 case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
4847 case BT_RFCOMM_SOCKET_DISCONNECT:
4848 if (function_name == BT_RFCOMM_SOCKET_DISCONNECT)
4849 BT_PERMANENT_LOG("Disconnect socket");
4850 case BT_RFCOMM_SOCKET_WRITE:
4851 case BT_RFCOMM_CREATE_SOCKET:
4852 case BT_RFCOMM_REMOVE_SOCKET:
4853 case BT_RFCOMM_SEND_RX_DETAILS:
4854 case BT_RFCOMM_SEND_TX_DETAILS:
4855 case BT_RFCOMM_UPDATE_CONNECTION_INFO:
4857 case BT_OPP_PUSH_FILES:
4858 case BT_OPP_CANCEL_PUSH:
4859 /* TODO: MAP? MAP functions, see above */
4861 case BT_OBEX_SERVER_ACCEPT_CONNECTION:
4862 case BT_OBEX_SERVER_REJECT_CONNECTION:
4863 case BT_OBEX_SERVER_ACCEPT_FILE:
4864 case BT_OBEX_SERVER_REJECT_FILE:
4865 case BT_OBEX_SERVER_SET_PATH:
4866 case BT_OBEX_SERVER_SET_ROOT:
4867 case BT_OBEX_SERVER_CANCEL_TRANSFER:
4868 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
4870 case BT_AUDIO_SELECT_ROLE:
4871 case BT_AUDIO_CONNECT:
4872 case BT_AUDIO_DISCONNECT:
4874 case BT_AG_DISCONNECT:
4876 case BT_AV_DISCONNECT:
4877 case BT_AV_SOURCE_CONNECT:
4878 case BT_AV_SOURCE_DISCONNECT:
4879 case BT_AVRCP_TARGET_CONNECT:
4880 case BT_AVRCP_TARGET_DISCONNECT:
4881 case BT_AVRCP_CONTROL_CONNECT:
4882 case BT_AVRCP_CONTROL_DISCONNECT:
4883 case BT_AVRCP_HANDLE_CONTROL:
4884 case BT_AVRCP_SET_TRACK_INFO:
4885 case BT_AVRCP_SET_PROPERTY:
4886 case BT_AVRCP_SET_PROPERTIES:
4887 case BT_AVRCP_CONTROL_SET_PROPERTY:
4889 case BT_AUDIO_SET_ABSOLUTE_VOLUME:
4890 case BT_AUDIO_GET_ABSOLUTE_VOLUME:
4891 case BT_AUDIO_IS_AVC_ACTIVATED:
4894 case BT_HF_DISCONNECT:
4896 case BT_HID_CONNECT:
4897 case BT_HID_DISCONNECT:
4899 case BT_HID_DEVICE_ACTIVATE:
4900 case BT_HID_DEVICE_DEACTIVATE:
4901 case BT_HID_DEVICE_CONNECT:
4902 case BT_HID_DEVICE_DISCONNECT:
4903 case BT_HID_DEVICE_SEND_MOUSE_EVENT:
4904 case BT_HID_DEVICE_SEND_KEY_EVENT:
4905 case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
4906 case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
4909 case BT_DISCONNECT_LE:
4911 case BT_SET_ADVERTISING_DATA:
4912 case BT_SET_SCAN_RESPONSE_DATA:
4914 case BT_HDP_CONNECT:
4915 case BT_HDP_DISCONNECT:
4916 case BT_HDP_SEND_DATA:
4917 case BT_HDP_REGISTER_SINK_APP:
4918 case BT_HDP_UNREGISTER_SINK_APP:
4921 case BT_DPM_SET_ALLOW_BT_MODE:
4922 case BT_DPM_GET_ALLOW_BT_MODE:
4923 case BT_DPM_SET_DEVICE_RESTRITION:
4924 case BT_DPM_GET_DEVICE_RESTRITION:
4925 case BT_DPM_SET_UUID_RESTRITION:
4926 case BT_DPM_GET_UUID_RESTRITION:
4927 case BT_DPM_ADD_DEVICES_BLACKLIST:
4928 case BT_DPM_ADD_DEVICES_WHITELIST:
4929 case BT_DPM_ADD_UUIDS_BLACKLIST:
4930 case BT_DPM_ADD_UUIDS_WHITELIST:
4931 case BT_DPM_CLEAR_DEVICES_BLACKLIST:
4932 case BT_DPM_CLEAR_DEVICES_WHITELIST:
4933 case BT_DPM_CLEAR_UUIDS_BLACKLIST:
4934 case BT_DPM_CLEAR_UUIDS_WHITELIST:
4935 case BT_DPM_REMOVE_DEVICE_BLACKLIST:
4936 case BT_DPM_REMOVE_DEVICE_WHITELIST:
4937 case BT_DPM_REMOVE_UUID_BLACKLIST:
4938 case BT_DPM_REMOVE_UUID_WHITELIST:
4939 case BT_DPM_GET_DEVICES_BLACKLIST:
4940 case BT_DPM_GET_DEVICES_WHITELIST:
4941 case BT_DPM_GET_UUIDS_BLACKLIST:
4942 case BT_DPM_GET_UUIDS_WHITELIST:
4943 case BT_DPM_SET_ALLOW_OUTGOING_CALL:
4944 case BT_DPM_GET_ALLOW_OUTGOING_CALL:
4945 case BT_DPM_SET_PAIRING_STATE:
4946 case BT_DPM_GET_PAIRING_STATE:
4947 case BT_DPM_SET_PROFILE_STATE:
4948 case BT_DPM_GET_PROFILE_STATE:
4949 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
4950 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
4951 case BT_DPM_SET_DISCOVERABLE_STATE:
4952 case BT_DPM_GET_DISCOVERABLE_STATE:
4953 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
4954 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
4955 case BT_DPM_SET_DATA_TRANSFER_STATE:
4956 case BT_DPM_GET_DATA_TRANSFER_STATE:
4958 case BT_NETWORK_ACTIVATE:
4959 case BT_NETWORK_DEACTIVATE:
4960 case BT_NETWORK_CONNECT:
4961 case BT_NETWORK_DISCONNECT:
4962 case BT_NETWORK_SERVER_DISCONNECT:
4964 case BT_GATT_GET_PRIMARY_SERVICES:
4965 case BT_GATT_GET_SERVICE_PROPERTIES: /* GATT Client */
4966 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: /* GATT Client */
4967 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: /* GATT Client */
4968 case BT_GATT_DISCOVER_CHARACTERISTICS:
4969 case BT_GATT_SET_PROPERTY_REQUEST:
4970 case BT_GATT_READ_CHARACTERISTIC:
4971 case BT_GATT_READ_DESCRIPTOR_VALUE: /* GATT Client */
4972 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
4973 case BT_GATT_ACQUIRE_WRITE:
4974 case BT_GATT_WRITE_DESCRIPTOR_VALUE: /* GATT Client */
4975 case BT_GATT_WATCH_CHARACTERISTIC: /* GATT Client */
4976 case BT_GATT_CLIENT_REGISTER: /* GATT Client */
4977 case BT_GATT_CLIENT_UNREGISTER: /* GATT Client */
4978 case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
4979 case BT_GATT_REGISTER_APPLICATION:
4980 case BT_GATT_REGISTER_SERVICE:
4981 case BT_GATT_SEND_RESPONSE:
4983 case BT_GATT_SERVER_REGISTER:
4984 case BT_GATT_SERVER_ADD_SERVICE:
4985 case BT_GATT_SERVER_ADD_CHARACTERISTIC:
4986 case BT_GATT_SERVER_ADD_DESCRIPTOR:
4987 case BT_GATT_SERVER_START_SERVICE:
4988 case BT_GATT_SERVER_STOP_SERVICE:
4989 case BT_GATT_SERVER_DELETE_SERVICE:
4990 case BT_GATT_SERVER_SEND_RESPONSE:
4991 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
4992 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
4993 case BT_GATT_SERVER_SEND_INDICATION:
4994 case BT_GATT_SERVER_UPDATE_VALUE:
4995 case BT_GATT_SERVER_DEREGISTER:
4997 case BT_REQ_ATT_MTU:
4998 case BT_PBAP_CONNECT:
4999 case BT_PBAP_DISCONNECT:
5000 case BT_PBAP_GET_PHONEBOOK_SIZE:
5001 case BT_PBAP_GET_PHONEBOOK:
5002 case BT_PBAP_GET_LIST:
5003 case BT_PBAP_PULL_VCARD:
5004 case BT_PBAP_PHONEBOOK_SEARCH:
5006 case BT_RFCOMM_LISTEN_AND_ACCEPT:
5008 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5009 BT_PRIVILEGE_PUBLIC);
5011 BT_INFO("Client Credentials [%s]", client_creds);
5012 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5013 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
5017 /* Need to check mediastorage privilege */
5018 if (function_name == BT_PBAP_GET_PHONEBOOK ||
5019 function_name == BT_PBAP_PULL_VCARD) {
5020 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5021 MEDIASTORAGE_PRIVILEGE);
5023 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5024 BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
5030 case BT_ENABLE_ADAPTER:
5031 case BT_DISABLE_ADAPTER:
5032 case BT_RESET_ADAPTER:
5033 case BT_RECOVER_ADAPTER:
5034 case BT_BATTERY_READ_DATA:
5035 case BT_ENABLE_ADAPTER_LE:
5036 case BT_DISABLE_ADAPTER_LE:
5037 case BT_SET_CONNECTABLE:
5038 case BT_SET_DISCOVERABLE_MODE:
5039 case BT_ADD_WHITE_LIST:
5040 case BT_REMOVE_WHITE_LIST:
5041 case BT_CLEAR_WHITE_LIST:
5042 case BT_SET_MANUFACTURER_DATA:
5044 case BT_CANCEL_SEARCH_SERVICE:
5045 case BT_ENABLE_RSSI:
5046 case BT_DISCONNECT_DEVICE:
5048 case BT_RFCOMM_ACCEPT_CONNECTION:
5049 case BT_RFCOMM_REJECT_CONNECTION:
5050 case BT_RFCOMM_LISTEN:
5052 case BT_HID_ENABLE_BARCODE_FEATURE:
5054 case BT_AVRCP_CONTROL_GET_PROPERTY:
5055 case BT_AVRCP_GET_TRACK_INFO:
5056 case BT_AVRCP_TRANSPORT_SET_PROPERTY:
5057 case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
5059 case BT_SET_CONTENT_PROTECT:
5060 case BT_BOND_DEVICE_BY_TYPE:
5061 case BT_SET_LE_PRIVACY:
5062 case BT_SET_LE_STATIC_RANDOM_ADDRESS:
5063 case BT_LE_CONN_UPDATE:
5064 case BT_UPDATE_LE_CONNECTION_MODE:
5065 case BT_GET_DEVICE_IDA:
5066 case BT_LE_READ_MAXIMUM_DATA_LENGTH:
5067 case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
5068 case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
5069 case BT_LE_SET_DATA_LENGTH:
5070 case BT_LE_OOB_READ_LOCAL_DATA:
5071 case BT_LE_OOB_ADD_REMOTE_DATA:
5073 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS:
5074 case BT_ENABLE_GATT_DATA_BATCHING:
5075 case BT_DISABLE_GATT_DATA_BATCHING:
5077 case BT_LE_IPSP_INIT:
5078 case BT_LE_IPSP_DEINIT:
5079 case BT_LE_IPSP_CONNECT:
5080 case BT_LE_IPSP_DISCONNECT:
5081 case BT_PXP_MONITOR_SET_PROPERTY:
5082 case BT_PXP_MONITOR_GET_PROPERTY:
5083 case BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES:
5084 case BT_PXP_REPORTER_REGISTER:
5085 case BT_PXP_REPORTER_UNREGISTER:
5086 case BT_PXP_REPORTER_GET_PROPERTY:
5089 case BT_TDS_PROVIDER_REGISTER:
5090 case BT_TDS_PROVIDER_UNREGISTER:
5091 case BT_TDS_PROVIDER_SET_MANUF_DATA:
5092 case BT_TDS_PROVIDER_CREATE:
5093 case BT_TDS_PROVIDER_DESTROY:
5094 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA:
5095 case BT_TDS_SEND_ACTIVATION_RESPONSE:
5096 case BT_TDS_READ_TRANSPORT_DATA:
5097 case BT_TDS_ENABLE_CONTROL_POINT:
5098 case BT_TDS_ACTIVATE_CONTROL_POINT:
5101 case BT_OTP_SERVER_INIT:
5102 case BT_OTP_SERVER_DEINIT:
5103 case BT_OTP_READ_VALUE:
5104 case BT_OTP_ENABLE_NOTIFICATION:
5105 case BT_OTP_WRITE_VALUE:
5106 case BT_LE_OTC_CONNECT:
5107 case BT_LE_OTC_DISCONNECT:
5109 case BT_MAP_CREATE_SESSION:
5110 case BT_MAP_DESTROY_SESSION:
5111 case BT_MAP_SET_FOLDER:
5112 case BT_MAP_LIST_FOLDERS:
5113 case BT_MAP_LIST_FILTER_FIELDS:
5114 case BT_MAP_LIST_MESSAGES:
5115 case BT_MAP_UPDATE_INBOX:
5116 case BT_MAP_PUSH_MESSAGE:
5117 case BT_MAP_GET_MESSAGE:
5120 case BT_MESH_DEINIT:
5121 case BT_MESH_NETWORK_CREATE:
5122 case BT_MESH_NETWORK_DESTROY:
5123 case BT_MESH_NETWORK_LOAD:
5124 case BT_MESH_NETWORK_SCAN:
5125 case BT_MESH_NETWORK_CANCEL_SCAN:
5126 case BT_MESH_NETWORK_SET_CAPABILITIES:
5127 case BT_MESH_NETWORK_PROVISION_DEVICE:
5128 case BT_MESH_AUTHENTICATION_REPLY:
5129 case BT_MESH_NETWORK_SET_NAME:
5130 case BT_MESH_NETWORK_ADD_NETKEY:
5131 case BT_MESH_NETWORK_DELETE_NETKEY:
5132 case BT_MESH_NETWORK_UPDATE_NETKEY:
5133 case BT_MESH_NETWORK_ADD_APPKEY:
5134 case BT_MESH_NETWORK_DELETE_APPKEY:
5135 case BT_MESH_NETWORK_UPDATE_APPKEY:
5136 case BT_MESH_NETWORK_GET_NETKEYS:
5137 case BT_MESH_NETWORK_GET_APPKEYS:
5138 case BT_MESH_NETWORK_GET_NODES:
5139 case BT_MESH_ELEMENT_GET_MODELS:
5140 case BT_MESH_NODE_BROWSE:
5141 case BT_MESH_NODE_GET_VENDOR_FEATURES:
5142 case BT_MESH_NODE_CONFIGURE_KEY:
5143 case BT_MESH_NODE_TTL_EXECUTE:
5144 case BT_MESH_NODE_GET_NETKEYS:
5145 case BT_MESH_NODE_GET_APPKEYS:
5146 case BT_MESH_NODE_RESET:
5147 case BT_MESH_MODEL_CONFIGURE_APPKEY:
5148 case BT_MESH_MODEL_GET_APPKEY_LIST:
5149 case BT_MESH_MODEL_EXECUTE_MSG:
5150 case BT_MESH_NETWORK_CREATE_GROUP:
5151 case BT_MESH_NETWORK_REMOVE_GROUP:
5152 case BT_MESH_MODEL_CONFIG_GROUP_SUB:
5153 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
5154 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST:
5155 case BT_MESH_MODEL_SET_PUBLICATION:
5156 case BT_MESH_MODEL_GET_PUBLICATION:
5157 case BT_MESH_NETWORK_GET_GROUPS:
5159 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5160 BT_PRIVILEGE_PLATFORM);
5162 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5163 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
5168 case BT_CHECK_ADAPTER:
5171 case BT_GET_LOCAL_NAME:
5172 case BT_GET_LOCAL_ADDRESS:
5173 case BT_GET_LOCAL_VERSION:
5174 case BT_IS_SERVICE_USED:
5175 case BT_GET_DISCOVERABLE_MODE:
5176 case BT_GET_DISCOVERABLE_TIME:
5177 case BT_IS_DISCOVERYING:
5178 case BT_IS_LE_DISCOVERYING:
5179 case BT_IS_CONNECTABLE:
5180 case BT_GET_CONNECTABLE:
5181 case BT_GET_BONDED_DEVICES:
5182 case BT_GET_PROFILE_CONNECTED_DEVICES:
5183 case BT_GET_BONDED_DEVICE:
5184 case BT_PASSKEY_REPLY:
5185 case BT_PASSKEY_CONFIRMATION_REPLY:
5186 case BT_GET_IS_ALIAS_SET:
5187 case BT_IS_DEVICE_CONNECTED:
5188 case BT_GET_CONNECTED_LINK_TYPE:
5189 case BT_SET_PROFILE_TRUSTED:
5190 case BT_GET_PROFILE_TRUSTED:
5191 case BT_GET_SPEAKER_GAIN:
5192 case BT_SET_SPEAKER_GAIN:
5193 case BT_RFCOMM_CLIENT_IS_CONNECTED:
5194 case BT_RFCOMM_IS_UUID_AVAILABLE:
5195 case BT_GET_ADVERTISING_DATA:
5196 case BT_GET_SCAN_RESPONSE_DATA:
5197 case BT_IS_ADVERTISING:
5198 case BT_IS_LE_2M_PHY_SUPPORTED:
5199 case BT_IS_LE_CODED_PHY_SUPPORTED:
5200 case BT_REGISTER_SCAN_FILTER:
5201 case BT_IS_SCAN_FILTER_SUPPORTED:
5202 case BT_GET_ATT_MTU:
5204 case BT_OBEX_SERVER_ALLOCATE:
5205 case BT_OBEX_SERVER_DEALLOCATE:
5206 case BT_OBEX_SERVER_IS_ACTIVATED:
5207 case BT_OPP_GET_TRANSFER_PROGRESS:
5208 /* Non-privilege control */
5211 BT_ERR("Unknown function!");
5216 if (function_name >= BT_FUNC_MESH_BASE) {
5217 BT_INFO("MESH Function called");
5218 char app_id[256] = { 0, };
5220 if (BLUETOOTH_ERROR_NONE == __bt_service_get_requester_app_id(unique_name,
5221 app_id, sizeof(app_id))) {
5222 requester_unique_creds = g_strdup(app_id);
5224 BT_DBG("Requester app_id not found, use client creds");
5225 requester_unique_creds = g_strdup(client_creds);
5227 BT_DBG("Requester unique_creds: %s", requester_unique_creds);
5229 BT_INFO("Non MESH Function called client creds [%s]", client_creds);
5241 GDBusNodeInfo *__bt_service_create_method_node_info
5242 (const gchar *introspection_data)
5245 GDBusNodeInfo *node_info = NULL;
5247 if (introspection_data == NULL) {
5248 BT_ERR("Introspection XML not present");
5252 node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
5255 BT_ERR("Unable to create node: %s", err->message);
5256 g_clear_error(&err);
5261 int __bt_service_register_object(GDBusConnection *conn,
5262 GDBusNodeInfo *node_info, gboolean reg)
5264 static guint service_id = 0;
5265 GError *error = NULL;
5268 if (node_info == NULL)
5271 service_id = g_dbus_connection_register_object(conn,
5273 node_info->interfaces[0],
5275 NULL, NULL, &error);
5276 if (service_id == 0)
5279 if (service_id > 0) {
5280 g_dbus_connection_unregister_object(conn,
5289 static void __name_owner_changed(GDBusConnection *connection,
5290 const gchar *sender_name,
5291 const gchar *object_path,
5292 const gchar *interface_name,
5293 const gchar *signal_name,
5294 GVariant *parameters,
5297 const char *name = NULL;
5298 const char *old_owner = NULL;
5299 const char *new_owner = NULL;
5301 g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
5302 if (*new_owner != '\0')
5305 _bt_check_hdp_app_termination(name);
5307 /* Advertising App Termination */
5308 _bt_check_adv_app_termination(name);
5310 /* Check if le_scanning app is terminated */
5311 _bt_check_le_scanner_app_termination(name);
5313 /* Check if RFCOMM app is terminated */
5314 _bt_rfcomm_check_termination(name);
5317 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
5318 const gchar *name, gpointer user_data)
5320 GDBusNodeInfo *node_info = NULL;
5322 BT_INFO("bus acquired");
5324 ret_if(connection == NULL);
5326 node_info = __bt_service_create_method_node_info(
5327 bt_service_introspection_xml);
5328 ret_if(node_info == NULL);
5330 __bt_service_register_object(connection, node_info, TRUE);
5331 g_dbus_node_info_unref(node_info);
5333 bt_service_conn = connection;
5336 static void __bt_service_name_acquired_handler(GDBusConnection *connection,
5337 const gchar *name, gpointer user_data)
5339 BT_INFO("name acquired");
5340 name_acquired = TRUE;
5343 static void __bt_service_name_lost_handler(GDBusConnection *connection,
5344 const gchar *name, gpointer user_data)
5346 BT_INFO("name lost");
5347 name_acquired = FALSE;
5350 gboolean _is_name_acquired(void)
5352 return name_acquired;
5355 void _bt_service_unref_connection(void)
5359 if (bt_service_conn) {
5360 g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
5361 g_object_unref(bt_service_conn);
5362 bt_service_conn = NULL;
5368 int _bt_service_register(void)
5370 GDBusConnection *conn;
5373 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5374 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5375 bt_service_conn = conn;
5377 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5379 G_BUS_NAME_OWNER_FLAGS_NONE,
5380 __bt_service_bus_acquired_handler,
5381 __bt_service_name_acquired_handler,
5382 __bt_service_name_lost_handler,
5384 BT_DBG("owner_id is [%d]", owner_id);
5388 /* Subscribe for name owner changed signal */
5389 owner_sig_id = g_dbus_connection_signal_subscribe(conn,
5390 BT_FREEDESKTOP_SERVICE, BT_FREEDESKTOP_INTERFACE,
5391 BT_NAME_OWNER_CHANGED, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
5392 __name_owner_changed, NULL, NULL);
5393 BT_INFO("owner_sig_id: %d", owner_sig_id);
5395 return BLUETOOTH_ERROR_NONE;
5398 if (bt_service_conn) {
5399 g_object_unref(bt_service_conn);
5400 bt_service_conn = NULL;
5403 return BLUETOOTH_ERROR_INTERNAL;
5406 void _bt_service_unregister(void)
5408 if (bt_service_conn) {
5409 sd_notify(0, "STOPPING=1");
5411 if (owner_sig_id > 0) {
5412 g_dbus_connection_signal_unsubscribe(
5413 bt_service_conn, owner_sig_id);
5418 g_bus_unown_name(owner_id);
5422 __bt_service_register_object(bt_service_conn, NULL, FALSE);
5426 int _bt_service_cynara_init(void)
5429 char err_msg[256] = {0, };
5431 retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
5433 result = cynara_initialize(&p_cynara, conf);
5435 if (result != CYNARA_API_SUCCESS) {
5436 cynara_strerror(result, err_msg, sizeof(err_msg));
5437 BT_ERR("Fail to initialize cynara: [%s]", err_msg);
5438 return BLUETOOTH_ERROR_INTERNAL;
5441 return BLUETOOTH_ERROR_NONE;
5444 void _bt_service_cynara_deinit(void)
5447 char err_msg[256] = {0, };
5449 ret_if(p_cynara == NULL);
5451 result = cynara_finish(p_cynara);
5453 if (result != CYNARA_API_SUCCESS) {
5454 cynara_strerror(result, err_msg, sizeof(err_msg));
5455 BT_ERR("Fail to finish cynara: [%s]", err_msg);
5463 void _bt_service_method_return(GDBusMethodInvocation *invocation,
5464 GArray *out_param, int result)
5468 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5469 out_param->data, out_param->len, TRUE, NULL, NULL);
5471 g_dbus_method_invocation_return_value(invocation,
5472 g_variant_new("(iv)", result, out_var));
5475 void _bt_service_method_return_with_unix_fd_list(GDBusMethodInvocation *invocation,
5476 GArray *out_param, int result, GUnixFDList *fd_list)
5480 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5481 out_param->data, out_param->len, TRUE, NULL, NULL);
5483 g_dbus_method_invocation_return_value_with_unix_fd_list(invocation,
5484 g_variant_new("(iv)", result, out_var), fd_list);