4 * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7 * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
26 #include "plugin_module.h"
28 #include "debug_util.h"
30 #define SPECIFIC_PLUGIN_PATH_PREFIX "/usr/lib/libSLP-lbs-plugin-"
31 #define SPECIFIC_PLUGIN_PATH_POSTFIX ".so"
33 static const gps_plugin_interface *g_plugin = NULL;
35 int load_plugin_module(char *specific_name, void **plugin_handle)
37 char plugin_path[256];
39 if (specific_name[0] == '\0') {
40 strncpy(plugin_path, GPS_MANAGER_PLUGIN_PATH, sizeof(plugin_path));
42 snprintf(plugin_path, sizeof(plugin_path),
43 SPECIFIC_PLUGIN_PATH_PREFIX
45 SPECIFIC_PLUGIN_PATH_POSTFIX,
49 if (access (plugin_path, R_OK) != 0) {
50 strncpy(plugin_path, GPS_MANAGER_PLUGIN_PATH, sizeof(plugin_path));
51 setting_set_int(VCONFKEY_LOCATION_REPLAY_ENABLED, 1);
54 *plugin_handle = dlopen(plugin_path, RTLD_NOW);
55 if (!*plugin_handle) {
56 LOG_GPS(DBG_ERR, "Failed to load plugin module.");
57 LOG_GPS(DBG_ERR, "%s", dlerror());
61 const gps_plugin_interface *(*get_gps_plugin_interface) ();
62 get_gps_plugin_interface = dlsym(*plugin_handle, "get_gps_plugin_interface");
63 if (!get_gps_plugin_interface) {
64 LOG_GPS(DBG_ERR, "Failed to find entry symbol in plugin module.");
65 dlclose(*plugin_handle);
69 g_plugin = get_gps_plugin_interface();
72 LOG_GPS(DBG_ERR, "Failed to find load symbol in plugin module.");
73 dlclose(*plugin_handle);
76 LOG_GPS(DBG_LOW, "Success to load plugin module (%s).", plugin_path);
81 int unload_plugin_module(void *plugin_handle)
83 if (plugin_handle == NULL) {
84 LOG_GPS(DBG_ERR, "plugin_handle is already NULL.");
88 dlclose(plugin_handle);
93 const gps_plugin_interface *get_plugin_module(void)