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, int argc, char **argv,
37 static int (*__plugin_fini)(void);
38 static void *__handle;
40 static void __unload_appcore_ui_plugin(void)
51 static void __load_appcore_ui_plugin(void)
53 if (access(PATH_LIBAPPCORE_UI_PLUGIN, F_OK) != 0)
57 __handle = dlopen(PATH_LIBAPPCORE_UI_PLUGIN, RTLD_LAZY);
59 LOGE("Failed to open %s", PATH_LIBAPPCORE_UI_PLUGIN);
64 __plugin_init = dlsym(__handle, APPCORE_UI_PLUGIN_INIT);
66 LOGW("Failed to load %s symbol", APPCORE_UI_PLUGIN_INIT);
68 __plugin_fini = dlsym(__handle, APPCORE_UI_PLUGIN_FINI);
70 LOGW("Failed to load %s symbol", APPCORE_UI_PLUGIN_FINI);
73 void appcore_ui_plugin_init(appcore_ui_base_ops *ops, int argc, char **argv,
76 LOGI("[PLUGIN] init");
78 if (!__plugin_init && !__plugin_fini)
79 __load_appcore_ui_plugin();
82 __plugin_init(ops, argc, argv, hint);
85 void appcore_ui_plugin_fini(void)
87 LOGI("[PLUGIN] fini");
92 __unload_appcore_ui_plugin();