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
26 #include <dpl/wrt-dao-ro/wrt_db_types.h>
31 typedef int widget_handle_t;
34 * Parameter which should be used during policy evaluation.
36 typedef struct ace_param_s
43 * List of additional parameters which should be used during policy evaluation.
45 typedef struct ace_param_list_s
52 * Contains list of device capabilities. Each device capability may have
53 * associated list of function params.
55 typedef struct ace_device_cap_s
58 const char** dev_cap_names;
60 ace_param_list_t* params;
64 * List of device capabilities which must be check.
66 typedef struct ace_device_capabilities_s
69 const char **device_cap;
70 } ace_device_capabilities_t;
73 * List of api features that must be checked
75 typedef struct ace_api_features_s
78 const char **api_feature;
82 * Data from request will be used to evaluate policy file.
84 typedef struct ace_request_s
86 widget_handle_t widget_handle;
87 const char* feature_api;
88 const char* function_name;
89 ace_device_capabilities_t device_capabilities;
90 ace_param_list_t param_list;
94 * Data from request will be used to evaluate policy file.
96 typedef struct ace_request_2_s
98 widget_handle_t widget_handle;
99 ace_api_features_t api_features;
100 const char* function_name;
101 ace_device_cap_t device_capabilities;
105 * info returned by plugin_api_check_access
107 #define PLUGIN_API_ACCESS_GRANTED 1
108 #define PLUGIN_API_ACCESS_DENIED 0
109 #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,
129 typedef enum class_definition_type_e
134 } class_definition_type_t;
136 typedef enum class_definition_iframe_behaviour_e
138 //object should not be initalized in iframes
141 //object should be copied as reference to each iframe
142 REFERENCE, // deprecated
143 //object should be created for each iframe and NOT inform plugin
145 } class_definition_iframe_behaviour_t;
147 typedef enum class_definition_iframe_notice_e
152 } class_definition_iframe_notice_t;
154 typedef enum class_definition_iframe_overlay_e
157 USE_OVERLAYED, //deprecated
158 OVERLAYED_BEFORE_ORIGINAL //deprecated
159 } class_definition_iframe_overlay_t; //deprecated
161 typedef void* js_object_instance_t;
162 //global_context - id
163 typedef void (*iframe_loaded_cb)(java_script_context_t global_context,
164 js_object_instance_t iframe,
165 js_object_instance_t object);
167 typedef void* (*js_function_impl)(void*);
169 typedef struct class_definition_options_s
171 class_definition_type_t type;
172 class_definition_iframe_behaviour_t iframe_option;
173 class_definition_iframe_notice_t iframe_notice;
174 class_definition_iframe_overlay_t iframe_overlay; //deprecated
177 js_function_impl function;
178 } 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;
207 typedef feature_mapping_t* pfeature_mapping_t;
209 typedef pfeature_mapping_t (*features_getter)(void);
211 typedef const devcaps_t* (*devcaps_getter)(pfeature_mapping_t /*features*/,
212 const char* /*featureName*/);
213 typedef void (*deinitializer)(pfeature_mapping_t /*features*/);
215 typedef struct feature_mapping_interface_s
217 features_getter featGetter; /* returns a list of api features */
218 devcaps_getter dcGetter; /*
219 * for a given api feature returns a list of
220 * corresponding device capabilities
223 deinitializer release; /* as memory ownership of features is
224 * transfered to callee you have to call
225 * the release function ptr on features
227 } feature_mapping_interface_t;
230 * This is a structure describing a JS entity template (a class, an interface
231 * or function), object name and it's parent class name (parent_name). JS
232 * entity will be bind to a parent class name (parent_name.js_entity_name).
233 * @param parent_name - parent name (ie Widget.Device)
234 * @param object_name - object name (DeviceStatus)
235 * @param interface_name - interface name (e.g. Widget)
236 * @param js_class_template_getter_fun - js_class_template required to create
238 * @param js_class_consturctor_cb - constructor to call to when instance of
239 * certain interface is created
240 * @param private_data private data for object creator if required (usually
243 typedef struct js_entity_definition_s
245 const char *parent_name;
246 const char *object_name;
247 const char *interface_name;
248 js_class_template_getter js_class_template_getter_fun;
249 js_class_constructor_cb_t js_class_constructor_cb;
250 //class options may be null - default
251 class_definition_options_t* class_options;
252 } js_entity_definition_t;
254 typedef const js_entity_definition_t *js_entity_definition_ptr_t;
257 * Plugin export names
259 #define PLUGIN_WIDGET_START_PROC on_widget_start
260 #define PLUGIN_WIDGET_INIT_PROC on_widget_init
261 #define PLUGIN_WIDGET_STOP_PROC on_widget_stop
262 #define PLUGIN_FRAME_LOAD_PROC on_frame_load
263 #define PLUGIN_FRAME_UNLOAD_PROC on_frame_unload
264 #define PLUGIN_CLASS_MAP class_map
265 #define PLUGIN_GET_CLASS_PROC_MAP get_widget_class_map
267 #define PLUGIN_WIDGET_START_PROC_NAME "on_widget_start"
268 #define PLUGIN_WIDGET_INIT_PROC_NAME "on_widget_init"
269 #define PLUGIN_WIDGET_STOP_PROC_NAME "on_widget_stop"
270 #define PLUGIN_FRAME_LOAD_PROC_NAME "on_frame_load"
271 #define PLUGIN_FRAME_UNLOAD_PROC_NAME "on_frame_unload"
272 #define PLUGIN_CLASS_MAP_NAME "class_map"
273 #define PLUGIN_GET_CLASS_MAP_PROC_NAME "get_widget_class_map"
276 * Plugin export typedefs
278 typedef void (*on_widget_start_proc)(WidgetHandle widgetId);
280 typedef void (*on_widget_init_proc)(feature_mapping_interface_t *interface);
283 * FIXME: Add documentation
285 typedef void (*on_widget_stop_proc)(WidgetHandle widgetId);
287 typedef void (*on_frame_load_proc)(java_script_context_t context);
289 typedef void (*on_frame_unload_proc)(java_script_context_t context);
291 typedef const js_entity_definition_t* (*get_widget_entity_map_proc)();
293 #endif // WRT_PLUGIN_EXPORT_H