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 #include "plugin_manager.h"
22 static PluginFunc* __pluginFunc = NULL;
23 static void* __pluginLib;
25 #define PLUGIN_PATH "/usr/share/dotnet.tizen/lib/libdotnet_plugin.so"
27 int initializePluginManager(const char* mode)
29 if (isFileExist(PLUGIN_PATH)) {
30 __pluginLib = dlopen(PLUGIN_PATH, RTLD_NOW | RTLD_LOCAL);
32 __pluginFunc = (PluginFunc*)calloc(sizeof(PluginFunc), 1);
34 fprintf(stderr, "fail to allocate memory for plugin function structure\n");
37 __pluginFunc->initialize = (plugin_initialize_ptr)dlsym(__pluginLib, "plugin_initialize");
38 __pluginFunc->preload = (plugin_preload_ptr)dlsym(__pluginLib, "plugin_preload");
39 __pluginFunc->set_app_info = (plugin_set_app_info_ptr)dlsym(__pluginLib, "plugin_set_app_info");
40 __pluginFunc->set_coreclr_info = (plugin_set_coreclr_info_ptr)dlsym(__pluginLib, "plugin_set_coreclr_info");
41 __pluginFunc->get_dll_path = (plugin_get_dll_path_ptr)dlsym(__pluginLib, "plugin_get_dll_path");
42 __pluginFunc->before_execute = (plugin_before_execute_ptr)dlsym(__pluginLib, "plugin_before_execute");
43 __pluginFunc->finalize = (plugin_finalize_ptr)dlsym(__pluginLib, "plugin_finalize");
46 if (__pluginFunc->initialize)
47 __pluginFunc->initialize(mode);
53 void finalizePluginManager()
56 if (__pluginFunc->finalize) {
57 __pluginFunc->finalize();
71 if (__pluginFunc && __pluginFunc->preload) {
72 __pluginFunc->preload();
76 void pluginSetAppInfo(const char* appId, const char* managedAssemblyPath)
78 if (__pluginFunc && __pluginFunc->set_app_info) {
79 __pluginFunc->set_app_info(appId, managedAssemblyPath);
83 void pluginSetCoreclrInfo(void* hostHandle, unsigned int domainId, coreclr_create_delegate_ptr delegateFunc)
85 if (__pluginFunc && __pluginFunc->set_coreclr_info) {
86 __pluginFunc->set_coreclr_info(hostHandle, domainId, delegateFunc);
90 char* pluginGetDllPath()
92 if (__pluginFunc && __pluginFunc->get_dll_path) {
93 return __pluginFunc->get_dll_path();
99 void pluginBeforeExecute()
101 if (__pluginFunc && __pluginFunc->before_execute) {
102 __pluginFunc->before_execute();