2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 /* This is infrastructral, shared function for all bt-* / *.c files. */
22 #include "bt-internal-types.h"
24 tizen_profile_t profile = _PROFILE_UNKNOWN;
26 bt_plugin_info_t *headed_plugin_info = NULL;
28 void bluetooth_plugin_init()
30 headed_plugin_info = g_malloc0(sizeof(bt_plugin_info_t));
31 if (!headed_plugin_info)
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);
38 headed_plugin_info->handle_headed = dlopen(HEADED_PLUGIN_FILEPATH, RTLD_NOW);
40 if (!headed_plugin_info->handle_headed) {
41 headed_plugin_info->plugin_headed_enabled = FALSE;
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;
52 headed_plugin_info->plugin_headed_enabled = TRUE;
55 void bluetooth_plugin_deinit()
57 if (!headed_plugin_info->plugin_headed_enabled) {
58 g_free(headed_plugin_info);
59 headed_plugin_info = NULL;
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;