Fix Web TC blocking issues
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-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 #include <glib.h>
19 #include <gio/gio.h>
20 #include <dlog.h>
21 #include <string.h>
22 #include <syspopup_caller.h>
23 #include <bundle_internal.h>
24
25 #include "bluetooth-api.h"
26 #include "bt-internal-types.h"
27
28 #include "bt-service-common.h"
29 #include "bt-service-dpm.h"
30
31 static dpm_policy_t policy_table[DPM_POLICY_END] = {
32         [DPM_POLICY_ALLOW_BLUETOOTH] = {DPM_BT_ERROR},
33         [DPM_POLICY_BLUETOOTH_DEVICE_RESTRICTION] = {DPM_STATUS_ERROR},
34         [DPM_POLICY_BLUETOOTH_UUID_RESTRICTION] = {DPM_STATUS_ERROR},
35         [DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST] = {NULL},
36         [DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST] = {NULL},
37         [DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST] = {NULL},
38         [DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST] = {NULL},
39         [DPM_POLICY_ALLOW_BLUETOOTH_OUTGOING_CALL] = {DPM_STATUS_ERROR},
40         [DPM_POLICY_BLUETOOTH_PAIRING_STATE] = {DPM_STATUS_ERROR},
41         [DPM_POLICY_BLUETOOTH_DESKTOP_CONNECTIVITY_STATE] = {DPM_STATUS_ERROR},
42         [DPM_POLICY_BLUETOOTH_DISCOVERABLE_STATE] = {DPM_STATUS_ERROR},
43         [DPM_POLICY_BLUETOOTH_LIMITED_DISCOVERABLE_STATE] = {DPM_STATUS_ERROR},
44         [DPM_POLICY_BLUETOOTH_DATA_TRANSFER_STATE] = {DPM_STATUS_ERROR},
45 };
46
47
48 /**
49  * @brief DPM profile state
50  * @see
51  */
52 static dpm_profile_state_t dpm_profile_state[DPM_PROFILE_NONE]  = {
53         [DPM_POLICY_BLUETOOTH_A2DP_PROFILE_STATE] = {DPM_STATUS_ERROR},
54         [DPM_POLICY_BLUETOOTH_AVRCP_PROFILE_STATE] = {DPM_STATUS_ERROR},
55         [DPM_POLICY_BLUETOOTH_BPP_PROFILE_STATE] = {DPM_STATUS_ERROR},
56         [DPM_POLICY_BLUETOOTH_DUN_PROFILE_STATE] = {DPM_STATUS_ERROR},
57         [DPM_POLICY_BLUETOOTH_FTP_PROFILE_STATE] = {DPM_STATUS_ERROR},
58         [DPM_POLICY_BLUETOOTH_HFP_PROFILE_STATE] = {DPM_STATUS_ERROR},
59         [DPM_POLICY_BLUETOOTH_HSP_PROFILE_STATE] = {DPM_STATUS_ERROR},
60         [DPM_POLICY_BLUETOOTH_PBAP_PROFILE_STATE] = {DPM_STATUS_ERROR},
61         [DPM_POLICY_BLUETOOTH_SAP_PROFILE_STATE] = {DPM_STATUS_ERROR},
62         [DPM_POLICY_BLUETOOTH_SPP_PROFILE_STATE] = {DPM_STATUS_ERROR},
63 };
64
65 dpm_result_t _bt_dpm_set_allow_bluetooth_mode(dpm_bt_allow_t value)
66 {
67         BT_INFO("_bt_dpm_set_allow_bluetooth_mode");
68         policy_table[DPM_POLICY_ALLOW_BLUETOOTH].value  = value;
69
70         return DPM_RESULT_SUCCESS;
71 }
72
73 dpm_bt_allow_t _bt_dpm_get_allow_bluetooth_mode(void)
74 {
75         BT_INFO("_bt_dpm_get_allow_bluetooth_mode");
76         return policy_table[DPM_POLICY_ALLOW_BLUETOOTH].value;
77 }
78
79 dpm_result_t _bt_dpm_activate_bluetooth_device_restriction(dpm_status_t value)
80 {
81         BT_INFO("_bt_dpm_activate_bluetooth_device_restriction");
82         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
83                 return DPM_RESULT_ACCESS_DENIED;
84
85         policy_table[DPM_POLICY_BLUETOOTH_DEVICE_RESTRICTION].value  = value;
86
87         return DPM_RESULT_SUCCESS;
88 }
89
90 dpm_status_t _bt_dpm_is_bluetooth_device_restriction_active(void)
91 {
92         BT_INFO("_bt_dpm_is_bluetooth_device_restriction_active");
93
94         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
95                 return DPM_RESTRICTED;
96
97         return policy_table[DPM_POLICY_BLUETOOTH_DEVICE_RESTRICTION].value;
98 }
99
100 dpm_result_t _bt_dpm_activate_bluetoooth_uuid_restriction(dpm_status_t value)
101 {
102         BT_INFO("_bt_dpm_activate_bluetooth_device_restriction");
103         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
104                 return DPM_RESULT_ACCESS_DENIED;
105
106         policy_table[DPM_POLICY_BLUETOOTH_UUID_RESTRICTION].value  = value;
107
108         return DPM_RESULT_SUCCESS;
109 }
110
111 dpm_status_t _bt_dpm_is_bluetooth_uuid_restriction_active(void)
112 {
113         BT_INFO("_bt_dpm_is_bluetooth_uuid_restriction_active");
114
115         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
116                 return DPM_RESTRICTED;
117
118         return policy_table[DPM_POLICY_BLUETOOTH_UUID_RESTRICTION].value;
119 }
120
121 dpm_result_t _bt_dpm_add_bluetooth_devices_to_blacklist(char *device_address)
122 {
123         char *dev_addr;
124         BT_INFO("_bt_dpm_add_bluetooth_devices_to_blacklist");
125
126         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
127                 return DPM_RESULT_ACCESS_DENIED;
128
129         dev_addr = g_strdup(device_address);
130         if (!dev_addr)
131                 return DPM_RESULT_FAIL;
132         policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list  = g_slist_append(policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list, dev_addr);
133         return DPM_RESULT_SUCCESS;
134 }
135
136 GSList *_bt_dpm_get_bluetooth_devices_from_blacklist(void)
137 {
138         BT_INFO("_bt_dpm_get_bluetooth_devices_from_blacklist");
139
140         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
141                 return NULL;
142
143         return policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list;
144 }
145
146 dpm_result_t _bt_dpm_add_bluetooth_devices_to_whitelist(char *device_address)
147 {
148         char *dev_addr;
149         BT_INFO("_bt_dpm_add_bluetooth_devices_to_whitelist");
150
151         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
152                 return DPM_RESULT_ACCESS_DENIED;
153
154         dev_addr = g_strdup(device_address);
155         if (!dev_addr)
156                 return DPM_RESULT_FAIL;
157         policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list  = g_slist_append(policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list, dev_addr);
158         return DPM_RESULT_SUCCESS;
159 }
160
161 GSList *_bt_dpm_get_bluetooth_devices_from_whitelist(void)
162 {
163         BT_INFO("_bt_dpm_get_bluetooth_devices_from_whitelist");
164
165         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
166                 return NULL;
167
168         return policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list;
169 }
170
171 dpm_result_t _bt_dpm_add_bluetooth_uuids_to_blacklist(char *uuid)
172 {
173         char *l_uuid;
174         BT_INFO("_bt_dpm_add_bluetooth_uuids_to_blacklist");
175
176         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
177                 return DPM_RESULT_ACCESS_DENIED;
178
179         l_uuid = g_strdup(uuid);
180         if (!l_uuid)
181                 return DPM_RESULT_FAIL;
182         policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list  = g_slist_append(policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list, l_uuid);
183         return DPM_RESULT_SUCCESS;
184 }
185
186 GSList *_bt_dpm_get_bluetooth_uuids_from_blacklist(void)
187 {
188         BT_INFO("_bt_dpm_get_bluetooth_uuids_from_blacklist");
189
190         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
191                 return NULL;
192
193         return policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list;
194 }
195
196 dpm_result_t _bt_dpm_add_bluetooth_uuids_to_whitelist(char *uuid)
197 {
198         char *l_uuid;
199         BT_INFO("_bt_dpm_add_bluetooth_uuids_to_blacklist");
200
201         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
202                 return DPM_RESULT_ACCESS_DENIED;
203
204         l_uuid = g_strdup(uuid);
205         if (!l_uuid)
206                 return DPM_RESULT_FAIL;
207         policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list  = g_slist_append(policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list, l_uuid);
208         return DPM_RESULT_SUCCESS;
209 }
210
211
212 GSList *_bt_dpm_get_bluetooth_uuids_from_whitelist(void)
213 {
214         BT_INFO("_bt_dpm_get_bluetooth_uuids_from_whitelist");
215
216         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
217                 return NULL;
218
219         return policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list;
220 }
221
222 dpm_result_t _bt_dpm_set_allow_bluetooth_outgoing_call(dpm_status_t value)
223 {
224         BT_INFO("_bt_dpm_activate_bluetooth_device_restriction");
225         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
226                 return DPM_RESULT_ACCESS_DENIED;
227
228         policy_table[DPM_POLICY_ALLOW_BLUETOOTH_OUTGOING_CALL].value  = value;
229
230         return DPM_RESULT_SUCCESS;
231 }
232
233 dpm_status_t _bt_dpm_get_allow_bluetooth_outgoing_call(void)
234 {
235         BT_INFO("_bt_dpm_get_allow_bluetooth_outgoing_call");
236
237         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
238                 return DPM_RESTRICTED;
239
240         return policy_table[DPM_POLICY_ALLOW_BLUETOOTH_OUTGOING_CALL].value;
241 }
242
243 dpm_result_t _bt_dpm_clear_bluetooth_devices_from_blacklist(void)
244 {
245         GSList *l = NULL;
246         BT_INFO("_bt_dpm_clear_bluetooth_devices_from_blacklist");
247
248         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
249                 return DPM_RESULT_ACCESS_DENIED;
250
251         for (l = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list; l; l = g_slist_next(l)) {
252                 char *address = l->data;
253                 if (address) {
254                         policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list = g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list, address);
255                         g_free(address);
256                 }
257         }
258         return DPM_RESULT_SUCCESS;
259 }
260
261 dpm_result_t _bt_dpm_clear_bluetooth_devices_from_whitelist(void)
262 {
263         GSList *l = NULL;
264         BT_INFO("_bt_dpm_clear_bluetooth_devices_from_blacklist");
265
266         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
267                 return DPM_RESULT_ACCESS_DENIED;
268
269         for (l = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list; l; l = g_slist_next(l)) {
270                 char *address = l->data;
271                 if (address) {
272                         policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list = g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list, address);
273                         g_free(address);
274                 }
275         }
276         return DPM_RESULT_SUCCESS;
277 }
278
279 dpm_result_t _bt_dpm_clear_bluetooth_uuids_from_blacklist(void)
280 {
281         GSList *l = NULL;
282         BT_INFO("_bt_dpm_clear_bluetooth_devices_from_blacklist");
283
284         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
285                 return DPM_RESULT_ACCESS_DENIED;
286
287         for (l = policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list; l; l = g_slist_next(l)) {
288                 char *l_uuid = l->data;
289                 if (l_uuid)
290                         policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list = g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list, l_uuid);
291                         g_free(l_uuid);
292         }
293         return DPM_RESULT_SUCCESS;
294 }
295
296 dpm_result_t _bt_dpm_clear_bluetooth_uuids_from_whitelist(void)
297 {
298         GSList *l = NULL;
299         BT_INFO("_bt_dpm_clear_bluetooth_uuids_from_whitelist");
300
301         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
302                 return DPM_RESULT_ACCESS_DENIED;
303
304         for (l = policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list; l; l = g_slist_next(l)) {
305                 char *l_uuid = l->data;
306                 if (l_uuid) {
307                         policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list = g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list, l_uuid);
308                         g_free(l_uuid);
309                 }
310         }
311         return DPM_RESULT_SUCCESS;
312 }
313
314 dpm_status_t _bt_dpm_set_bluetooth_pairing_state(dpm_status_t value)
315 {
316         BT_INFO("_bt_dpm_set_bluetooth_pairing_state");
317
318         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
319                 return DPM_RESTRICTED;
320
321         policy_table[DPM_POLICY_BLUETOOTH_PAIRING_STATE].value = value;
322
323         return DPM_RESULT_SUCCESS;
324 }
325
326 dpm_status_t _bt_dpm_get_bluetooth_pairing_state(void)
327 {
328         BT_INFO("_bt_dpm_get_bluetooth_pairing_state");
329
330         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
331                 return DPM_RESTRICTED;
332
333         return policy_table[DPM_POLICY_BLUETOOTH_PAIRING_STATE].value;
334 }
335
336 dpm_status_t _bt_dpm_set_bluetooth_profile_state(dpm_profile_t profile, dpm_status_t value)
337 {
338         BT_INFO("_bt_dpm_set_bluetooth_profile_state");
339
340         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
341                 return DPM_RESTRICTED;
342
343         dpm_profile_state[profile].value = value;
344
345         return DPM_RESULT_SUCCESS;
346 }
347
348 dpm_status_t _bt_dpm_get_bluetooth_profile_state(dpm_profile_t profile)
349 {
350         BT_INFO("_bt_dpm_get_bluetooth_profile_state");
351
352         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
353                 return DPM_RESTRICTED;
354
355         return dpm_profile_state[profile].value;
356 }
357
358 dpm_status_t _bt_dpm_set_bluetooth_desktop_connectivity_state(dpm_status_t value)
359 {
360         BT_INFO("_bt_dpm_set_bluetooth_desktop_connectivity_state");
361
362         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
363                 return DPM_RESTRICTED;
364
365         policy_table[DPM_POLICY_BLUETOOTH_DESKTOP_CONNECTIVITY_STATE].value = value;
366
367         return DPM_RESULT_SUCCESS;
368 }
369
370 dpm_status_t _bt_dpm_get_bluetooth_desktop_connectivity_state(void)
371 {
372         BT_INFO("_bt_dpm_get_bluetooth_desktop_connectivity_state");
373
374         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
375                 return DPM_RESTRICTED;
376
377         return policy_table[DPM_POLICY_BLUETOOTH_DESKTOP_CONNECTIVITY_STATE].value;
378 }
379
380 dpm_status_t _bt_dpm_set_bluetooth_discoverable_state(dpm_status_t value)
381 {
382         BT_INFO("_bt_dpm_set_bluetooth_discoverable_state");
383
384         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
385                 return DPM_RESTRICTED;
386
387         policy_table[DPM_POLICY_BLUETOOTH_DISCOVERABLE_STATE].value = value;
388
389         return DPM_RESULT_SUCCESS;
390 }
391
392 dpm_status_t _bt_dpm_get_bluetooth_discoverable_state(void)
393 {
394         BT_INFO("_bt_dpm_get_bluetooth_discoverable_state");
395
396         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
397                 return DPM_RESTRICTED;
398
399         return policy_table[DPM_POLICY_BLUETOOTH_DISCOVERABLE_STATE].value;
400 }
401
402 dpm_status_t _bt_dpm_set_bluetooth_limited_discoverable_state(dpm_status_t value)
403 {
404         BT_INFO("_bt_dpm_set_bluetooth_limited_discoverable_state");
405
406         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
407                 return DPM_RESTRICTED;
408
409         policy_table[DPM_POLICY_BLUETOOTH_LIMITED_DISCOVERABLE_STATE].value = value;
410
411         return DPM_RESULT_SUCCESS;
412 }
413
414 dpm_status_t _bt_dpm_get_bluetooth_limited_discoverable_state(void)
415 {
416         BT_INFO("_bt_dpm_get_bluetooth_limited_discoverable_state");
417
418         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
419                 return DPM_RESTRICTED;
420
421         return policy_table[DPM_POLICY_BLUETOOTH_LIMITED_DISCOVERABLE_STATE].value;
422 }
423
424 dpm_status_t _bt_dpm_set_bluetooth_data_transfer_state(dpm_status_t value)
425 {
426         BT_INFO("_bt_dpm_set_bluetooth_data_transfer_state");
427
428         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
429                 return DPM_RESTRICTED;
430
431         return policy_table[DPM_POLICY_BLUETOOTH_DATA_TRANSFER_STATE].value = value;
432 }
433
434 dpm_status_t _bt_dpm_get_allow_bluetooth_data_transfer_state(dpm_status_t value)
435 {
436         BT_INFO("_bt_dpm_get_allow_bluetooth_data_transfer_state");
437
438         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
439                 return DPM_RESTRICTED;
440
441         return policy_table[DPM_POLICY_BLUETOOTH_DATA_TRANSFER_STATE].value;
442 }
443
444 dpm_result_t _bt_dpm_remove_bluetooth_devices_from_whitelist(GSList *device_addresses)
445 {
446         GSList *l = NULL;
447         GSList *device_list = NULL;
448         BT_INFO("_bt_dpm_remove_bluetooth_devices_from_whitelist");
449
450         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
451                 return DPM_RESULT_ACCESS_DENIED;
452
453         for (device_list = device_addresses; device_list; device_list = g_slist_next(device_list)) {
454                 for (l = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list; l; l = g_slist_next(l)) {
455                         if (l->data == device_list->data) {
456                                 char *addr = device_list->data;
457                                 if (addr) {
458                                         policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list =
459                                                 g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_DEVICES_WHITELIST].list, addr);
460                                         g_free(addr);
461                                         break;
462                                 }
463                         }
464                 }
465         }
466         return DPM_RESULT_SUCCESS;
467 }
468
469 dpm_result_t _bt_dpm_remove_bluetooth_devices_from_blacklist(GSList *device_addresses)
470 {
471         GSList *l = NULL;
472         GSList *device_list = NULL;
473         BT_INFO("_bt_dpm_remove_bluetooth_devices_from_blacklist");
474
475         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
476                 return DPM_RESULT_ACCESS_DENIED;
477
478         for (device_list = device_addresses; device_list; device_list = g_slist_next(device_list)) {
479                 for (l = policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list; l; l = g_slist_next(l)) {
480                         if (l->data == device_list->data) {
481                                 char *addr = device_list->data;
482                                 if (addr) {
483                                         policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list =
484                                                 g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list, addr);
485                                         g_free(addr);
486                                         break;
487                                 }
488                         }
489                 }
490         }
491         return DPM_RESULT_SUCCESS;
492 }
493
494 dpm_result_t _bt_dpm_remove_bluetooth_uuids_from_whitelist(GSList *uuids)
495 {
496         GSList *l = NULL;
497         GSList *uuids_list = NULL;
498         BT_INFO("_bt_dpm_remove_bluetooth_uuids_from_whitelist");
499
500         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
501                 return DPM_RESULT_ACCESS_DENIED;
502
503         for (uuids_list = uuids; uuids_list; uuids_list = g_slist_next(uuids_list)) {
504                 for (l = policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list; l; l = g_slist_next(l)) {
505                         if (l->data == uuids_list->data) {
506                                 char *uuid = uuids_list->data;
507                                 if (uuid) {
508                                         policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list =
509                                                 g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_UUIDS_WHITELIST].list, uuid);
510                                         g_free(uuid);
511                                         break;
512                                 }
513                         }
514                 }
515         }
516         return DPM_RESULT_SUCCESS;
517 }
518
519 dpm_result_t _bt_dpm_remove_bluetooth_uuids_from_blacklist(GSList *uuids)
520 {
521         GSList *l = NULL;
522         GSList *uuids_list = NULL;
523         BT_INFO("_bt_dpm_remove_bluetooth_uuids_from_blacklist");
524
525         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
526                 return DPM_RESULT_ACCESS_DENIED;
527
528         for (uuids_list = uuids; uuids_list; uuids_list = g_slist_next(uuids_list)) {
529                 for (l = policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list; l; l = g_slist_next(l)) {
530                         if (l->data == uuids_list->data) {
531                                 char *uuid = uuids_list->data;
532                                 if (uuid) {
533                                         policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list =
534                                                 g_slist_remove(policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list, uuid);
535                                         g_free(uuid);
536                                         break;
537                                 }
538                         }
539                 }
540         }
541         return DPM_RESULT_SUCCESS;
542 }
543
544 dpm_result_t _bt_dpm_clear_bluetooth_uuids_from_list(void)
545 {
546         BT_INFO("_bt_dpm_clear_bluetooth_uuids_from_list");
547         dpm_result_t err = DPM_RESULT_FAIL;
548
549         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
550                 return DPM_RESULT_ACCESS_DENIED;
551
552         err = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
553         if (!err){
554                 err = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
555         }
556
557         return err;
558 }
559
560 dpm_result_t _bt_dpm_clear_bluetooth_devices_from_list(void)
561 {
562         BT_INFO("_bt_dpm_clear_bluetooth_devices_from_list");
563         dpm_result_t err = DPM_RESULT_FAIL;
564
565         if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_RESTRICTED)
566                 return DPM_RESULT_ACCESS_DENIED;
567
568         err = _bt_dpm_clear_bluetooth_devices_from_blacklist();
569         if (!err){
570                 err = _bt_dpm_clear_bluetooth_devices_from_blacklist();
571         }
572
573         return err;
574 }