2 * Copyright (c) 2017 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.
22 #include "appcore_ui_plugin.h"
28 #define LOG_TAG "APP_CORE_UI_PLUGIN"
30 #define PATH_LIBAPPCORE_UI_PLUGIN \
31 "/usr/share/appcore/plugins/libappcore-ui-plugin.so"
32 #define APPCORE_UI_PLUGIN_INIT "APPCORE_UI_PLUGIN_INIT"
33 #define APPCORE_UI_PLUGIN_FINI "APPCORE_UI_PLUGIN_FINI"
35 static int (*__plugin_init)(appcore_ui_base_ops *ops, unsigned int *hint);
36 static int (*__plugin_fini)(void);
37 static void *__handle;
39 static void __unload_appcore_ui_plugin(void)
50 static void __load_appcore_ui_plugin(void)
52 if (access(PATH_LIBAPPCORE_UI_PLUGIN, F_OK) != 0)
56 __handle = dlopen(PATH_LIBAPPCORE_UI_PLUGIN, RTLD_LAZY);
58 LOGE("Failed to open %s", PATH_LIBAPPCORE_UI_PLUGIN);
63 __plugin_init = dlsym(__handle, APPCORE_UI_PLUGIN_INIT);
65 LOGW("Failed to load %s symbol", APPCORE_UI_PLUGIN_INIT);
67 __plugin_fini = dlsym(__handle, APPCORE_UI_PLUGIN_FINI);
69 LOGW("Failed to load %s symbol", APPCORE_UI_PLUGIN_FINI);
72 void appcore_ui_plugin_init(appcore_ui_base_ops *ops, unsigned int *hint)
74 LOGI("[PLUGIN] init");
76 if (!__plugin_init && !__plugin_fini)
77 __load_appcore_ui_plugin();
80 __plugin_init(ops, hint);
83 void appcore_ui_plugin_fini(void)
85 LOGI("[PLUGIN] fini");
90 __unload_appcore_ui_plugin();