3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include "utility/sync_util.h"
22 #include "plugin/data_converter_plugin.h"
24 #ifndef SYNC_AGENT_LOG
26 #define LOG_TAG "AF_PlugIn"
29 static int current_plugin_count_dataconverter = 0;
31 static plugin_data_converter_s plugIn_repository[PLUGIN_MAX_DATA_CONVERTER];
33 static int _find_data_converter_plugin(int plugin_id);
35 plugin_data_converter_func_set_s plugin_get_data_converter_func_set(void *plugin_handle, plugin_error_e * error_code)
39 *error_code = PLUGIN_SUCCESS;
41 plugin_data_converter_func_set_s func_set;
43 func_set.func_converter = dlsym(plugin_handle, "sync_agent_plugin_converter");
44 func_set.func_replace_converter = dlsym(plugin_handle, "sync_agent_plugin_replace_converter");
45 func_set.func_reverse_converter = dlsym(plugin_handle, "sync_agent_plugin_reverse_converter");
46 func_set.func_alloc_object = dlsym(plugin_handle, "sync_agent_plugin_alloc_object");
47 func_set.func_free_object = dlsym(plugin_handle, "sync_agent_plugin_free_object");
48 func_set.func_set_value = dlsym(plugin_handle, "sync_agent_plugin_set_value");
49 func_set.func_get_value = dlsym(plugin_handle, "sync_agent_plugin_get_value");
50 func_set.func_get_obj_info = dlsym(plugin_handle, "sync_agent_plugin_get_obj_info");
51 func_set.func_free_obj_info = dlsym(plugin_handle, "sync_agent_plugin_free_obj_info");
58 plugin_error_e plugin_register_plugin_data_converter(plugin_data_converter_s plugin)
62 if (current_plugin_count_dataconverter >= PLUGIN_MAX_DATA_CONVERTER) {
63 return PLUGIN_FULL_CAPACITY;
66 plugIn_repository[current_plugin_count_dataconverter] = plugin;
68 current_plugin_count_dataconverter++;
72 return PLUGIN_SUCCESS;
75 void plugin_clear_plugin_data_converter()
80 for (i = 0; i < current_plugin_count_dataconverter; i++) {
81 memset(&(plugIn_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
82 memset(&(plugIn_repository[i].func_set), 0x00, sizeof(plugin_data_converter_func_set_s));
83 memset(&(plugIn_repository[i]), 0x00, sizeof(plugin_data_converter_s));
89 const plugin_data_converter_s *plugin_get_data_converter_plugin_repository(int *count)
93 *count = current_plugin_count_dataconverter;
97 return plugIn_repository;
100 plugin_converter_cb plugin_get_function_converter(int plugin_id)
104 int index = _find_data_converter_plugin(plugin_id);
111 return plugIn_repository[index].func_set.func_converter;
114 plugin_replace_converter_cb plugin_get_function_replace_converter(int plugin_id)
118 int index = _find_data_converter_plugin(plugin_id);
125 return plugIn_repository[index].func_set.func_replace_converter;
128 plugin_reverse_converter_cb plugin_get_function_reverse_converter(int plugin_id)
132 int index = _find_data_converter_plugin(plugin_id);
139 return plugIn_repository[index].func_set.func_reverse_converter;
142 plugin_alloc_object_cb plugin_get_function_alloc_object(int plugIn_id)
146 int index = _find_data_converter_plugin(plugIn_id);
153 return plugIn_repository[index].func_set.func_alloc_object;
156 plugin_free_object_cb plugin_get_function_free_object(int plugin_id)
160 int index = _find_data_converter_plugin(plugin_id);
167 return plugIn_repository[index].func_set.func_free_object;
170 plugin_set_value_cb plugin_get_function_set_value_to_object(int plugin_id)
174 int index = _find_data_converter_plugin(plugin_id);
181 return plugIn_repository[index].func_set.func_set_value;
184 plugin_get_value_cb plugin_get_function_get_value_to_object(int plugin_id)
188 int index = _find_data_converter_plugin(plugin_id);
195 return plugIn_repository[index].func_set.func_get_value;
198 plugin_get_obj_info_cb plugin_get_function_get_obj_info(int plugin_id)
202 int index = _find_data_converter_plugin(plugin_id);
209 return plugIn_repository[index].func_set.func_get_obj_info;
212 plugin_free_obj_info_cb plugin_get_function_free_obj_info(int plugin_id)
216 int index = _find_data_converter_plugin(plugin_id);
223 return plugIn_repository[index].func_set.func_free_obj_info;
226 static int _find_data_converter_plugin(int plugin_id)
231 for (; i < current_plugin_count_dataconverter; i++) {
232 if (plugIn_repository[i].plugin_info.plugin_id == plugin_id) {