Remove wrong dependency in the systemd service file
[platform/core/connectivity/bluetooth-frwk.git] / include / bt-internal-types.c
1 /*
2  * Copyright (c) 2016 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 /* This is infrastructral, shared function for all bt-* / *.c files. */
19
20 #include <dlfcn.h>
21
22 #include "bt-internal-types.h"
23
24 tizen_profile_t profile = _PROFILE_UNKNOWN;
25
26 bt_plugin_info_t *headed_plugin_info = NULL;
27
28 void bluetooth_plugin_init()
29 {
30         headed_plugin_info = g_malloc0(sizeof(bt_plugin_info_t));
31         if (!headed_plugin_info)
32                 return;
33
34         /* check ARCH 64 or 32*/
35         if (!access(FILEPATH_ARCH_64, 0))
36                 headed_plugin_info->handle_headed = dlopen(HEADED_PLUGIN_FILEPATH64, RTLD_NOW);
37         else
38                 headed_plugin_info->handle_headed = dlopen(HEADED_PLUGIN_FILEPATH, RTLD_NOW);
39
40         if (!headed_plugin_info->handle_headed) {
41                 headed_plugin_info->plugin_headed_enabled = FALSE;
42                 return;
43         }
44
45         headed_plugin_info->headed_plugin = dlsym(headed_plugin_info->handle_headed, "headed_plugin");
46         if (!headed_plugin_info->headed_plugin) {
47                 dlclose(headed_plugin_info->handle_headed);
48                 headed_plugin_info->plugin_headed_enabled = FALSE;
49                 return;
50         }
51
52         headed_plugin_info->plugin_headed_enabled = TRUE;
53 }
54
55 void bluetooth_plugin_deinit()
56 {
57         if (!headed_plugin_info->plugin_headed_enabled) {
58                 g_free(headed_plugin_info);
59                 headed_plugin_info = NULL;
60                 return;
61         }
62
63         dlclose(headed_plugin_info->handle_headed);
64         headed_plugin_info->plugin_headed_enabled = FALSE;
65         g_free(headed_plugin_info);
66         headed_plugin_info = NULL;
67 }
68