2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 #ifndef __LIVEBOX_HELPER_PRODUCT_H
18 #define __LIVEBOX_HELPER_PRODUCT_H
25 * @file livebox_product.h
26 * @brief This file declares API of liblivebox library for product
30 * @addtogroup CAPI_LIVEBOX_HELPER_PRODUCT_MODULE
35 * @brief Structure for a livebox buffer defined by a provider.
37 struct livebox_buffer;
39 extern const int DONE; /**<Return values of livebox programming interfaces: Operation is successfully done.*/
41 extern const int OUTPUT_UPDATED; /**<Return values of livebox programming interfaces: Contents are updated.*/
43 extern const int NEED_TO_SCHEDULE; /**<Return values of livebox programming interfaces: Need to call the livebox_need_to_update and livebox_update_content.*/
45 extern const int FORCE_TO_SCHEDULE; /**<Return values of livebox programming interfaces: Need to do force update.*/
47 extern const int NEED_TO_CREATE; /**<Return values of livebox programming interfaces: Need to create a new instance.*/
49 extern const int NEED_TO_DESTROY; /**<Return values of livebox programming interfaces: Need to destroy this instance.*/
51 extern const int NEED_TO_UPDATE; /**<Return values of livebox programming interfaces: Need to update.*/
53 extern const int USE_NET; /**<Return values of livebox programming interfaces: Using network.*/
55 extern const int LB_SYS_EVENT_FONT_CHANGED; /**<System event type: System font is changed.*/
57 extern const int LB_SYS_EVENT_LANG_CHANGED; /**<System event type: System language is changed.*/
59 extern const int LB_SYS_EVENT_TIME_CHANGED; /**<System event type: System time is changed.*/
61 extern const int LB_SYS_EVENT_REGION_CHANGED; /**<System event type: Region changed. */
63 extern const int LB_SYS_EVENT_TTS_CHANGED; /**< System event type: Accessibility changed. */
65 extern const int LB_SYS_EVENT_PAUSED; /**<System event type: Livebox is paused.*/
67 extern const int LB_SYS_EVENT_RESUMED; /**<System event type: Livebox is resumed.*/
69 extern const int LB_SYS_EVENT_MMC_STATUS_CHANGED; /**<System event type: MMC Status change event.*/
71 extern const int LB_SYS_EVENT_DELETED;/**<System event type: Livebox instance is removed from a viewer.*/
74 * @brief Structure for extra event information for livebox_content_event interface function.
76 #if !defined(__SCRIPT_EVENT_INFO)
77 #define __SCRIPT_EVENT_INFO
80 * Text signal & Content event uses this data structure.
84 double x; /**< X value of current mouse(touch) position */
85 double y; /**< Y value of current mouse(touch) position */
86 int down; /**< Is it pressed(1) or not(0) */
90 double sx; /**< Pressed object's left top X */
91 double sy; /**< Pressed object's left top Y */
92 double ex; /**< Pressed object's right bottom X */
93 double ey; /**< Pressed object's right bottom Y */
99 * @brief Notifies the updated content to the provider.
100 * @details Forcedly notifies the updated contents.
101 * This function can be used from async callback function to notify the updated content.
102 * @param[in] id Instance Id which is passed to you via the first parameter of every livebox_XXXX interface functions
103 * @param[in] is_pd 1 for updating content of PD or 0(for content of LB)
106 * @retval #LB_STATUS_ERROR_MEMORY Not enough memory
107 * @retval #LB_STATUS_ERROR_INVALID Invalid argument
108 * @retval #LB_STATUS_ERROR_IO I/O failed, Cannot access given resource file(id)
109 * @retval #LB_STATUS_SUCCESS Successfully notified
110 * @pre This API only can be used after loaded into the data-provider-slave process.
112 extern int livebox_content_is_updated(const char *id, int is_pd);
115 * @brief Replaces "\n" (new line character) with <br> tag.
116 * @details This utility function is used to replace all NEW LINE CHARACTER ("\n") with <br> tag.
117 * @param[in] str Source string
119 * @return char * type
120 * @retval string Allocted in the heap
121 * @retval @c NULL If it fails to replace string
122 * @post Returned string must has to be free'd by user manually.
124 extern char *livebox_util_nl2br(const char *str);
127 * Interfaces for direct buffer management (Available only for the PD area).
129 #ifndef __PROVIDER_BUFFER_H
131 * @brief Enumeration for value should be sync'd with provider.
134 BUFFER_EVENT_ENTER, /**< Mouse cursor enter */
135 BUFFER_EVENT_LEAVE, /**< Mouse cursor leave */
136 BUFFER_EVENT_DOWN, /**< Mouse down */
137 BUFFER_EVENT_MOVE, /**< Mouse move */
138 BUFFER_EVENT_UP, /**< Mouse up */
140 BUFFER_EVENT_KEY_DOWN, /**< Key down */
141 BUFFER_EVENT_KEY_UP, /**< Key up */
142 BUFFER_EVENT_KEY_FOCUS_IN, /**< Key focus in */
143 BUFFER_EVENT_KEY_FOCUS_OUT, /**< Key focus out */
145 BUFFER_EVENT_HIGHLIGHT, /**< Accessibility - Highlight */
146 BUFFER_EVENT_HIGHLIGHT_NEXT, /**< Accessibility - Move highlight to next */
147 BUFFER_EVENT_HIGHLIGHT_PREV, /**< Accessibility - Move highlight to prev */
148 BUFFER_EVENT_ACTIVATE, /**< Accessibility - Activate the highlighted object */
149 BUFFER_EVENT_ACTION_UP, /**< Accessibility - Make UP action */
150 BUFFER_EVENT_ACTION_DOWN, /**< Accessibility - Make Down action */
151 BUFFER_EVENT_SCROLL_UP, /**< Accessibility - Scroll up */
152 BUFFER_EVENT_SCROLL_MOVE, /**< Accessibility - Scroll move */
153 BUFFER_EVENT_SCROLL_DOWN, /**< Accessibility - Scroll down */
154 BUFFER_EVENT_UNHIGHLIGHT, /**< Accessibility - Remove highlight */
156 BUFFER_EVENT_ON_HOLD, /**< To prevent from generating mouse clicked event */
157 BUFFER_EVENT_OFF_HOLD, /**< Stopped holding. */
158 BUFFER_EVENT_ON_SCROLL, /**< On scrolling */
159 BUFFER_EVENT_OFF_SCROLL, /**< Scrolling stopped */
161 /* Accessibility event */
162 BUFFER_EVENT_VALUE_CHANGE,
171 struct buffer_event_data {
172 enum buffer_event type; /**< Mouse, Keyboard, Accessibility event type */
173 double timestamp; /**< Timestamp of events */
177 int x; /**< If the event type is for accessibility or mouse, coordinates of X for pointer */
178 int y; /**< If the event type is for accessibility or mouse, coordinates of Y for pointer */
184 unsigned int mouse_type;
185 unsigned int action_type;
186 unsigned int action_by;
190 unsigned int keycode; /**< If the event type is for keyboard, the value of keycode */
196 * @brief Acquires a buffer for PD or LB, currently only the PD is supported.
197 * @param[in] id Instance Id which is passed to you via the first parameter of every livebox_XXXX interface functions
198 * @param[in] is_pd 1 for PD or 0 for livebox
199 * @param[in] width Width in pixel
200 * @param[in] height Height in pixel
201 * @param[in] pixels Size of a pixel in bytes
202 * @param[in] handler Event handling callback
203 * @param[in] data User data for event handling callback
204 * @privlevel platform
205 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
206 * @return Buffer handle
207 * @retval @c NULL Failed to acquire buffer
208 * @retval handler Handle object
209 * @pre Given instance must be specify its type as buffer. or this API will be fail.
210 * @post Allocated buffer object must be released via livebox_release_buffer().
211 * @see livebox_acquire_buffer()
213 extern struct livebox_buffer *livebox_acquire_buffer(const char *id, int is_pd, int width, int height, int pixels, int auto_align, int (*handler)(struct livebox_buffer *, struct buffer_event_data *, void *), void *data);
216 * @brief Acquires the ID of pixmap resource.
217 * @details Only if the provider uses pixmap for providing render buffer.
218 * @remarks Pixmap Id can be destroyed if you call the livebox_release_buffer(). Then this pixmap Id is not guaranteed to use.
219 * @param[in] handle Buffer handle
221 * @return unsigned log type
222 * @retval positive Pixmap Id
223 * @retval 0 Failed to get pixmap Id
224 * @pre The system must be set to use the pixmap method for content sharing.
225 * @see livebox_acquire_buffer()
227 extern unsigned long livebox_pixmap_id(struct livebox_buffer *handle);
230 * @brief Releases the buffer of livebox.
231 * @param[in] handle Buffer handle
232 * @privlevel platform
233 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
235 * @retval #LB_STATUS_ERROR_INVALID Invalid argument
236 * @retval #LB_STATUS_SUCCESS Successfully released
237 * @pre Handle must be created using livebox_acquire_buffer().
238 * @see livebox_acquire_buffer()
240 extern int livebox_release_buffer(struct livebox_buffer *handle);
243 * @brief Gets the address of S/W render buffer.
244 * @details If you try to use this, after livebox_create_hw_buffer(), you will get @c NULL.
245 * @param[in] handle Buffer handle
246 * @privlevel platform
247 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
248 * @return void* address of the render buffer
249 * @retval @c NULL If it falis to get buffer address
250 * @retval address If it succeed to get the buffer address
251 * @see livebox_unref_buffer()
253 extern void *livebox_ref_buffer(struct livebox_buffer *handle);
256 * @brief Releases the S/W render buffer.
257 * @param[in] buffer Address of render buffer
258 * @privlevel platform
259 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
261 * @retval #LB_STATUS_ERROR_INVALID Invalid handle
262 * @retval #LB_STATUS_SUCCESS Successfully unreference
263 * @pre livebox_ref_buffer() must be called.
264 * @see livebox_ref_buffer()
266 extern int livebox_unref_buffer(void *buffer);
269 * @brief Synchronizes the updated buffer.
270 * @details This is only needed for non-H/W accelerated buffer.
271 * @param[in] handle Buffer handle
272 * @privlevel platform
273 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
275 * @retval #LB_STATUS_SUCCESS Successfully sync'd
276 * @retval #LB_STATUS_ERROR_INVALID Invalid argument
277 * @see livebox_acquire_buffer()
279 extern int livebox_sync_buffer(struct livebox_buffer *handle);
282 * @brief Requests to schedule the update operation to a provider.
283 * @param[in] id Instance Id which is passed to you via the first parameter of every livebox_XXXX interface functions
284 * @privlevel platform
285 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
286 * @return If succes returns 0 or return less than 0
287 * @retval #LB_STATUS_SUCCESS Successfully triggered
288 * @retval #LB_STATUS_ERROR_INVALID Invalid argument
289 * @retval #LB_STATUS_ERROR_MEMORY Not enough memory
290 * @retval #LB_STATUS_ERROR_NOT_EXIST Given id instance is not exist
292 extern int livebox_request_update(const char *id);
295 * @brief Checks whether the livebox supports H/W acceleration or not.
296 * @param[in] handle Buffer handle
299 * @retval 1 If the buffer handle support the H/W acceleration buffer
300 * @retval 0 If it doesn not supported
301 * @see livebox_acquire_buffer()
303 extern int livebox_support_hw_buffer(struct livebox_buffer *handle);
306 * @brief Creates the H/W accelerated buffer.
307 * @param[in] handle Buffer handle
308 * @privlevel platform
309 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
311 * @retval #LB_STATUS_ERROR_ALREADY H/W buffer is already created
312 * @retval #LB_STATUS_ERROR_INVALID Invalid argument
313 * @retval #LB_STATUS_SUCCESS Successfully created
314 * @pre Must be checked whether the H/W buffer is supported or not.
315 * @post Must be destroyed if it is not necessary.
316 * @see livebox_support_hw_buffer()
318 extern int livebox_create_hw_buffer(struct livebox_buffer *handle);
321 * @brief Destroys the H/W accelerated buffer.
322 * @param[in] handle Buffer handle
323 * @privlevel platform
324 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
326 * @retval #LB_STATUS_SUCCESS Successfully destroyed
327 * @retval #LB_STATUS_ERROR_INVALID Invalid argument
328 * @pre Must be created h/w buffer using livebox_create_hw_buffer.
329 * @see livebox_create_hw_buffer()
331 extern int livebox_destroy_hw_buffer(struct livebox_buffer *handle);
334 * @brief Gets the address of the accelerated H/W buffer.
335 * @param[in] handle Buffer handle
336 * @privlevel platform
337 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
339 * @retval @c NULL Failed to get H/W accelerated buffer address
340 * @retval addr H/W accelerated buffer address
341 * @see livebox_create_hw_buffer()
343 extern void *livebox_buffer_hw_buffer(struct livebox_buffer *handle);
346 * @brief Get the stride information from the buffer info
347 * @param[in] handle Buffer handle
349 * @return int stride size
350 * @retval positive_value length of stride
351 * @return LB_STATUS_ERROR_INVALID Invalid parameter
352 * @return LB_STATUS_ERROR_FAULT Unrecoverable error
353 * @see livebox_create_hw_buffer()
355 extern int livebox_buffer_stride(struct livebox_buffer *handle);
358 * @brief Pre-processes for rendering content.
359 * @details This is only needed for accessing H/W accelerated buffer.
360 * @param[in] handle Buffer handle
361 * @privlevel platform
362 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
364 * @retval #LB_STATUS_ERROR_INVALID Invalid handle
365 * @retval #LB_STATUS_SUCCESS Successfully done
366 * @post livebox_buffer_post_render must be called after the rendering (accessing buffer) is completed.
367 * @see livebox_support_hw_buffer()
368 * @see livebox_buffer_post_render()
370 extern int livebox_buffer_pre_render(struct livebox_buffer *handle);
373 * @brief Post-processes for rendering content.
374 * @param[in] handle Buffer handle
375 * @privlevel platform
376 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
377 * @return If succes returns 0 or return less than 0
378 * @retval #LB_STATUS_SUCCESS If succeed
379 * @retval #LB_STATUS_ERROR_INVALID Invalid argument
380 * @pre livebox_buffer_pre_render must be called.
381 * @see livebox_support_hw_buffer()
382 * @see livebox_buffer_pre_render()
384 extern int livebox_buffer_post_render(struct livebox_buffer *handle);
387 * @brief Sends a request to the viewer (homescreen) to close the PD.
388 * @details Even though you call this function. the homescreen can ignore it.
389 * @param[in] pkgname Livebox Package Id
390 * @param[in] id Instance Id which is passed to you via the first parameter of every livebox_XXXX interface functions
391 * @param[in] reason LB_STATUS_SUCCESS(0)
392 * @privlevel platform
393 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
395 * @retval #LB_STATUS_ERROR_INVALID Invalid parameters
396 * @retval #LB_STATUS_ERROR_MEMORY Out of memory
397 * @retval #LB_STATUS_ERROR_FAULT Failed to send a request
398 * @retval #LB_STATUS_SUCCESS Successfully requested
400 extern int livebox_request_close_pd(const char *pkgname, const char *id, int reason);
403 * @brief Send a freeze request to the viewer (homescreen)
405 * The viewer will get this request via event callback.
406 * Then it should freeze its scroller or stop moving the livebox.
407 * @remarks If the viewer doesn't care this request, this will has no effect.
408 * @param[in] pkgname Livebox Package Id
409 * @param[in] id Instance Id which is passed to you via the first parameter of every livebox_XXXX interface functions
410 * @privlevel platform
411 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
413 * @retval #LB_STATUS_ERROR_INVALID Invalid parameters
414 * @retval #LB_STATUS_ERROR_MEMORY Out of memory
415 * @retval #LB_STATUS_ERROR_FAULT Failed to send requet
416 * @retval #LB_STATUS_SUCCESS Successfully requested
417 * @see livebox_release_scroller()
419 extern int livebox_freeze_scroller(const char *pkgname, const char *id);
422 * @brief Send a release request to the viewer (homescreen)
424 * The viewer will get this request via event callback.
425 * Then it should release its scroller or continue moving the livebox.
426 * @remarks If the viewer doesn't care this request, this will has no effect.
427 * @param[in] pkgname Livebox Package Id
428 * @param[in] id Instance Id which is passed to you via the first parameter of every livebox_XXXX interface functions
429 * @privlevel platform
430 * @privilege %http://developer.samsung.com/privilege/core/dynamicbox.provider
432 * @retval #LB_STATUS_ERROR_INVALID Invalid parameters
433 * @retval #LB_STATUS_ERROR_MEMORY Out of memory
434 * @retval #LB_STATUS_ERROR_FAULT Failed to send requet
435 * @retval #LB_STATUS_SUCCESS Successfully requested
436 * @see livebox_freeze_scroller()
438 extern int livebox_release_scroller(const char *pkgname, const char *id);
441 * @brief Get the configuration value for premultiplied alpha.
443 * If the system uses the premultiplied alpha for content,
444 * This function will returns 1.
445 * @remarks This function only works with the inhouse provider.
447 * @return status of premultiplied alpha.
448 * @retval 1 Content rendered with premultiplied alpha.
449 * @retval 0 Content doesn't rendered with premultiplied alpha.
451 extern int livebox_conf_premultiplied_alpha(void);
454 * @brief Get the configuration value for AUTO Alignment of canvas buffer.
456 * If the UIFW does not support the STRIDE information for rendering frame,
457 * This function will returns 1, then the livebox will automatically aligning the buffer.
459 * @return status of auto alignment.
460 * @retval 1 Content will be automatically aligned by livebox.
461 * @retval 0 Content will be aligned by UIFW, using stride information.
463 extern int livebox_conf_auto_align(void);