Merge "Disconnect all profiles if a device is restricted by DPM" into tizen_3.0
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-dpm.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *              http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #ifdef TIZEN_DPM_ENABLE
19 #include <vconf.h>
20
21 #include "bluetooth-api.h"
22 #include "bt-internal-types.h"
23 #include "bt-common.h"
24 #include "bt-request-sender.h"
25 #include "bt-event-handler.h"
26 #include "bt-event-handler.h"
27 #include "bt-dpm.h"
28
29 #ifdef TIZEN_DPM_VCONF_ENABLE
30 BT_EXPORT_API int bluetooth_dpm_is_mode_allowed(void)
31 {
32         int value;
33         /* check VCONFKEY_BT_STATUS */
34         if (vconf_get_int(VCONFKEY_BT_DPM_STATUS, &value) != 0) {
35                 BT_ERR("fail to get vconf key!");
36                 return BLUETOOTH_DPM_RESULT_FAIL;
37         }
38         if (value != VCONFKEY_BT_DPM_STATUS_RESTRICTED)
39                 return BLUETOOTH_DPM_RESULT_SUCCESS;
40         else
41                 return BLUETOOTH_DPM_RESULT_ACCESS_DENIED;
42 }
43 #endif
44
45 #if 0
46 static bt_dpm_status_e _bt_check_dpm_allow_restriction(void)
47 {
48         bt_dpm_allow_t mode;
49
50         bluetooth_dpm_get_allow_mode(&mode);
51
52         return (mode == BLUETOOTH_DPM_BT_RESTRICTED) ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED;
53 }
54 #endif
55
56 static bt_dpm_status_e _bt_check_dpm_handsfree_only(void)
57 {
58         bt_dpm_allow_t mode;
59
60         bluetooth_dpm_get_allow_mode(&mode);
61
62         return (mode == BLUETOOTH_DPM_HANDSFREE_ONLY ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
63 }
64
65 static bt_dpm_status_e _bt_check_dpm_pairing_restriction(void)
66 {
67         bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
68
69         bluetooth_dpm_get_pairing_state(&dpm_status);
70
71         return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
72 }
73
74 static bt_dpm_status_e _bt_check_dpm_desktop_connectivity_restriction(void)
75 {
76         bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
77
78         bluetooth_dpm_get_desktop_connectivity_state(&dpm_status);
79
80         return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
81 }
82
83 #if 0
84 static bt_dpm_status_e _bt_check_dpm_visible_restriction(void)
85 {
86         bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
87
88         bluetooth_dpm_get_desktop_connectivity_state(&dpm_status);
89
90         return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
91 }
92
93 static bt_dpm_status_e _bt_check_dpm_limited_discoverable_mode(void)
94 {
95         bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
96
97         bluetooth_dpm_get_limited_discoverable_state(&dpm_status);
98
99         return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
100 }
101 #endif
102
103 static bt_dpm_status_e _bt_check_dpm_blacklist_device(bluetooth_device_address_t *address)
104 {
105         int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
106         bt_dpm_device_list_t dev_list;
107         char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
108
109         _bt_convert_addr_type_to_string(device_address,
110                         (unsigned char *)address->addr);
111
112         ret = bluetooth_dpm_get_devices_from_blacklist(&dev_list);
113         if (ret == BLUETOOTH_DPM_RESULT_SUCCESS) {
114                 int i = 0;
115                 for (i = 0; i < dev_list.count; i++) {
116                         char temp_address[BT_ADDRESS_STRING_SIZE] = { 0 };
117                         _bt_convert_addr_type_to_string(temp_address,
118                         (unsigned char *)dev_list.addresses[i].addr);
119                         if (g_strcmp0(device_address, temp_address) == 0)
120                                 return BT_DPM_RESTRICTED;
121                         else
122                                 return BT_DPM_ALLOWED;
123                 }
124         } else {
125                 return BT_DPM_NO_SERVICE;
126         }
127         return BT_DPM_ALLOWED;
128 }
129
130 static bt_dpm_status_e _bt_check_dpm_blacklist_uuid(char *uuid)
131 {
132         bt_dpm_status_e bt_dpm_status = BT_DPM_ALLOWED;
133         bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
134         bt_dpm_profile_t dpm_profile = BLUETOOTH_DPM_PROFILE_NONE;
135         bt_dpm_uuids_list_t uuid_list;
136         int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
137         retv_if(!uuid, bt_dpm_status);
138
139         ret = bluetooth_dpm_get_uuids_from_blacklist(&uuid_list);
140         if (ret == BLUETOOTH_DPM_RESULT_SUCCESS) {
141                 int i = 0;
142                 for (i = 0; i < uuid_list.count; i++) {
143                         if (g_strcmp0(uuid, uuid_list.uuids[i]) == 0)
144                                 return BT_DPM_RESTRICTED;
145                         else
146                                 return BT_DPM_ALLOWED;
147                 }
148         } else {
149                 return BT_DPM_NO_SERVICE;
150         }
151
152         if (g_strcmp0(BT_OPP_UUID, uuid) == 0) {
153                 bt_dpm_status_t dpm_status = BLUETOOTH_DPM_ALLOWED;
154                 bluetooth_dpm_get_data_transfer_state(&dpm_status);
155                 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
156         }
157
158         /* ++ check MDM profile restriction ++ */
159         if (g_strcmp0(BT_A2DP_UUID, uuid) == 0)
160                 dpm_profile = BLUETOOTH_DPM_POLICY_A2DP_PROFILE_STATE;
161         else if (g_strcmp0(BT_AVRCP_TARGET_UUID, uuid) == 0)
162                 dpm_profile = BLUETOOTH_DPM_POLICY_AVRCP_PROFILE_STATE;
163         else if (g_strcmp0(BT_HFP_AUDIO_GATEWAY_UUID, uuid) == 0)
164                 dpm_profile = BLUETOOTH_DPM_POLICY_HFP_PROFILE_STATE;
165         else if (g_strcmp0(BT_HSP_AUDIO_GATEWAY_UUID, uuid) == 0)
166                 dpm_profile = BLUETOOTH_DPM_POLICY_HSP_PROFILE_STATE;
167         else if (g_strcmp0(BT_OBEX_PSE_UUID, uuid) == 0)
168                 dpm_profile = BLUETOOTH_DPM_POLICY_PBAP_PROFILE_STATE;
169
170         if (dpm_profile != BLUETOOTH_DPM_PROFILE_NONE) {
171                 ret = bluetooth_dpm_get_profile_state(dpm_profile, &dpm_status);
172                 return (dpm_status == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
173         }
174         /* -- check DPM profile restriction -- */
175
176         return bt_dpm_status;
177 }
178
179 static bt_dpm_status_e _bt_check_dpm_transfer_restriction(void)
180 {
181         bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
182         bt_dpm_status_t dpm_value = BLUETOOTH_DPM_ALLOWED;
183
184         dpm_status = _bt_check_dpm_blacklist_uuid(BT_OPP_UUID);
185
186         if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
187                 return dpm_status;
188
189         bluetooth_dpm_get_data_transfer_state(&dpm_value);
190
191         return (dpm_value == BLUETOOTH_DPM_RESTRICTED ? BT_DPM_RESTRICTED : BT_DPM_ALLOWED);
192 }
193
194 static bt_dpm_status_e _bt_check_dpm_hsp_restriction(void)
195 {
196         bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
197
198         dpm_status = _bt_check_dpm_blacklist_uuid(BT_HFP_AUDIO_GATEWAY_UUID);
199
200         if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
201                 return dpm_status;
202
203         dpm_status = _bt_check_dpm_blacklist_uuid(BT_HSP_AUDIO_GATEWAY_UUID);
204         if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
205                 return dpm_status;
206
207         return dpm_status;
208 }
209
210 static bt_dpm_status_e _bt_check_dpm_a2dp_restriction(void)
211 {
212         bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
213
214         dpm_status = _bt_check_dpm_blacklist_uuid(BT_A2DP_UUID);
215
216         if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
217                 return dpm_status;
218
219         return dpm_status;
220 }
221
222 static bt_dpm_status_e _bt_check_dpm_avrcp_restriction(void)
223 {
224         bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
225
226         dpm_status = _bt_check_dpm_blacklist_uuid(BT_AVRCP_TARGET_UUID);
227
228         if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
229                 return dpm_status;
230
231         return dpm_status;
232 }
233
234 static bt_dpm_status_e _bt_check_dpm_spp_restriction(void)
235 {
236         bt_dpm_status_e dpm_status = BT_DPM_ALLOWED;
237
238         dpm_status = _bt_check_dpm_blacklist_uuid(BT_SPP_UUID);
239
240         if (dpm_status == BT_DPM_NO_SERVICE || dpm_status == BT_DPM_RESTRICTED)
241                 return dpm_status;
242
243         return dpm_status;
244 }
245
246 int _bt_check_dpm(int service, void *param)
247 {
248         bt_dpm_status_e status = BT_DPM_ALLOWED;
249
250         BT_CHECK_ENABLED_ANY(return);
251
252         switch (service) {
253         case BT_DPM_HF_ONLY:
254                 status = _bt_check_dpm_handsfree_only();
255                 break;
256
257         case BT_DPM_PAIRING:
258                 status = _bt_check_dpm_pairing_restriction();
259                 break;
260         case BT_DPM_DESKTOP:
261                 status = _bt_check_dpm_desktop_connectivity_restriction();
262                 break;
263         case BT_DPM_ADDRESS: {
264                 status = _bt_check_dpm_blacklist_device((bluetooth_device_address_t *)param);
265                 }
266                 break;
267         case BT_DPM_UUID: {
268                 char *uuid;
269                 uuid = (char *)param;
270                 status = _bt_check_dpm_blacklist_uuid(uuid);
271                 }
272                 break;
273         case BT_DPM_OPP:
274                 status = _bt_check_dpm_transfer_restriction();
275                 break;
276         case BT_DPM_HSP:
277                 status = _bt_check_dpm_hsp_restriction();
278                 break;
279         case BT_DPM_A2DP:
280                 status = _bt_check_dpm_a2dp_restriction();
281                 break;
282         case BT_DPM_AVRCP:
283                 status = _bt_check_dpm_avrcp_restriction();
284                 break;
285         case BT_DPM_SPP:
286                 status = _bt_check_dpm_spp_restriction();
287                 break;
288
289         default:
290                 BT_ERR("Unknown service");
291                 return status;
292         }
293
294         if (status == BT_DPM_RESTRICTED)
295                 BT_INFO("Service [%d], DPM permission denied", service);
296         else if (status == BT_DPM_NO_SERVICE)
297                 BT_DBG("DPM no service [%d]", status);
298
299         return status;
300 }
301
302 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
303 {
304         int result =  BLUETOOTH_DPM_RESULT_SUCCESS;
305 #ifdef TIZEN_DPM_VCONF_ENABLE
306         int bt_status;
307 #endif
308
309 #ifdef TIZEN_DPM_VCONF_ENABLE
310         if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
311                 BT_ERR("Error in reading VCONFKEY_BT_STATUS");
312
313         if (bt_status == VCONFKEY_BT_STATUS_ON) {
314                 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
315                         BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
316                         result = BLUETOOTH_DPM_RESULT_FAIL;
317                 } else {
318                         BT_ERR("Set VCONFKEY_BT_DPM_STATUS success\n");
319                         result = BLUETOOTH_DPM_RESULT_SUCCESS;
320                 }
321
322                 BT_INIT_PARAMS();
323                 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
324
325                 g_array_append_vals(in_param1, &value, sizeof(int));
326
327                 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
328                         in_param1, in_param2, in_param3, in_param4, &out_param);
329
330                 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
331
332                 if (result == BLUETOOTH_DPM_RESULT_SUCCESS &&
333                         value == BLUETOOTH_DPM_BT_RESTRICTED) {
334                         result = bluetooth_disable_adapter();
335                 }
336         } else {
337                 if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
338                         value <= BLUETOOTH_DPM_BT_RESTRICTED) {
339                         if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
340                                 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
341                                 result = BLUETOOTH_DPM_RESULT_FAIL;
342                         } else
343                                 result = BLUETOOTH_DPM_RESULT_SUCCESS;
344                 } else
345                         result = BLUETOOTH_DPM_RESULT_INVALID_PARAM;
346         }
347 #else
348         BT_INIT_PARAMS();
349         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
350
351         g_array_append_vals(in_param1, &value, sizeof(int));
352
353         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
354                 in_param1, in_param2, in_param3, in_param4, &out_param);
355
356         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
357 #endif
358
359         return result;
360
361 }
362
363 BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
364 {
365         int result;
366
367 #ifdef TIZEN_DPM_VCONF_ENABLE
368         *value = bluetooth_dpm_is_mode_allowed();
369         return BLUETOOTH_DPM_RESULT_SUCCESS;
370 #else
371         BT_CHECK_ENABLED_ANY(return);
372
373         BT_INIT_PARAMS();
374         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
375
376         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
377                 in_param1, in_param2, in_param3, in_param4, &out_param);
378
379         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
380                 if (out_param->len > 0) {
381                         *value = g_array_index(out_param,
382                                         int, 0);
383                 } else {
384                         BT_ERR("out_param length is 0!!");
385                 }
386         }
387
388         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
389 #endif
390
391         return result;
392 }
393
394
395 BT_EXPORT_API int bluetooth_dpm_activate_device_restriction(bt_dpm_status_t value)
396 {
397         int result;
398
399         BT_CHECK_ENABLED_ANY(return);
400
401         BT_INIT_PARAMS();
402         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
403
404         g_array_append_vals(in_param1, &value, sizeof(int));
405
406         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DEVICE_RESTRITION,
407                 in_param1, in_param2, in_param3, in_param4, &out_param);
408
409         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
410
411         return result;
412 }
413
414
415 BT_EXPORT_API int bluetooth_dpm_is_device_restriction_active(bt_dpm_status_t *value)
416 {
417         int result;
418
419         BT_CHECK_ENABLED_ANY(return);
420
421         BT_INIT_PARAMS();
422         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
423
424         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICE_RESTRITION,
425                 in_param1, in_param2, in_param3, in_param4, &out_param);
426
427         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
428                 if (out_param->len > 0) {
429                         *value = g_array_index(out_param,
430                                         int, 0);
431                 } else {
432                         BT_ERR("out_param length is 0!!");
433                 }
434         }
435
436         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
437
438         return result;
439 }
440
441
442 BT_EXPORT_API int bluetooth_dpm_activate_uuid_restriction(bt_dpm_status_t value)
443 {
444         int result;
445
446         BT_CHECK_ENABLED_ANY(return);
447
448         BT_INIT_PARAMS();
449         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
450
451         g_array_append_vals(in_param1, &value, sizeof(int));
452
453         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_UUID_RESTRITION,
454                 in_param1, in_param2, in_param3, in_param4, &out_param);
455
456         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
457
458         return result;
459 }
460
461
462 BT_EXPORT_API int bluetooth_dpm_is_uuid_restriction_active(bt_dpm_status_t *value)
463 {
464         int result;
465
466         BT_CHECK_ENABLED_ANY(return);
467
468         BT_INIT_PARAMS();
469         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
470
471         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUID_RESTRITION,
472                 in_param1, in_param2, in_param3, in_param4, &out_param);
473
474         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
475                 if (out_param->len > 0) {
476                         *value = g_array_index(out_param,
477                                         int, 0);
478                 } else {
479                         BT_ERR("out_param length is 0!!");
480                 }
481         }
482
483         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
484
485         return result;
486
487 }
488
489
490 BT_EXPORT_API int bluetooth_dpm_add_devices_to_blacklist(const bluetooth_device_address_t *device_address)
491 {
492         int result;
493
494         BT_CHECK_PARAMETER(device_address, return);
495         BT_CHECK_ENABLED_ANY(return);
496
497         BT_INIT_PARAMS();
498         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
499
500         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
501
502
503         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_BLACKLIST,
504                 in_param1, in_param2, in_param3, in_param4, &out_param);
505
506         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
507
508         return result;
509 }
510
511
512 BT_EXPORT_API int bluetooth_dpm_add_devices_to_whitelist(const bluetooth_device_address_t *device_address)
513 {
514         int result;
515
516         BT_CHECK_PARAMETER(device_address, return);
517         BT_CHECK_ENABLED_ANY(return);
518
519         BT_INIT_PARAMS();
520         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
521
522         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
523
524         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_WHITELIST,
525                 in_param1, in_param2, in_param3, in_param4, &out_param);
526
527         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
528
529         return result;
530
531 }
532
533
534 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_blacklist(const char *service_uuid)
535 {
536         int result;
537         char uuid[BLUETOOTH_UUID_STRING_MAX];
538
539         BT_CHECK_PARAMETER(service_uuid, return);
540         BT_CHECK_ENABLED_ANY(return);
541
542
543         BT_INIT_PARAMS();
544         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
545
546         g_strlcpy(uuid, service_uuid, sizeof(uuid));
547         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
548
549         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_BLACKLIST,
550                 in_param1, in_param2, in_param3, in_param4, &out_param);
551
552         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
553
554         return result;
555
556 }
557
558
559 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_whitelist(const char *service_uuid)
560 {
561         int result;
562         char uuid[BLUETOOTH_UUID_STRING_MAX];
563
564         BT_CHECK_PARAMETER(service_uuid, return);
565         BT_CHECK_ENABLED_ANY(return);
566
567         BT_INIT_PARAMS();
568         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
569
570         g_strlcpy(uuid, service_uuid, sizeof(uuid));
571         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
572
573         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_WHITELIST,
574                 in_param1, in_param2, in_param3, in_param4, &out_param);
575
576         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
577
578         return result;
579 }
580
581
582 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_blacklist(void)
583 {
584         int result;
585
586         BT_CHECK_ENABLED_ANY(return);
587
588         BT_INIT_PARAMS();
589         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
590
591         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_BLACKLIST,
592                 in_param1, in_param2, in_param3, in_param4, &out_param);
593
594         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
595
596         return result;
597 }
598
599
600 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_whitelist(void)
601 {
602         int result;
603
604         BT_CHECK_ENABLED_ANY(return);
605
606         BT_INIT_PARAMS();
607         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
608
609         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_WHITELIST,
610                 in_param1, in_param2, in_param3, in_param4, &out_param);
611
612         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
613
614         return result;
615 }
616
617
618 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_blacklist(void)
619 {
620         int result;
621
622         BT_CHECK_ENABLED_ANY(return);
623
624         BT_INIT_PARAMS();
625         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
626
627         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_BLACKLIST,
628                 in_param1, in_param2, in_param3, in_param4, &out_param);
629
630         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
631
632         return result;
633 }
634
635
636 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_whitelist(void)
637 {
638         int result;
639
640         BT_CHECK_ENABLED_ANY(return);
641
642         BT_INIT_PARAMS();
643         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
644
645         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_WHITELIST,
646                 in_param1, in_param2, in_param3, in_param4, &out_param);
647
648         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
649
650         return result;
651 }
652
653
654 static void _bluetooth_extract_dpm_device_info(int count,
655                                                         bt_dpm_device_list_t *dst_info,
656                                                         bt_dpm_device_list_t *src_info)
657 {
658         int i;
659
660         for (i = 0; i < count; i++) {
661                 memset(dst_info->addresses[i].addr, 0,
662                         BLUETOOTH_ADDRESS_LENGTH);
663
664                 g_strlcpy((gchar *)dst_info->addresses[i].addr, (gchar *)src_info->addresses[i].addr,
665                         BLUETOOTH_ADDRESS_LENGTH);
666
667 //              BT_DBG("address[%d] : %s", i, dst_info->addresses[i].addr);
668         }
669 }
670
671 static void _bluetooth_extract_dpm_uuid_info(int count,
672                                                         bt_dpm_uuids_list_t *dst_info,
673                                                         bt_dpm_uuids_list_t *src_info)
674 {
675         int i;
676
677         for (i = 0; i < count; i++) {
678                 memset(dst_info->uuids[i], 0,
679                         BLUETOOTH_UUID_STRING_MAX);
680
681                 g_strlcpy(dst_info->uuids[i], src_info->uuids[i],
682                         BLUETOOTH_UUID_STRING_MAX);
683
684                 BT_DBG("uuids[%d] : %s", i, dst_info->uuids[i]);
685         }
686 }
687
688 BT_EXPORT_API int bluetooth_dpm_get_devices_from_blacklist(bt_dpm_device_list_t *device_list)
689 {
690         int result;
691         bt_dpm_device_list_t *devices = NULL;
692
693         BT_CHECK_ENABLED_ANY(return);
694
695         BT_INIT_PARAMS();
696         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
697
698         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_BLACKLIST,
699                 in_param1, in_param2, in_param3, in_param4, &out_param);
700
701         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
702                 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
703                 BT_DBG("device_list->count : %d", devices->count);
704
705                 if (devices->count == 0) {
706                         BT_ERR("device_list->count is zero !");
707                         return BLUETOOTH_DPM_RESULT_FAIL;
708                 }
709
710                 device_list->count = devices->count;
711
712                 _bluetooth_extract_dpm_device_info(devices->count,
713                                 device_list, devices);
714         } else {
715                 BT_ERR("Get Devices list Failed");
716         }
717
718         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
719
720         return result;
721 }
722
723 BT_EXPORT_API int bluetooth_dpm_get_devices_from_whitelist(bt_dpm_device_list_t *device_list)
724 {
725         int result;
726         bt_dpm_device_list_t *devices = NULL;
727
728         BT_CHECK_ENABLED_ANY(return);
729
730         BT_INIT_PARAMS();
731         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
732
733         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_WHITELIST,
734                 in_param1, in_param2, in_param3, in_param4, &out_param);
735
736         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
737                 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
738                 BT_DBG("device_list->count : %d", devices->count);
739
740                 if (devices->count == 0) {
741                         BT_ERR("device_list->count is zero !");
742                         return BLUETOOTH_DPM_RESULT_FAIL;
743                 }
744
745                 device_list->count = devices->count;
746
747                 _bluetooth_extract_dpm_device_info(devices->count,
748                                 device_list, devices);
749
750         } else {
751                 BT_ERR("Get Devices list Failed");
752         }
753         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
754
755         return result;
756 }
757
758 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_blacklist(bt_dpm_uuids_list_t *uuid_list)
759 {
760         int result;
761         bt_dpm_uuids_list_t *uuids;
762
763         BT_CHECK_ENABLED_ANY(return);
764
765         BT_INIT_PARAMS();
766         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
767
768         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_BLACKLIST,
769                 in_param1, in_param2, in_param3, in_param4, &out_param);
770
771         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
772                 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
773                 BT_DBG("uuids->count : %d", uuids->count);
774
775                 if (uuids->count == 0) {
776                         BT_ERR("uuids->count is zero !");
777                         return BLUETOOTH_DPM_RESULT_FAIL;
778                 }
779
780                 uuid_list->count = uuids->count;
781                 _bluetooth_extract_dpm_uuid_info(uuids->count,
782                                 uuid_list, uuids);
783         } else {
784                 BT_ERR("Get UUIDS list Failed");
785         }
786
787         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
788
789         return result;
790 }
791
792 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_whitelist(bt_dpm_uuids_list_t *uuid_list)
793 {
794         int result;
795         bt_dpm_uuids_list_t *uuids;
796
797         BT_CHECK_ENABLED_ANY(return);
798
799         BT_INIT_PARAMS();
800         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
801
802         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_WHITELIST,
803                 in_param1, in_param2, in_param3, in_param4, &out_param);
804
805         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
806                 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
807                 BT_DBG("uuids->count : %d", uuids->count);
808
809                 if (uuids->count == 0) {
810                         BT_ERR("uuids->count is zero !");
811                         return BLUETOOTH_DPM_RESULT_FAIL;
812                 }
813
814                 uuid_list->count = uuids->count;
815
816                 _bluetooth_extract_dpm_uuid_info(uuids->count,
817                                 uuid_list, uuids);
818         } else {
819                 BT_ERR("Get UUIDS list Failed");
820         }
821
822         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
823
824         return result;
825 }
826
827 BT_EXPORT_API int bluetooth_dpm_remove_device_from_whitelist(const bluetooth_device_address_t *device_address)
828 {
829         int result;
830
831         BT_CHECK_PARAMETER(device_address, return);
832         BT_CHECK_ENABLED_ANY(return);
833
834         BT_INIT_PARAMS();
835         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
836
837         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
838
839         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_WHITELIST,
840                 in_param1, in_param2, in_param3, in_param4, &out_param);
841
842         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
843
844         return result;
845 }
846
847 BT_EXPORT_API int bluetooth_dpm_remove_device_from_blacklist(const bluetooth_device_address_t *device_address)
848 {
849         int result;
850
851         BT_CHECK_PARAMETER(device_address, return);
852         BT_CHECK_ENABLED_ANY(return);
853
854         BT_INIT_PARAMS();
855         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
856
857         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
858
859         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_BLACKLIST,
860                 in_param1, in_param2, in_param3, in_param4, &out_param);
861
862         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
863
864         return result;
865 }
866
867 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_whitelist(const char *service_uuid)
868 {
869         int result;
870         char uuid[BLUETOOTH_UUID_STRING_MAX];
871
872         BT_CHECK_PARAMETER(service_uuid, return);
873         BT_CHECK_ENABLED_ANY(return);
874
875         BT_INIT_PARAMS();
876         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
877
878         g_strlcpy(uuid, service_uuid, sizeof(uuid));
879         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
880
881         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_WHITELIST,
882                 in_param1, in_param2, in_param3, in_param4, &out_param);
883
884         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
885
886         return result;
887 }
888
889 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_blacklist(const char *service_uuid)
890 {
891         int result;
892         char uuid[BLUETOOTH_UUID_STRING_MAX];
893
894         BT_CHECK_PARAMETER(service_uuid, return);
895         BT_CHECK_ENABLED_ANY(return);
896
897         BT_INIT_PARAMS();
898         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
899
900         g_strlcpy(uuid, service_uuid, sizeof(uuid));
901         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
902
903         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_BLACKLIST,
904                 in_param1, in_param2, in_param3, in_param4, &out_param);
905
906         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
907
908         return result;
909
910 }
911
912 BT_EXPORT_API int bluetooth_dpm_set_allow_outgoing_call(bt_dpm_status_t value)
913 {
914         int result;
915
916         BT_CHECK_ENABLED_ANY(return);
917
918         BT_INIT_PARAMS();
919         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
920
921         g_array_append_vals(in_param1, &value, sizeof(int));
922
923         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_OUTGOING_CALL,
924                 in_param1, in_param2, in_param3, in_param4, &out_param);
925
926         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
927
928         return result;
929 }
930
931 BT_EXPORT_API int bluetooth_dpm_get_allow_outgoing_call(bt_dpm_status_t *value)
932 {
933         int result;
934
935         BT_CHECK_ENABLED_ANY(return);
936
937         BT_INIT_PARAMS();
938         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
939
940         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_OUTGOING_CALL,
941                 in_param1, in_param2, in_param3, in_param4, &out_param);
942
943         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
944                 if (out_param->len > 0) {
945                         *value = g_array_index(out_param,
946                                         int, 0);
947                 } else {
948                         BT_ERR("out_param length is 0!!");
949                 }
950         }
951
952         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
953
954         return result;
955 }
956
957 BT_EXPORT_API int bluetooth_dpm_set_pairing_state(bt_dpm_status_t value)
958 {
959         int result;
960
961         BT_CHECK_ENABLED_ANY(return);
962
963         BT_INIT_PARAMS();
964         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
965
966         g_array_append_vals(in_param1, &value, sizeof(int));
967
968         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PAIRING_STATE,
969                 in_param1, in_param2, in_param3, in_param4, &out_param);
970
971         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
972
973         return result;
974 }
975
976 BT_EXPORT_API int bluetooth_dpm_get_pairing_state(bt_dpm_status_t *value)
977 {
978         int result;
979
980         BT_CHECK_ENABLED_ANY(return);
981
982         BT_INIT_PARAMS();
983         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
984
985         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
986                 in_param1, in_param2, in_param3, in_param4, &out_param);
987
988         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
989                 if (out_param->len > 0) {
990                         *value = g_array_index(out_param,
991                                         int, 0);
992                 } else {
993                         BT_ERR("out_param length is 0!!");
994                 }
995         }
996
997         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
998
999         return result;
1000 }
1001
1002 BT_EXPORT_API int bluetooth_dpm_set_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t value)
1003 {
1004         int result;
1005
1006         BT_CHECK_ENABLED_ANY(return);
1007
1008         BT_INIT_PARAMS();
1009         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1010
1011         g_array_append_vals(in_param1, &profile, sizeof(int));
1012         g_array_append_vals(in_param2, &value, sizeof(int));
1013
1014         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PROFILE_STATE,
1015                 in_param1, in_param2, in_param3, in_param4, &out_param);
1016
1017         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1018
1019         return result;
1020 }
1021
1022 BT_EXPORT_API int bluetooth_dpm_get_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t *value)
1023 {
1024         int result;
1025
1026         BT_CHECK_ENABLED_ANY(return);
1027
1028         BT_INIT_PARAMS();
1029         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1030
1031         g_array_append_vals(in_param1, &profile, sizeof(int));
1032
1033         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_PROFILE_STATE,
1034                 in_param1, in_param2, in_param3, in_param4, &out_param);
1035
1036         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1037                 if (out_param->len > 0) {
1038                         *value = g_array_index(out_param,
1039                                         int, 0);
1040                 } else {
1041                         BT_ERR("out_param length is 0!!");
1042                 }
1043         }
1044
1045         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1046
1047         return result;
1048 }
1049
1050 BT_EXPORT_API int bluetooth_dpm_set_desktop_connectivity_state(bt_dpm_status_t value)
1051 {
1052         int result;
1053
1054         BT_CHECK_ENABLED_ANY(return);
1055
1056         BT_INIT_PARAMS();
1057         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1058
1059         g_array_append_vals(in_param1, &value, sizeof(int));
1060
1061         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DESKROP_CONNECTIVITY_STATE,
1062                 in_param1, in_param2, in_param3, in_param4, &out_param);
1063
1064         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1065
1066         return result;
1067 }
1068
1069 BT_EXPORT_API int bluetooth_dpm_get_desktop_connectivity_state(bt_dpm_status_t *value)
1070 {
1071         int result;
1072
1073         BT_CHECK_ENABLED_ANY(return);
1074
1075         BT_INIT_PARAMS();
1076         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1077
1078         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DESKROP_CONNECTIVITY_STATE,
1079                 in_param1, in_param2, in_param3, in_param4, &out_param);
1080
1081         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1082                 if (out_param->len > 0) {
1083                         *value = g_array_index(out_param,
1084                                         int, 0);
1085                 } else {
1086                         BT_ERR("out_param length is 0!!");
1087                 }
1088         }
1089
1090         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1091
1092         return result;
1093 }
1094
1095 BT_EXPORT_API int bluetooth_dpm_set_discoverable_state(bt_dpm_status_t value)
1096 {
1097         int result;
1098
1099         BT_CHECK_ENABLED_ANY(return);
1100
1101         BT_INIT_PARAMS();
1102         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1103
1104         g_array_append_vals(in_param1, &value, sizeof(int));
1105
1106         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DISCOVERABLE_STATE,
1107                 in_param1, in_param2, in_param3, in_param4, &out_param);
1108
1109         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1110
1111         return result;
1112 }
1113
1114 BT_EXPORT_API int bluetooth_dpm_get_discoverable_state(bt_dpm_status_t *value)
1115 {
1116         int result;
1117
1118         BT_CHECK_ENABLED_ANY(return);
1119
1120         BT_INIT_PARAMS();
1121         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1122
1123         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DISCOVERABLE_STATE,
1124                 in_param1, in_param2, in_param3, in_param4, &out_param);
1125
1126         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1127                 if (out_param->len > 0) {
1128                         *value = g_array_index(out_param,
1129                                         int, 0);
1130                 } else {
1131                         BT_ERR("out_param length is 0!!");
1132                 }
1133         }
1134
1135         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1136
1137         return result;
1138 }
1139
1140 BT_EXPORT_API int bluetooth_dpm_set_limited_discoverable_state(bt_dpm_status_t value)
1141 {
1142         int result;
1143
1144         BT_CHECK_ENABLED_ANY(return);
1145
1146         BT_INIT_PARAMS();
1147         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1148
1149         g_array_append_vals(in_param1, &value, sizeof(int));
1150
1151         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_LIMITED_DISCOVERABLE_STATE,
1152                 in_param1, in_param2, in_param3, in_param4, &out_param);
1153
1154         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1155
1156         return result;
1157 }
1158
1159 BT_EXPORT_API int bluetooth_dpm_get_limited_discoverable_state(bt_dpm_status_t *value)
1160 {
1161         int result;
1162
1163         BT_CHECK_ENABLED_ANY(return);
1164
1165         BT_INIT_PARAMS();
1166         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1167
1168         g_array_append_vals(in_param1, &value, sizeof(int));
1169
1170         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_LIMITED_DISCOVERABLE_STATE,
1171                 in_param1, in_param2, in_param3, in_param4, &out_param);
1172
1173         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1174                 if (out_param->len > 0) {
1175                         *value = g_array_index(out_param,
1176                                         int, 0);
1177                 } else {
1178                         BT_ERR("out_param length is 0!!");
1179                 }
1180         }
1181
1182         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1183
1184         return result;
1185 }
1186
1187 BT_EXPORT_API int bluetooth_dpm_set_data_transfer_state(bt_dpm_status_t value)
1188 {
1189         int result;
1190
1191         BT_CHECK_ENABLED_ANY(return);
1192
1193         BT_INIT_PARAMS();
1194         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1195
1196         g_array_append_vals(in_param1, &value, sizeof(int));
1197
1198         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DATA_TRANSFER_STATE,
1199                 in_param1, in_param2, in_param3, in_param4, &out_param);
1200
1201         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1202
1203         return result;
1204 }
1205
1206 BT_EXPORT_API int bluetooth_dpm_get_data_transfer_state(bt_dpm_status_t *value)
1207 {
1208         int result;
1209
1210         BT_CHECK_ENABLED_ANY(return);
1211
1212         BT_INIT_PARAMS();
1213         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1214
1215         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DATA_TRANSFER_STATE,
1216                 in_param1, in_param2, in_param3, in_param4, &out_param);
1217
1218         if (result == BLUETOOTH_DPM_RESULT_SUCCESS) {
1219                 if (out_param->len > 0) {
1220                         *value = g_array_index(out_param,
1221                                         int, 0);
1222                 } else {
1223                         BT_ERR("out_param length is 0!!");
1224                 }
1225         }
1226
1227         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1228
1229         return result;
1230 }
1231 #endif /* #ifdef TIZEN_DPM_ENABLE */