2 * Copyright (c) 2011 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.
17 * @file wrt_plugin_export.h
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief Header file for plugin export API
22 #ifndef WRT_PLUGIN_EXPORT_H
23 #define WRT_PLUGIN_EXPORT_H
30 typedef int widget_handle_t;
33 * Parameter which should be used during policy evaluation.
35 typedef struct ace_param_s
42 * List of additional parameters which should be used during policy evaluation.
44 typedef struct ace_param_list_s
51 * Contains list of device capabilities. Each device capability may have
52 * associated list of function params.
54 typedef struct ace_device_cap_s
57 const char** dev_cap_names;
59 ace_param_list_t* params;
63 * List of device capabilities which must be check.
65 typedef struct ace_device_capabilities_s
68 const char **device_cap;
69 } ace_device_capabilities_t;
72 * List of api features that must be checked
74 typedef struct ace_api_features_s
77 const char **api_feature;
81 * Data from request will be used to evaluate policy file.
83 typedef struct ace_request_s
85 widget_handle_t widget_handle;
86 const char* feature_api;
87 const char* function_name;
88 ace_device_capabilities_t device_capabilities;
89 ace_param_list_t param_list;
93 * Data from request will be used to evaluate policy file.
95 typedef struct ace_request_2_s
97 widget_handle_t widget_handle;
98 ace_api_features_t api_features;
99 const char* function_name;
100 ace_device_cap_t device_capabilities;
104 * info returned by plugin_api_check_access
106 #define PLUGIN_API_ACCESS_GRANTED 1
107 #define PLUGIN_API_ACCESS_DENIED 0
108 #define PLUGIN_API_ACCESS_ERROR -1
111 typedef const void* java_script_context_t;
113 typedef struct js_object_properties_s
117 } js_object_properties_t;
119 typedef const void* js_class_template_t;
120 typedef void* js_object_ref_t;
121 typedef const void* js_value_ref_t;
123 typedef js_class_template_t (*js_class_template_getter) (void);
124 typedef void* (*js_class_constructor_cb_t)(js_class_template_t,
125 js_object_ref_t, size_t, js_value_ref_t[],
128 typedef enum class_definition_type_e
133 } class_definition_type_t;
135 typedef enum class_definition_iframe_behaviour_e
137 //object should not be initalized in iframes
140 //object should be copied as reference to each iframe
142 //object should be created for each iframe and NOT inform plugin
144 } class_definition_iframe_behaviour_t;
146 typedef enum class_definition_iframe_notice_e
151 } class_definition_iframe_notice_t;
153 typedef enum class_definition_iframe_overlay_e
157 OVERLAYED_BEFORE_ORIGINAL
158 } class_definition_iframe_overlay_t;
160 typedef void* js_object_instance_t;
161 //global_context - id
162 typedef void(*iframe_loaded_cb)(java_script_context_t global_context,
163 js_object_instance_t iframe,
164 js_object_instance_t object);
166 typedef void* (*js_function_impl)(void*);
168 typedef struct class_definition_options_s
170 class_definition_type_t type;
171 class_definition_iframe_behaviour_t iframe_option;
172 class_definition_iframe_notice_t iframe_notice;
173 class_definition_iframe_overlay_t iframe_overlay;
176 js_function_impl function;
177 } class_definition_options_t;
181 * list of device caps
183 typedef struct devcaps_s
190 * mapping from a feature to corresponding list of device capabilities
192 typedef struct feature_devcaps_s
199 * list of feature_devcaps_t structs
201 typedef struct feature_mapping_s
203 feature_devcaps_t* features;
204 size_t featuresCount;
208 typedef feature_mapping_t* pfeature_mapping_t;
210 typedef pfeature_mapping_t (*features_getter)(void);
212 typedef const devcaps_t* (*devcaps_getter)(pfeature_mapping_t /*features*/,
213 const char* /*featureName*/);
214 typedef void (*deinitializer)(pfeature_mapping_t /*features*/);
216 typedef struct feature_mapping_interface_s
218 features_getter featGetter; /* returns a list of api features */
219 devcaps_getter dcGetter; /*
220 * for a given api feature returns a list of
221 * corresponding device capabilities
224 deinitializer release; /* as memory ownership of features is
225 * transfered to callee you have to call
226 * the release function ptr on features
228 } feature_mapping_interface_t;
232 * This is a structure describing a JS entity template (a class, an interface
233 * or function), object name and it's parent class name (parent_name). JS
234 * entity will be bind to a parent class name (parent_name.js_entity_name).
235 * @param parent_name - parent name (ie Widget.Device)
236 * @param object_name - object name (DeviceStatus)
237 * @param interface_name - interface name (e.g. Widget)
238 * @param js_class_template_getter_fun - js_class_template required to create
240 * @param js_class_consturctor_cb - constructor to call to when instance of
241 * certain interface is created
242 * @param private_data private data for object creator if required (usually
245 typedef struct js_entity_definition_s
247 const char *parent_name;
248 const char *object_name;
249 const char *interface_name;
250 js_class_template_getter js_class_template_getter_fun;
251 js_class_constructor_cb_t js_class_constructor_cb;
252 //class options may be null - default
253 class_definition_options_t* class_options;
254 } js_entity_definition_t;
256 typedef const js_entity_definition_t *js_entity_definition_ptr_t;
259 * Plugin export names
261 #define PLUGIN_WIDGET_START_PROC on_widget_start
262 #define PLUGIN_WIDGET_INIT_PROC on_widget_init
263 #define PLUGIN_WIDGET_STOP_PROC on_widget_stop
264 #define PLUGIN_FRAME_LOAD_PROC on_frame_load
265 #define PLUGIN_FRAME_UNLOAD_PROC on_frame_unload
266 #define PLUGIN_CLASS_MAP class_map
267 #define PLUGIN_GET_CLASS_PROC_MAP get_widget_class_map
269 #define PLUGIN_WIDGET_START_PROC_NAME "on_widget_start"
270 #define PLUGIN_WIDGET_INIT_PROC_NAME "on_widget_init"
271 #define PLUGIN_WIDGET_STOP_PROC_NAME "on_widget_stop"
272 #define PLUGIN_FRAME_LOAD_PROC_NAME "on_frame_load"
273 #define PLUGIN_FRAME_UNLOAD_PROC_NAME "on_frame_unload"
274 #define PLUGIN_CLASS_MAP_NAME "class_map"
275 #define PLUGIN_GET_CLASS_MAP_PROC_NAME "get_widget_class_map"
278 * Plugin export typedefs
280 typedef void (*on_widget_start_proc)(int widgetId);
282 typedef void (*on_widget_init_proc)(feature_mapping_interface_t *interface);
285 * FIXME: Add documentation
287 typedef void (*on_widget_stop_proc)(int widgetId);
289 typedef void (*on_frame_load_proc)(java_script_context_t context);
291 typedef void (*on_frame_unload_proc)(java_script_context_t context);
293 typedef const js_entity_definition_t* (*get_widget_entity_map_proc)();
295 #endif // WRT_PLUGIN_EXPORT_H