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.
22 #include "bluetooth-api.h"
23 #include "bluetooth-hid-api.h"
24 #include "bluetooth-audio-api.h"
25 #include "bt-internal-types.h"
26 #include "bluetooth-ipsp-api.h"
28 #include "bt-common.h"
29 #include "bt-request-sender.h"
30 #include "bt-event-handler.h"
31 #include "bluetooth-media-control.h"
33 static GSList *sending_requests;
35 static GDBusProxy *service_gproxy;
37 static GDBusProxy *__bt_gdbus_init_service_proxy(void)
39 GDBusConnection *service_gconn;
43 service_gconn = _bt_gdbus_get_system_gconn();
48 proxy = g_dbus_proxy_new_sync(service_gconn,
49 G_DBUS_PROXY_FLAGS_NONE, NULL,
56 BT_ERR("Unable to create proxy: %s", err->message);
63 service_gproxy = proxy;
68 static GDBusProxy *__bt_gdbus_get_service_proxy(void)
70 return (service_gproxy) ? service_gproxy : __bt_gdbus_init_service_proxy();
73 void _bt_gdbus_deinit_proxys(void)
76 g_object_unref(service_gproxy);
77 service_gproxy = NULL;
81 static void __bt_get_event_info(int service_function, GArray *output,
82 int *event, int *event_type, void **param_data)
84 ret_if(event == NULL);
86 BT_DBG("service_function : %s (0x%x)",
87 _bt_convert_service_function_to_string(service_function),
89 switch (service_function) {
91 case BT_BOND_DEVICE_BY_TYPE:
92 *event_type = BT_ADAPTER_EVENT;
93 *event = BLUETOOTH_EVENT_BONDING_FINISHED;
94 ret_if(output == NULL);
95 *param_data = &g_array_index(output,
96 bluetooth_device_info_t, 0);
98 case BT_UNBOND_DEVICE:
99 *event_type = BT_ADAPTER_EVENT;
100 *event = BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED;
101 ret_if(output == NULL);
102 *param_data = &g_array_index(output,
103 bluetooth_device_address_t, 0);
105 case BT_SEARCH_SERVICE:
106 *event_type = BT_ADAPTER_EVENT;
107 *event = BLUETOOTH_EVENT_SERVICE_SEARCHED;
108 ret_if(output == NULL);
109 *param_data = &g_array_index(output,
113 *event_type = BT_HID_EVENT;
114 *event = BLUETOOTH_HID_CONNECTED;
115 ret_if(output == NULL);
116 *param_data = &g_array_index(output,
117 bluetooth_device_address_t, 0);
119 case BT_HID_DISCONNECT:
120 *event_type = BT_HID_EVENT;
121 *event = BLUETOOTH_HID_DISCONNECTED;
122 ret_if(output == NULL);
123 *param_data = &g_array_index(output,
124 bluetooth_device_address_t, 0);
126 case BT_AUDIO_CONNECT:
128 *event_type = BT_HEADSET_EVENT;
129 *event = BLUETOOTH_EVENT_AG_CONNECTED;
130 ret_if(output == NULL);
131 *param_data = &g_array_index(output, char, 0);
133 case BT_AUDIO_DISCONNECT:
134 case BT_AG_DISCONNECT:
135 *event_type = BT_HEADSET_EVENT;
136 *event = BLUETOOTH_EVENT_AG_DISCONNECTED;
137 ret_if(output == NULL);
138 *param_data = &g_array_index(output, char, 0);
141 *event_type = BT_HEADSET_EVENT;
142 *event = BLUETOOTH_EVENT_AV_CONNECTED;
143 ret_if(output == NULL);
144 *param_data = &g_array_index(output, char, 0);
146 case BT_AV_DISCONNECT:
147 *event_type = BT_HEADSET_EVENT;
148 *event = BLUETOOTH_EVENT_AV_DISCONNECTED;
149 ret_if(output == NULL);
150 *param_data = &g_array_index(output, char, 0);
152 case BT_AV_SOURCE_CONNECT:
153 *event_type = BT_A2DP_SOURCE_EVENT;
154 *event = BLUETOOTH_EVENT_AV_SOURCE_CONNECTED;
155 ret_if(output == NULL);
156 *param_data = &g_array_index(output, char, 0);
158 case BT_AV_SOURCE_DISCONNECT:
159 *event_type = BT_A2DP_SOURCE_EVENT;
160 *event = BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED;
161 ret_if(output == NULL);
162 *param_data = &g_array_index(output, char, 0);
165 *event_type = BT_HF_AGENT_EVENT;
166 *event = BLUETOOTH_EVENT_HF_CONNECTED;
167 ret_if(output == NULL);
168 *param_data = &g_array_index(output, char, 0);
170 case BT_HF_DISCONNECT:
171 *event_type = BT_HF_AGENT_EVENT;
172 *event = BLUETOOTH_EVENT_HF_DISCONNECTED;
173 ret_if(output == NULL);
174 *param_data = &g_array_index(output, char, 0);
176 case BT_NETWORK_CONNECT:
177 *event_type = BT_ADAPTER_EVENT;
178 *event = BLUETOOTH_EVENT_NETWORK_CONNECTED;
179 ret_if(output == NULL);
180 *param_data = &g_array_index(output,
181 bluetooth_device_address_t, 0);
183 case BT_NETWORK_DISCONNECT:
184 *event_type = BT_ADAPTER_EVENT;
185 *event = BLUETOOTH_EVENT_NETWORK_DISCONNECTED;
186 ret_if(output == NULL);
187 *param_data = &g_array_index(output,
188 bluetooth_device_address_t, 0);
190 case BT_RFCOMM_CLIENT_CONNECT:
191 *event_type = BT_RFCOMM_CLIENT_EVENT;
192 *event = BLUETOOTH_EVENT_RFCOMM_CONNECTED;
193 ret_if(output == NULL);
194 *param_data = &g_array_index(output,
195 bluetooth_rfcomm_connection_t, 0);
197 case BT_AVRCP_TARGET_CONNECT:
198 *event_type = BT_AVRCP_EVENT;
199 *event = BLUETOOTH_EVENT_AVRCP_CONNECTED;
200 ret_if(output == NULL);
201 *param_data = &g_array_index(output, char, 0);
203 case BT_AVRCP_TARGET_DISCONNECT:
204 *event_type = BT_AVRCP_EVENT;
205 *event = BLUETOOTH_EVENT_AVRCP_DISCONNECTED;
206 ret_if(output == NULL);
207 *param_data = &g_array_index(output, char, 0);
209 case BT_AVRCP_CONTROL_CONNECT:
210 *event_type = BT_AVRCP_CONTROL_EVENT;
211 *event = BLUETOOTH_EVENT_AVRCP_CONTROL_CONNECTED;
212 ret_if(output == NULL);
213 *param_data = &g_array_index(output, char, 0);
215 case BT_AVRCP_CONTROL_DISCONNECT:
216 *event_type = BT_AVRCP_CONTROL_EVENT;
217 *event = BLUETOOTH_EVENT_AVRCP_CONTROL_DISCONNECTED;
218 ret_if(output == NULL);
219 *param_data = &g_array_index(output, char, 0);
222 *event_type = BT_DEVICE_EVENT;
223 *event = BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED;
224 ret_if(output == NULL);
225 *param_data = &g_array_index(output,
226 bluetooth_device_address_t, 0);
229 *event_type = BT_DEVICE_EVENT;
230 *event = BLUETOOTH_EVENT_GATT_CONNECTED;
231 ret_if(output == NULL);
232 *param_data = &g_array_index(output,
233 bluetooth_device_address_t, 0);
235 case BT_DISCONNECT_LE:
236 *event_type = BT_DEVICE_EVENT;
237 *event = BLUETOOTH_EVENT_GATT_DISCONNECTED;
238 ret_if(output == NULL);
239 *param_data = &g_array_index(output,
240 bluetooth_device_address_t, 0);
242 case BT_TDS_READ_TRANSPORT_DATA:
243 *event_type = BT_TDS_EVENT;
244 *event = BLUETOOTH_EVENT_TDS_TRANSPORT_DATA_RECEIVED;
245 ret_if(output == NULL);
246 *param_data = &g_array_index(output,
247 bluetooth_device_address_t, 0);
249 case BT_TDS_ENABLE_CONTROL_POINT:
250 *event_type = BT_TDS_EVENT;
251 *event = BLUETOOTH_EVENT_TDS_CONTROL_POINT_ENABLED;
252 ret_if(output == NULL);
253 *param_data = &g_array_index(output,
254 bluetooth_device_address_t, 0);
256 case BT_TDS_ACTIVATE_CONTROL_POINT:
257 *event_type = BT_TDS_EVENT;
258 *event = BLUETOOTH_EVENT_TDS_ACTIVATION_RESULT;
259 ret_if(output == NULL);
260 *param_data = &g_array_index(output,
261 bluetooth_device_address_t, 0);
264 *event_type = BT_HDP_EVENT;
265 *event = BLUETOOTH_EVENT_HDP_CONNECTED;
266 ret_if(output == NULL);
267 *param_data = &g_array_index(output,
268 bt_hdp_connected_t, 0);
270 case BT_HDP_DISCONNECT:
271 *event_type = BT_HDP_EVENT;
272 *event = BLUETOOTH_EVENT_HDP_DISCONNECTED;
273 ret_if(output == NULL);
274 *param_data = &g_array_index(output,
275 bt_hdp_disconnected_t, 0);
278 BT_ERR("Unknown function");
284 out param1: API result
285 out param2: return paramter
288 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
293 size = g_variant_get_size(var);
295 data = (char *)g_variant_get_data(var);
297 param = g_array_append_vals(param, data, size);
302 static void __send_request_cb(GDBusProxy *proxy,
306 bluetooth_event_param_t bt_event;
307 bt_req_info_t *cb_data = user_data;
308 int result = BLUETOOTH_ERROR_NONE;
309 int event_type = BT_ADAPTER_EVENT;
311 GError *error = NULL;
315 GArray *out_param1 = NULL;
316 // GArray *out_param2 = NULL;
319 memset(&bt_event, 0x00, sizeof(bluetooth_event_param_t));
321 value = g_dbus_proxy_call_finish(proxy, res, &error);
324 /* dBUS gives error cause */
325 BT_ERR("D-Bus API failure: message[%s]",
327 g_clear_error(&error);
329 result = BLUETOOTH_ERROR_TIMEOUT;
331 ret_if(cb_data == NULL);
333 __bt_get_event_info(cb_data->service_function, NULL,
334 &bt_event.event, &event_type,
335 &bt_event.param_data);
337 g_variant_get(value, "(iv)", &result, ¶m1);
338 g_variant_unref(value);
341 out_param1 = g_array_new(TRUE, TRUE, sizeof(gchar));
342 __bt_fill_garray_from_variant(param1, out_param1);
343 g_variant_unref(param1);
347 // out_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
348 // __bt_fill_garray_from_variant(param2, out_param2);
349 // result = g_array_index(out_param2, int, 0);
350 // g_variant_unref(param2);
351 // g_array_free(out_param2, TRUE);
353 // result = BLUETOOTH_ERROR_INTERNAL;
356 ret_if(cb_data == NULL);
358 __bt_get_event_info(cb_data->service_function, out_param1,
359 &bt_event.event, &event_type,
360 &bt_event.param_data);
362 BT_DBG("service_function [%d]", cb_data->service_function);
363 if (result == BLUETOOTH_ERROR_NONE && out_param1) {
364 if (cb_data->service_function == BT_OPP_PUSH_FILES) {
365 request_id = g_array_index(out_param1, int, 0);
366 BT_DBG("request_id : %d", request_id);
367 _bt_add_push_request_id(request_id);
368 } else if (cb_data->service_function == BT_MAP_LIST_FOLDERS) {
369 request_id = g_array_index(out_param1, int, 0);
370 BT_DBG("request_id : %d", request_id);
371 _bt_add_push_request_id(request_id);
372 } else if (cb_data->service_function == BT_MAP_LIST_FILTER_FIELDS) {
373 request_id = g_array_index(out_param1, int, 0);
374 BT_DBG("request_id : %d", request_id);
375 _bt_add_push_request_id(request_id);
376 } else if (cb_data->service_function == BT_MAP_LIST_MESSAGES) {
377 request_id = g_array_index(out_param1, int, 0);
378 BT_DBG("request_id : %d", request_id);
379 _bt_add_push_request_id(request_id);
380 } else if (cb_data->service_function == BT_MAP_GET_MESSAGE) {
381 request_id = g_array_index(out_param1, int, 0);
382 BT_DBG("request_id : %d", request_id);
383 _bt_add_push_request_id(request_id);
384 } else if (cb_data->service_function == BT_MAP_PUSH_MESSAGE) {
385 request_id = g_array_index(out_param1, int, 0);
386 BT_DBG("request_id : %d", request_id);
387 _bt_add_push_request_id(request_id);
394 if (cb_data->cb == NULL)
397 /* Only if fail case, call the callback function*/
398 bt_event.result = result;
399 BT_INFO("event_type[%d], result= %s [0x%x]", event_type,
400 _bt_convert_error_to_string(result), result);
402 if (event_type == BT_ADAPTER_EVENT || event_type == BT_RFCOMM_CLIENT_EVENT) {
403 ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
406 } else if (event_type == BT_HID_EVENT) {
407 ((hid_cb_func_ptr)cb_data->cb)(bt_event.event,
408 (hid_event_param_t *)&bt_event,
410 } else if (event_type == BT_HEADSET_EVENT) {
411 ((bt_audio_func_ptr)cb_data->cb)(bt_event.event,
412 (bt_audio_event_param_t *)&bt_event,
414 } else if (event_type == BT_HF_AGENT_EVENT) {
415 ((bt_audio_func_ptr)cb_data->cb)(bt_event.event,
416 (bt_audio_event_param_t *)&bt_event,
418 } else if (event_type == BT_AVRCP_CONTROL_EVENT) {
419 ((media_cb_func_ptr)cb_data->cb)(bt_event.event,
420 (media_event_param_t *)&bt_event,
422 } else if (event_type == BT_A2DP_SOURCE_EVENT) {
423 ((bt_audio_func_ptr)cb_data->cb)(bt_event.event,
424 (bt_audio_event_param_t *)&bt_event,
426 } else if (event_type == BT_DEVICE_EVENT) {
427 ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
430 } else if (event_type == BT_TDS_EVENT) {
431 ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
434 } else if (event_type == BT_HDP_EVENT) {
435 ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
436 &bt_event, cb_data->user_data);
437 } else if (event_type == BT_AVRCP_EVENT) {
438 ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
439 &bt_event, cb_data->user_data);
441 BT_INFO("Not handled event type : %d", event_type);
445 g_array_free(out_param1, TRUE);
447 sending_requests = g_slist_remove(sending_requests, (void *)cb_data);
453 int _bt_sync_send_request(int service_type, int service_function,
454 GArray *in_param1, GArray *in_param2,
455 GArray *in_param3, GArray *in_param4,
458 int result = BLUETOOTH_ERROR_NONE;
459 GError *error = NULL;
460 GArray *in_param5 = NULL;
461 // GArray *out_param2 = NULL;
471 switch (service_type) {
472 case BT_BLUEZ_SERVICE:
473 case BT_OBEX_SERVICE:
474 case BT_AGENT_SERVICE:
475 case BT_CHECK_PRIVILEGE:
476 proxy = __bt_gdbus_get_service_proxy();
478 return BLUETOOTH_ERROR_INTERNAL;
480 in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
484 param1 = g_variant_new_from_data((const GVariantType *)"ay",
485 in_param1->data, in_param1->len,
487 param2 = g_variant_new_from_data((const GVariantType *)"ay",
488 in_param2->data, in_param2->len,
490 param3 = g_variant_new_from_data((const GVariantType *)"ay",
491 in_param3->data, in_param3->len,
493 param4 = g_variant_new_from_data((const GVariantType *)"ay",
494 in_param4->data, in_param4->len,
496 param5 = g_variant_new_from_data((const GVariantType *)"ay",
497 in_param5->data, in_param5->len,
500 ret = g_dbus_proxy_call_sync(proxy, "service_request",
501 g_variant_new("(iii@ay@ay@ay@ay@ay)",
502 service_type, service_function,
506 G_DBUS_CALL_FLAGS_NONE, -1,
509 g_array_free(in_param5, TRUE);
512 /* dBUS-RPC is failed */
513 BT_ERR("dBUS-RPC is failed");
516 /* dBUS gives error cause */
517 BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
518 error->code, error->message);
520 g_clear_error(&error);
522 /* dBUS does not give error cause dBUS-RPC is failed */
523 BT_ERR("error returned was NULL");
526 return BLUETOOTH_ERROR_INTERNAL;
532 g_variant_get(ret, "(iv)", &result, ¶m1);
535 *out_param1 = g_array_new(TRUE, TRUE, sizeof(gchar));
536 __bt_fill_garray_from_variant(param1, *out_param1);
537 g_variant_unref(param1);
541 // out_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
542 // __bt_fill_garray_from_variant(param2, out_param2);
543 // result = g_array_index(out_param2, int, 0);
544 // g_variant_unref(param2);
545 // g_array_free(out_param2, TRUE);
547 // result = BLUETOOTH_ERROR_INTERNAL;
550 g_variant_unref(ret);
553 BT_ERR("Unknown service type");
554 return BLUETOOTH_ERROR_INTERNAL;
560 int _bt_async_send_request(int service_type, int service_function,
561 GArray *in_param1, GArray *in_param2,
562 GArray *in_param3, GArray *in_param4,
563 void *callback, void *user_data)
565 GArray* in_param5 = NULL;
566 bt_req_info_t *cb_data;
576 BT_DBG("service_function : %s (0x%x)",
577 _bt_convert_service_function_to_string(service_function),
580 cb_data = g_new0(bt_req_info_t, 1);
582 cb_data->service_function = service_function;
583 cb_data->cb = callback;
584 cb_data->user_data = user_data;
586 switch (service_type) {
587 case BT_BLUEZ_SERVICE:
588 case BT_OBEX_SERVICE:
589 proxy = __bt_gdbus_get_service_proxy();
592 return BLUETOOTH_ERROR_INTERNAL;
595 /* Do not timeout the request in certain cases. Sometime the
596 * request may take undeterministic time to reponse.
597 * (for ex: pairing retry) */
598 if (service_function == BT_BOND_DEVICE ||
599 service_function == BT_BOND_DEVICE_BY_TYPE)
602 timeout = BT_DBUS_TIMEOUT_MAX;
604 in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
606 param1 = g_variant_new_from_data((const GVariantType *)"ay",
607 in_param1->data, in_param1->len,
609 param2 = g_variant_new_from_data((const GVariantType *)"ay",
610 in_param2->data, in_param2->len,
612 param3 = g_variant_new_from_data((const GVariantType *)"ay",
613 in_param3->data, in_param3->len,
615 param4 = g_variant_new_from_data((const GVariantType *)"ay",
616 in_param4->data, in_param4->len,
618 param5 = g_variant_new_from_data((const GVariantType *)"ay",
619 in_param5->data, in_param5->len,
622 g_dbus_proxy_call(proxy, "service_request",
623 g_variant_new("(iii@ay@ay@ay@ay@ay)",
624 service_type, service_function,
625 BT_ASYNC_REQ, param1, param2,
626 param3, param4, param5),
627 G_DBUS_CALL_FLAGS_NONE,
629 (GAsyncReadyCallback)__send_request_cb,
631 sending_requests = g_slist_append(sending_requests, cb_data);
633 g_array_free(in_param5, TRUE);
640 return BLUETOOTH_ERROR_NONE;
643 int _bt_async_send_request_with_unix_fd_list(int service_type, int service_function,
644 GArray *in_param1, GArray *in_param2,
645 GArray *in_param3, GArray *in_param4,
646 void *callback, void *user_data,
647 GUnixFDList *fd_list, GAsyncReadyCallback __async_req_cb)
649 GArray* in_param5 = NULL;
650 bt_req_info_t *cb_data;
660 BT_DBG("service_function : %d", service_function);
662 cb_data = g_new0(bt_req_info_t, 1);
663 cb_data->service_function = service_function;
664 cb_data->cb = callback;
665 cb_data->user_data = user_data;
667 switch (service_type) {
668 case BT_BLUEZ_SERVICE:
669 case BT_OBEX_SERVICE:
670 proxy = __bt_gdbus_get_service_proxy();
673 return BLUETOOTH_ERROR_INTERNAL;
676 /* Do not timeout the request in certain cases. Sometime the
677 * request may take undeterministic time to reponse.
678 * (for ex: pairing retry) */
679 if (service_function == BT_BOND_DEVICE ||
680 service_function == BT_BOND_DEVICE_BY_TYPE)
683 timeout = BT_DBUS_TIMEOUT_MAX;
685 in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
687 param1 = g_variant_new_from_data((const GVariantType *)"ay",
688 in_param1->data, in_param1->len,
690 param2 = g_variant_new_from_data((const GVariantType *)"ay",
691 in_param2->data, in_param2->len,
693 param3 = g_variant_new_from_data((const GVariantType *)"ay",
694 in_param3->data, in_param3->len,
696 param4 = g_variant_new_from_data((const GVariantType *)"ay",
697 in_param4->data, in_param4->len,
699 param5 = g_variant_new_from_data((const GVariantType *)"ay",
700 in_param5->data, in_param5->len,
703 g_dbus_proxy_call_with_unix_fd_list(proxy, "service_request",
704 g_variant_new("(iii@ay@ay@ay@ay@ay)",
705 service_type, service_function,
706 BT_ASYNC_REQ, param1, param2,
707 param3, param4, param5),
708 G_DBUS_CALL_FLAGS_NONE,
709 timeout, fd_list, NULL,
710 __async_req_cb, (gpointer)cb_data);
711 sending_requests = g_slist_append(sending_requests, cb_data);
713 g_array_free(in_param5, TRUE);
720 return BLUETOOTH_ERROR_NONE;
723 int _bt_sync_send_request_with_unix_fd_list(
724 int service_type, int service_function,
725 GArray *in_param1, GArray *in_param2,
726 GArray *in_param3, GArray *in_param4,
727 GUnixFDList *fd_list, GArray **out_param1,
728 GUnixFDList **out_fd_list)
730 int result = BLUETOOTH_ERROR_NONE;
731 GError *error = NULL;
732 GArray *in_param5 = NULL;
742 switch (service_type) {
743 case BT_BLUEZ_SERVICE:
744 case BT_OBEX_SERVICE:
745 case BT_AGENT_SERVICE:
746 case BT_CHECK_PRIVILEGE:
747 proxy = __bt_gdbus_get_service_proxy();
749 return BLUETOOTH_ERROR_INTERNAL;
751 in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
753 param1 = g_variant_new_from_data((const GVariantType *)"ay",
754 in_param1->data, in_param1->len,
756 param2 = g_variant_new_from_data((const GVariantType *)"ay",
757 in_param2->data, in_param2->len,
759 param3 = g_variant_new_from_data((const GVariantType *)"ay",
760 in_param3->data, in_param3->len,
762 param4 = g_variant_new_from_data((const GVariantType *)"ay",
763 in_param4->data, in_param4->len,
765 param5 = g_variant_new_from_data((const GVariantType *)"ay",
766 in_param5->data, in_param5->len,
769 ret = g_dbus_proxy_call_with_unix_fd_list_sync(proxy, "service_request",
770 g_variant_new("(iii@ay@ay@ay@ay@ay)",
771 service_type, service_function,
772 BT_SYNC_REQ, param1, param2,
773 param3, param4, param5),
774 G_DBUS_CALL_FLAGS_NONE, -1,
775 fd_list, out_fd_list, NULL, &error);
776 g_array_free(in_param5, TRUE);
779 /* dBUS-RPC is failed */
780 BT_ERR("dBUS-RPC is failed");
783 /* dBUS gives error cause */
784 BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
785 error->code, error->message);
787 g_clear_error(&error);
789 /* dBUS does not give error cause dBUS-RPC is failed */
790 BT_ERR("error returned was NULL");
793 return BLUETOOTH_ERROR_INTERNAL;
797 g_variant_get(ret, "(iv)", &result, ¶m1);
800 *out_param1 = g_array_new(TRUE, TRUE, sizeof(gchar));
801 __bt_fill_garray_from_variant(param1, *out_param1);
802 g_variant_unref(param1);
805 g_variant_unref(ret);
808 BT_ERR("Unknown service type");
809 return BLUETOOTH_ERROR_INTERNAL;