Remove and modify for some dbus policies
[platform/core/connectivity/bluetooth-frwk.git] / include / bt-internal-types.c
index cdbfb66..1c91f88 100644 (file)
  *
  */
 
-/* This is infrastructral, shared functino for all bt-* / *.c files. */
+/* This is infrastructral, shared function for all bt-* / *.c files. */
+
+#include <dlfcn.h>
 
 #include "bt-internal-types.h"
 
 tizen_profile_t profile = _PROFILE_UNKNOWN;
+
+bt_plugin_info_t *headed_plugin_info = NULL;
+
+void bluetooth_plugin_init()
+{
+       headed_plugin_info = g_malloc0(sizeof(bt_plugin_info_t));
+       if (!headed_plugin_info)
+               return;
+
+       /* check ARCH 64 or 32*/
+       if (!access(FILEPATH_ARCH_64, 0))
+               headed_plugin_info->handle_headed = dlopen(HEADED_PLUGIN_FILEPATH64, RTLD_NOW);
+       else
+               headed_plugin_info->handle_headed = dlopen(HEADED_PLUGIN_FILEPATH, RTLD_NOW);
+
+       if (!headed_plugin_info->handle_headed) {
+               headed_plugin_info->plugin_headed_enabled = FALSE;
+               return;
+       }
+
+       headed_plugin_info->headed_plugin = dlsym(headed_plugin_info->handle_headed, "headed_plugin");
+       if (!headed_plugin_info->headed_plugin) {
+               dlclose(headed_plugin_info->handle_headed);
+               headed_plugin_info->plugin_headed_enabled = FALSE;
+               return;
+       }
+
+       headed_plugin_info->plugin_headed_enabled = TRUE;
+}
+
+void bluetooth_plugin_deinit()
+{
+       if (!headed_plugin_info->plugin_headed_enabled) {
+               g_free(headed_plugin_info);
+               headed_plugin_info = NULL;
+               return;
+       }
+
+       dlclose(headed_plugin_info->handle_headed);
+       headed_plugin_info->plugin_headed_enabled = FALSE;
+       g_free(headed_plugin_info);
+       headed_plugin_info = NULL;
+}
+