DPM: Sync API return value with other bt-service modules.
[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_FEATURE_BT_DPM
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_FEATURE_BT_DPM
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_ERROR_INTERNAL;
37         }
38         if (value != VCONFKEY_BT_DPM_STATUS_RESTRICTED)
39                 return BLUETOOTH_ERROR_NONE;
40         else
41                 return BLUETOOTH_ERROR_PERMISSION_DEINED;
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         int ret = BLUETOOTH_ERROR_NONE;
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                 ret = BLUETOOTH_ERROR_PERMISSION_DEINED;
297         } else if (status == BT_DPM_NO_SERVICE) {
298                 BT_DBG("DPM no service [%d]", status);
299                 ret = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
300         }
301
302         return ret;
303 }
304
305 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
306 {
307         int result =  BLUETOOTH_ERROR_NONE;
308 #ifdef TIZEN_FEATURE_BT_DPM
309         int bt_status;
310 #endif
311
312 #ifdef TIZEN_FEATURE_BT_DPM
313         if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
314                 BT_ERR("Error in reading VCONFKEY_BT_STATUS");
315
316         if (bt_status == VCONFKEY_BT_STATUS_ON) {
317                 if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
318                         BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
319                         result = BLUETOOTH_ERROR_INTERNAL;
320                 } else {
321                         BT_ERR("Set VCONFKEY_BT_DPM_STATUS success\n");
322                         result = BLUETOOTH_ERROR_NONE;
323                 }
324
325                 BT_INIT_PARAMS();
326                 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
327
328                 g_array_append_vals(in_param1, &value, sizeof(int));
329
330                 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
331                         in_param1, in_param2, in_param3, in_param4, &out_param);
332
333                 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
334
335                 if (result == BLUETOOTH_ERROR_NONE &&
336                         value == BLUETOOTH_DPM_BT_RESTRICTED) {
337                         result = bluetooth_disable_adapter();
338                 }
339         } else {
340                 if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
341                         value <= BLUETOOTH_DPM_BT_RESTRICTED) {
342                         if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
343                                 BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
344                                 result = BLUETOOTH_ERROR_INTERNAL;
345                         } else
346                                 result = BLUETOOTH_ERROR_NONE;
347                 } else
348                         result = BLUETOOTH_ERROR_INVALID_PARAM;
349         }
350 #else
351         BT_INIT_PARAMS();
352         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
353
354         g_array_append_vals(in_param1, &value, sizeof(int));
355
356         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_BT_MODE,
357                 in_param1, in_param2, in_param3, in_param4, &out_param);
358
359         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
360 #endif
361
362         return result;
363
364 }
365
366 BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
367 {
368         int result;
369
370 #ifdef TIZEN_FEATURE_BT_DPM
371         *value = bluetooth_dpm_is_mode_allowed();
372         result = BLUETOOTH_ERROR_NONE;
373 #else
374         BT_CHECK_ENABLED_ANY(return);
375
376         BT_INIT_PARAMS();
377         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
378
379         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
380                 in_param1, in_param2, in_param3, in_param4, &out_param);
381
382         if (result == BLUETOOTH_ERROR_NONE) {
383                 if (out_param->len > 0) {
384                         *value = g_array_index(out_param,
385                                         int, 0);
386                 } else {
387                         BT_ERR("out_param length is 0!!");
388                 }
389         }
390
391         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
392 #endif
393
394         return result;
395 }
396
397
398 BT_EXPORT_API int bluetooth_dpm_activate_device_restriction(bt_dpm_status_t value)
399 {
400         int result;
401
402         BT_CHECK_ENABLED_ANY(return);
403
404         BT_INIT_PARAMS();
405         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
406
407         g_array_append_vals(in_param1, &value, sizeof(int));
408
409         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DEVICE_RESTRITION,
410                 in_param1, in_param2, in_param3, in_param4, &out_param);
411
412         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
413
414         return result;
415 }
416
417
418 BT_EXPORT_API int bluetooth_dpm_is_device_restriction_active(bt_dpm_status_t *value)
419 {
420         int result;
421
422         BT_CHECK_ENABLED_ANY(return);
423
424         BT_INIT_PARAMS();
425         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
426
427         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICE_RESTRITION,
428                 in_param1, in_param2, in_param3, in_param4, &out_param);
429
430         if (result == BLUETOOTH_ERROR_NONE) {
431                 if (out_param->len > 0) {
432                         *value = g_array_index(out_param,
433                                         int, 0);
434                 } else {
435                         BT_ERR("out_param length is 0!!");
436                 }
437         }
438
439         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
440
441         return result;
442 }
443
444
445 BT_EXPORT_API int bluetooth_dpm_activate_uuid_restriction(bt_dpm_status_t value)
446 {
447         int result;
448
449         BT_CHECK_ENABLED_ANY(return);
450
451         BT_INIT_PARAMS();
452         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
453
454         g_array_append_vals(in_param1, &value, sizeof(int));
455
456         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_UUID_RESTRITION,
457                 in_param1, in_param2, in_param3, in_param4, &out_param);
458
459         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
460
461         return result;
462 }
463
464
465 BT_EXPORT_API int bluetooth_dpm_is_uuid_restriction_active(bt_dpm_status_t *value)
466 {
467         int result;
468
469         BT_CHECK_ENABLED_ANY(return);
470
471         BT_INIT_PARAMS();
472         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
473
474         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUID_RESTRITION,
475                 in_param1, in_param2, in_param3, in_param4, &out_param);
476
477         if (result == BLUETOOTH_ERROR_NONE) {
478                 if (out_param->len > 0) {
479                         *value = g_array_index(out_param,
480                                         int, 0);
481                 } else {
482                         BT_ERR("out_param length is 0!!");
483                 }
484         }
485
486         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
487
488         return result;
489
490 }
491
492
493 BT_EXPORT_API int bluetooth_dpm_add_devices_to_blacklist(const bluetooth_device_address_t *device_address)
494 {
495         int result;
496
497         BT_CHECK_PARAMETER(device_address, return);
498         BT_CHECK_ENABLED_ANY(return);
499
500         BT_INIT_PARAMS();
501         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
502
503         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
504
505
506         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_BLACKLIST,
507                 in_param1, in_param2, in_param3, in_param4, &out_param);
508
509         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
510
511         return result;
512 }
513
514
515 BT_EXPORT_API int bluetooth_dpm_add_devices_to_whitelist(const bluetooth_device_address_t *device_address)
516 {
517         int result;
518
519         BT_CHECK_PARAMETER(device_address, return);
520         BT_CHECK_ENABLED_ANY(return);
521
522         BT_INIT_PARAMS();
523         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
524
525         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
526
527         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_DEVICES_WHITELIST,
528                 in_param1, in_param2, in_param3, in_param4, &out_param);
529
530         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
531
532         return result;
533
534 }
535
536
537 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_blacklist(const char *service_uuid)
538 {
539         int result;
540         char uuid[BLUETOOTH_UUID_STRING_MAX];
541
542         BT_CHECK_PARAMETER(service_uuid, return);
543         BT_CHECK_ENABLED_ANY(return);
544
545
546         BT_INIT_PARAMS();
547         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
548
549         g_strlcpy(uuid, service_uuid, sizeof(uuid));
550         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
551
552         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_BLACKLIST,
553                 in_param1, in_param2, in_param3, in_param4, &out_param);
554
555         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
556
557         return result;
558
559 }
560
561
562 BT_EXPORT_API int bluetooth_dpm_add_uuids_to_whitelist(const char *service_uuid)
563 {
564         int result;
565         char uuid[BLUETOOTH_UUID_STRING_MAX];
566
567         BT_CHECK_PARAMETER(service_uuid, return);
568         BT_CHECK_ENABLED_ANY(return);
569
570         BT_INIT_PARAMS();
571         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
572
573         g_strlcpy(uuid, service_uuid, sizeof(uuid));
574         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
575
576         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_ADD_UUIDS_WHITELIST,
577                 in_param1, in_param2, in_param3, in_param4, &out_param);
578
579         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
580
581         return result;
582 }
583
584
585 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_blacklist(void)
586 {
587         int result;
588
589         BT_CHECK_ENABLED_ANY(return);
590
591         BT_INIT_PARAMS();
592         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
593
594         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_BLACKLIST,
595                 in_param1, in_param2, in_param3, in_param4, &out_param);
596
597         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
598
599         return result;
600 }
601
602
603 BT_EXPORT_API int bluetooth_dpm_clear_devices_from_whitelist(void)
604 {
605         int result;
606
607         BT_CHECK_ENABLED_ANY(return);
608
609         BT_INIT_PARAMS();
610         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
611
612         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_DEVICES_WHITELIST,
613                 in_param1, in_param2, in_param3, in_param4, &out_param);
614
615         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
616
617         return result;
618 }
619
620
621 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_blacklist(void)
622 {
623         int result;
624
625         BT_CHECK_ENABLED_ANY(return);
626
627         BT_INIT_PARAMS();
628         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
629
630         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_BLACKLIST,
631                 in_param1, in_param2, in_param3, in_param4, &out_param);
632
633         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
634
635         return result;
636 }
637
638
639 BT_EXPORT_API int bluetooth_dpm_clear_uuids_from_whitelist(void)
640 {
641         int result;
642
643         BT_CHECK_ENABLED_ANY(return);
644
645         BT_INIT_PARAMS();
646         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
647
648         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_CLEAR_UUIDS_WHITELIST,
649                 in_param1, in_param2, in_param3, in_param4, &out_param);
650
651         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
652
653         return result;
654 }
655
656
657 static void _bluetooth_extract_dpm_device_info(int count,
658                                                         bt_dpm_device_list_t *dst_info,
659                                                         bt_dpm_device_list_t *src_info)
660 {
661         int i;
662
663         for (i = 0; i < count; i++) {
664                 memset(dst_info->addresses[i].addr, 0,
665                         BLUETOOTH_ADDRESS_LENGTH);
666
667                 g_strlcpy((gchar *)dst_info->addresses[i].addr, (gchar *)src_info->addresses[i].addr,
668                         BLUETOOTH_ADDRESS_LENGTH);
669
670 //              BT_DBG("address[%d] : %s", i, dst_info->addresses[i].addr);
671         }
672 }
673
674 static void _bluetooth_extract_dpm_uuid_info(int count,
675                                                         bt_dpm_uuids_list_t *dst_info,
676                                                         bt_dpm_uuids_list_t *src_info)
677 {
678         int i;
679
680         for (i = 0; i < count; i++) {
681                 memset(dst_info->uuids[i], 0,
682                         BLUETOOTH_UUID_STRING_MAX);
683
684                 g_strlcpy(dst_info->uuids[i], src_info->uuids[i],
685                         BLUETOOTH_UUID_STRING_MAX);
686
687                 BT_DBG("uuids[%d] : %s", i, dst_info->uuids[i]);
688         }
689 }
690
691 BT_EXPORT_API int bluetooth_dpm_get_devices_from_blacklist(bt_dpm_device_list_t *device_list)
692 {
693         int result;
694         bt_dpm_device_list_t *devices = NULL;
695
696         BT_CHECK_ENABLED_ANY(return);
697
698         BT_INIT_PARAMS();
699         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
700
701         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_BLACKLIST,
702                 in_param1, in_param2, in_param3, in_param4, &out_param);
703
704         if (result == BLUETOOTH_ERROR_NONE) {
705                 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
706                 BT_DBG("device_list->count : %d", devices->count);
707
708                 if (devices->count == 0) {
709                         BT_ERR("device_list->count is zero !");
710                         result = BLUETOOTH_ERROR_NOT_FOUND;
711                 }
712
713                 device_list->count = devices->count;
714
715                 _bluetooth_extract_dpm_device_info(devices->count,
716                                 device_list, devices);
717         } else {
718                 BT_ERR("Get Devices list Failed");
719         }
720
721         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
722
723         return result;
724 }
725
726 BT_EXPORT_API int bluetooth_dpm_get_devices_from_whitelist(bt_dpm_device_list_t *device_list)
727 {
728         int result;
729         bt_dpm_device_list_t *devices = NULL;
730
731         BT_CHECK_ENABLED_ANY(return);
732
733         BT_INIT_PARAMS();
734         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
735
736         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DEVICES_WHITELIST,
737                 in_param1, in_param2, in_param3, in_param4, &out_param);
738
739         if (result == BLUETOOTH_ERROR_NONE) {
740                 devices = &g_array_index(out_param, bt_dpm_device_list_t, 0);
741                 BT_DBG("device_list->count : %d", devices->count);
742
743                 if (devices->count == 0) {
744                         BT_ERR("device_list->count is zero !");
745                         result = BLUETOOTH_ERROR_NOT_FOUND;
746                 }
747
748                 device_list->count = devices->count;
749
750                 _bluetooth_extract_dpm_device_info(devices->count,
751                                 device_list, devices);
752
753         } else {
754                 BT_ERR("Get Devices list Failed");
755         }
756         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
757
758         return result;
759 }
760
761 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_blacklist(bt_dpm_uuids_list_t *uuid_list)
762 {
763         int result;
764         bt_dpm_uuids_list_t *uuids;
765
766         BT_CHECK_ENABLED_ANY(return);
767
768         BT_INIT_PARAMS();
769         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
770
771         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_BLACKLIST,
772                 in_param1, in_param2, in_param3, in_param4, &out_param);
773
774         if (result == BLUETOOTH_ERROR_NONE) {
775                 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
776                 BT_DBG("uuids->count : %d", uuids->count);
777
778                 if (uuids->count == 0) {
779                         BT_ERR("uuids->count is zero !");
780                         result = BLUETOOTH_ERROR_NOT_FOUND;
781                 }
782
783                 uuid_list->count = uuids->count;
784                 _bluetooth_extract_dpm_uuid_info(uuids->count,
785                                 uuid_list, uuids);
786         } else {
787                 BT_ERR("Get UUIDS list Failed");
788         }
789
790         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
791
792         return result;
793 }
794
795 BT_EXPORT_API int bluetooth_dpm_get_uuids_from_whitelist(bt_dpm_uuids_list_t *uuid_list)
796 {
797         int result;
798         bt_dpm_uuids_list_t *uuids;
799
800         BT_CHECK_ENABLED_ANY(return);
801
802         BT_INIT_PARAMS();
803         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
804
805         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_UUIDS_WHITELIST,
806                 in_param1, in_param2, in_param3, in_param4, &out_param);
807
808         if (result == BLUETOOTH_ERROR_NONE) {
809                 uuids = &g_array_index(out_param, bt_dpm_uuids_list_t, 0);
810                 BT_DBG("uuids->count : %d", uuids->count);
811
812                 if (uuids->count == 0) {
813                         BT_ERR("uuids->count is zero !");
814                         result = BLUETOOTH_ERROR_NOT_FOUND;
815                 }
816
817                 uuid_list->count = uuids->count;
818
819                 _bluetooth_extract_dpm_uuid_info(uuids->count,
820                                 uuid_list, uuids);
821         } else {
822                 BT_ERR("Get UUIDS list Failed");
823         }
824
825         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
826
827         return result;
828 }
829
830 BT_EXPORT_API int bluetooth_dpm_remove_device_from_whitelist(const bluetooth_device_address_t *device_address)
831 {
832         int result;
833
834         BT_CHECK_PARAMETER(device_address, return);
835         BT_CHECK_ENABLED_ANY(return);
836
837         BT_INIT_PARAMS();
838         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
839
840         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
841
842         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_WHITELIST,
843                 in_param1, in_param2, in_param3, in_param4, &out_param);
844
845         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
846
847         return result;
848 }
849
850 BT_EXPORT_API int bluetooth_dpm_remove_device_from_blacklist(const bluetooth_device_address_t *device_address)
851 {
852         int result;
853
854         BT_CHECK_PARAMETER(device_address, return);
855         BT_CHECK_ENABLED_ANY(return);
856
857         BT_INIT_PARAMS();
858         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
859
860         g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
861
862         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_DEVICE_BLACKLIST,
863                 in_param1, in_param2, in_param3, in_param4, &out_param);
864
865         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
866
867         return result;
868 }
869
870 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_whitelist(const char *service_uuid)
871 {
872         int result;
873         char uuid[BLUETOOTH_UUID_STRING_MAX];
874
875         BT_CHECK_PARAMETER(service_uuid, return);
876         BT_CHECK_ENABLED_ANY(return);
877
878         BT_INIT_PARAMS();
879         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
880
881         g_strlcpy(uuid, service_uuid, sizeof(uuid));
882         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
883
884         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_WHITELIST,
885                 in_param1, in_param2, in_param3, in_param4, &out_param);
886
887         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
888
889         return result;
890 }
891
892 BT_EXPORT_API int bluetooth_dpm_remove_uuid_from_blacklist(const char *service_uuid)
893 {
894         int result;
895         char uuid[BLUETOOTH_UUID_STRING_MAX];
896
897         BT_CHECK_PARAMETER(service_uuid, return);
898         BT_CHECK_ENABLED_ANY(return);
899
900         BT_INIT_PARAMS();
901         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
902
903         g_strlcpy(uuid, service_uuid, sizeof(uuid));
904         g_array_append_vals(in_param1, uuid, BLUETOOTH_UUID_STRING_MAX);
905
906         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_REMOVE_UUID_BLACKLIST,
907                 in_param1, in_param2, in_param3, in_param4, &out_param);
908
909         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
910
911         return result;
912
913 }
914
915 BT_EXPORT_API int bluetooth_dpm_set_allow_outgoing_call(bt_dpm_status_t value)
916 {
917         int result;
918
919         BT_CHECK_ENABLED_ANY(return);
920
921         BT_INIT_PARAMS();
922         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
923
924         g_array_append_vals(in_param1, &value, sizeof(int));
925
926         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_ALLOW_OUTGOING_CALL,
927                 in_param1, in_param2, in_param3, in_param4, &out_param);
928
929         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
930
931         return result;
932 }
933
934 BT_EXPORT_API int bluetooth_dpm_get_allow_outgoing_call(bt_dpm_status_t *value)
935 {
936         int result;
937
938         BT_CHECK_ENABLED_ANY(return);
939
940         BT_INIT_PARAMS();
941         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
942
943         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_OUTGOING_CALL,
944                 in_param1, in_param2, in_param3, in_param4, &out_param);
945
946         if (result == BLUETOOTH_ERROR_NONE) {
947                 if (out_param->len > 0) {
948                         *value = g_array_index(out_param,
949                                         int, 0);
950                 } else {
951                         BT_ERR("out_param length is 0!!");
952                 }
953         }
954
955         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
956
957         return result;
958 }
959
960 BT_EXPORT_API int bluetooth_dpm_set_pairing_state(bt_dpm_status_t value)
961 {
962         int result;
963
964         BT_CHECK_ENABLED_ANY(return);
965
966         BT_INIT_PARAMS();
967         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
968
969         g_array_append_vals(in_param1, &value, sizeof(int));
970
971         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PAIRING_STATE,
972                 in_param1, in_param2, in_param3, in_param4, &out_param);
973
974         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
975
976         return result;
977 }
978
979 BT_EXPORT_API int bluetooth_dpm_get_pairing_state(bt_dpm_status_t *value)
980 {
981         int result;
982
983         BT_CHECK_ENABLED_ANY(return);
984
985         BT_INIT_PARAMS();
986         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
987
988         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_ALLOW_BT_MODE,
989                 in_param1, in_param2, in_param3, in_param4, &out_param);
990
991         if (result == BLUETOOTH_ERROR_NONE) {
992                 if (out_param->len > 0) {
993                         *value = g_array_index(out_param,
994                                         int, 0);
995                 } else {
996                         BT_ERR("out_param length is 0!!");
997                 }
998         }
999
1000         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1001
1002         return result;
1003 }
1004
1005 BT_EXPORT_API int bluetooth_dpm_set_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t value)
1006 {
1007         int result;
1008
1009         BT_CHECK_ENABLED_ANY(return);
1010
1011         BT_INIT_PARAMS();
1012         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1013
1014         g_array_append_vals(in_param1, &profile, sizeof(int));
1015         g_array_append_vals(in_param2, &value, sizeof(int));
1016
1017         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_PROFILE_STATE,
1018                 in_param1, in_param2, in_param3, in_param4, &out_param);
1019
1020         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1021
1022         return result;
1023 }
1024
1025 BT_EXPORT_API int bluetooth_dpm_get_profile_state(bt_dpm_profile_t profile, bt_dpm_status_t *value)
1026 {
1027         int result;
1028
1029         BT_CHECK_ENABLED_ANY(return);
1030
1031         BT_INIT_PARAMS();
1032         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1033
1034         g_array_append_vals(in_param1, &profile, sizeof(int));
1035
1036         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_PROFILE_STATE,
1037                 in_param1, in_param2, in_param3, in_param4, &out_param);
1038
1039         if (result == BLUETOOTH_ERROR_NONE) {
1040                 if (out_param->len > 0) {
1041                         *value = g_array_index(out_param,
1042                                         int, 0);
1043                 } else {
1044                         BT_ERR("out_param length is 0!!");
1045                 }
1046         }
1047
1048         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1049
1050         return result;
1051 }
1052
1053 BT_EXPORT_API int bluetooth_dpm_set_desktop_connectivity_state(bt_dpm_status_t value)
1054 {
1055         int result;
1056
1057         BT_CHECK_ENABLED_ANY(return);
1058
1059         BT_INIT_PARAMS();
1060         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1061
1062         g_array_append_vals(in_param1, &value, sizeof(int));
1063
1064         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DESKROP_CONNECTIVITY_STATE,
1065                 in_param1, in_param2, in_param3, in_param4, &out_param);
1066
1067         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1068
1069         return result;
1070 }
1071
1072 BT_EXPORT_API int bluetooth_dpm_get_desktop_connectivity_state(bt_dpm_status_t *value)
1073 {
1074         int result;
1075
1076         BT_CHECK_ENABLED_ANY(return);
1077
1078         BT_INIT_PARAMS();
1079         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1080
1081         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DESKROP_CONNECTIVITY_STATE,
1082                 in_param1, in_param2, in_param3, in_param4, &out_param);
1083
1084         if (result == BLUETOOTH_ERROR_NONE) {
1085                 if (out_param->len > 0) {
1086                         *value = g_array_index(out_param,
1087                                         int, 0);
1088                 } else {
1089                         BT_ERR("out_param length is 0!!");
1090                 }
1091         }
1092
1093         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1094
1095         return result;
1096 }
1097
1098 BT_EXPORT_API int bluetooth_dpm_set_discoverable_state(bt_dpm_status_t value)
1099 {
1100         int result;
1101
1102         BT_CHECK_ENABLED_ANY(return);
1103
1104         BT_INIT_PARAMS();
1105         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1106
1107         g_array_append_vals(in_param1, &value, sizeof(int));
1108
1109         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DISCOVERABLE_STATE,
1110                 in_param1, in_param2, in_param3, in_param4, &out_param);
1111
1112         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1113
1114         return result;
1115 }
1116
1117 BT_EXPORT_API int bluetooth_dpm_get_discoverable_state(bt_dpm_status_t *value)
1118 {
1119         int result;
1120
1121         BT_CHECK_ENABLED_ANY(return);
1122
1123         BT_INIT_PARAMS();
1124         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1125
1126         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DISCOVERABLE_STATE,
1127                 in_param1, in_param2, in_param3, in_param4, &out_param);
1128
1129         if (result == BLUETOOTH_ERROR_NONE) {
1130                 if (out_param->len > 0) {
1131                         *value = g_array_index(out_param,
1132                                         int, 0);
1133                 } else {
1134                         BT_ERR("out_param length is 0!!");
1135                 }
1136         }
1137
1138         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1139
1140         return result;
1141 }
1142
1143 BT_EXPORT_API int bluetooth_dpm_set_limited_discoverable_state(bt_dpm_status_t value)
1144 {
1145         int result;
1146
1147         BT_CHECK_ENABLED_ANY(return);
1148
1149         BT_INIT_PARAMS();
1150         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1151
1152         g_array_append_vals(in_param1, &value, sizeof(int));
1153
1154         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_LIMITED_DISCOVERABLE_STATE,
1155                 in_param1, in_param2, in_param3, in_param4, &out_param);
1156
1157         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1158
1159         return result;
1160 }
1161
1162 BT_EXPORT_API int bluetooth_dpm_get_limited_discoverable_state(bt_dpm_status_t *value)
1163 {
1164         int result;
1165
1166         BT_CHECK_ENABLED_ANY(return);
1167
1168         BT_INIT_PARAMS();
1169         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1170
1171         g_array_append_vals(in_param1, &value, sizeof(int));
1172
1173         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_LIMITED_DISCOVERABLE_STATE,
1174                 in_param1, in_param2, in_param3, in_param4, &out_param);
1175
1176         if (result == BLUETOOTH_ERROR_NONE) {
1177                 if (out_param->len > 0) {
1178                         *value = g_array_index(out_param,
1179                                         int, 0);
1180                 } else {
1181                         BT_ERR("out_param length is 0!!");
1182                 }
1183         }
1184
1185         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1186
1187         return result;
1188 }
1189
1190 BT_EXPORT_API int bluetooth_dpm_set_data_transfer_state(bt_dpm_status_t value)
1191 {
1192         int result;
1193
1194         BT_CHECK_ENABLED_ANY(return);
1195
1196         BT_INIT_PARAMS();
1197         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1198
1199         g_array_append_vals(in_param1, &value, sizeof(int));
1200
1201         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_SET_DATA_TRANSFER_STATE,
1202                 in_param1, in_param2, in_param3, in_param4, &out_param);
1203
1204         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1205
1206         return result;
1207 }
1208
1209 BT_EXPORT_API int bluetooth_dpm_get_data_transfer_state(bt_dpm_status_t *value)
1210 {
1211         int result;
1212
1213         BT_CHECK_ENABLED_ANY(return);
1214
1215         BT_INIT_PARAMS();
1216         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1217
1218         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DPM_GET_DATA_TRANSFER_STATE,
1219                 in_param1, in_param2, in_param3, in_param4, &out_param);
1220
1221         if (result == BLUETOOTH_ERROR_NONE) {
1222                 if (out_param->len > 0) {
1223                         *value = g_array_index(out_param,
1224                                         int, 0);
1225                 } else {
1226                         BT_ERR("out_param length is 0!!");
1227                 }
1228         }
1229
1230         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
1231
1232         return result;
1233 }
1234 #endif /* #ifdef TIZEN_FEATURE_BT_DPM */