2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.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.
35 #define DEFAULT_PERIOD -1.0f
37 enum content_event_type {
38 CONTENT_EVENT_MOUSE_DOWN = 0x00000001, /*!< LB mouse down event for livebox */
39 CONTENT_EVENT_MOUSE_UP = 0x00000002, /*!< LB mouse up event for livebox */
40 CONTENT_EVENT_MOUSE_MOVE = 0x00000004, /*!< LB mouse move event for livebox */
41 CONTENT_EVENT_MOUSE_ENTER = 0x00000008, /*!< LB mouse enter event for livebox */
42 CONTENT_EVENT_MOUSE_LEAVE = 0x00000010, /*!< LB mouse leave event for livebox */
43 CONTENT_EVENT_MOUSE_SET = 0x00000020, /*!< LB mouse set auto event for livebox */
44 CONTENT_EVENT_MOUSE_UNSET = 0x00000040, /*!< LB mouse unset auto event for livebox */
46 CONTENT_EVENT_ACCESS_READ = 0x00000100, /*!< LB accessibility read for livebox */
47 CONTENT_EVENT_ACCESS_READ_NEXT = 0x00000200, /*!< LB accessibility read next for livebox */
48 CONTENT_EVENT_ACCESS_READ_PREV = 0x00000400, /*!< LB accessibility read prev for livebox */
49 CONTENT_EVENT_ACCESS_ACTIVATE = 0x00000800, /*!< LB accessibility activate */
50 CONTENT_EVENT_ACCESS_UP = 0x00001000, /*!< LB accessibility up */
51 CONTENT_EVENT_ACCESS_DOWN = 0x00002000, /*!< LB accessibility down */
53 CONTENT_EVENT_KEY_DOWN = 0x00100000, /*!< LB key press */
54 CONTENT_EVENT_KEY_UP = 0x00200000, /*!< LB key release */
56 CONTENT_EVENT_KEY_MASK = 0x80000000,
57 CONTENT_EVENT_ACCESS_MASK = 0x40000000,
58 CONTENT_EVENT_MOUSE_MASK = 0x20000000,
59 CONTENT_EVENT_PD_MASK = 0x10000000,
60 CONTENT_EVENT_LB_MASK = 0x00000000,
62 LB_MOUSE_DOWN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_DOWN,
63 LB_MOUSE_UP = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UP,
64 LB_MOUSE_MOVE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_MOVE,
65 LB_MOUSE_ENTER = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_ENTER,
66 LB_MOUSE_LEAVE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_LEAVE,
67 LB_MOUSE_SET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET,
68 LB_MOUSE_UNSET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET,
70 PD_MOUSE_DOWN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_DOWN,
71 PD_MOUSE_UP = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UP,
72 PD_MOUSE_MOVE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_MOVE,
73 PD_MOUSE_ENTER = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_ENTER,
74 PD_MOUSE_LEAVE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_LEAVE,
75 PD_MOUSE_SET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET,
76 PD_MOUSE_UNSET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET,
78 LB_ACCESS_READ = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_READ,
79 LB_ACCESS_READ_NEXT = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_READ_NEXT,
80 LB_ACCESS_READ_PREV = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_READ_PREV,
81 LB_ACCESS_ACTIVATE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_ACTIVATE,
82 LB_ACCESS_UP = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_UP,
83 LB_ACCESS_DOWN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_DOWN,
85 PD_ACCESS_READ = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_READ,
86 PD_ACCESS_READ_NEXT = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_READ_NEXT,
87 PD_ACCESS_READ_PREV = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_READ_PREV,
88 PD_ACCESS_ACTIVATE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_ACTIVATE,
89 PD_ACCESS_UP = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_UP,
90 PD_ACCESS_DOWN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_DOWN,
92 LB_KEY_DOWN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_DOWN,
93 LB_KEY_UP = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UP,
95 PD_KEY_DOWN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_DOWN,
96 PD_KEY_UP = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UP,
98 CONTENT_EVENT_MAX = 0xFFFFFFFF,
101 /* Exported to user app */
102 enum livebox_lb_type {
103 LB_TYPE_IMAGE = 0x01, /*!< Contents of a livebox is based on the image file */
104 LB_TYPE_BUFFER = 0x02, /*!< Contents of a livebox is based on canvas buffer(shared) */
105 LB_TYPE_TEXT = 0x04, /*!< Contents of a livebox is based on formatted text file */
106 LB_TYPE_PIXMAP = 0x08, /*!< Contens of a livebox is shared by the pixmap(depends on X) */
108 LB_TYPE_INVALID = 0xFF,
111 enum livebox_pd_type {
112 PD_TYPE_BUFFER = 0x01, /*!< Contents of a PD is based on canvas buffer(shared) */
113 PD_TYPE_TEXT = 0x02, /*!< Contents of a PD is based on formatted text file */
114 PD_TYPE_PIXMAP = 0x04, /*!< Contents of a livebox is shared by the pixmap(depends on X) */
116 PD_TYPE_INVALID = 0xFF,
119 enum livebox_event_type { /*!< livebox_event_handler_set Event list */
120 LB_EVENT_LB_UPDATED, /*!< Contents of the given livebox is updated */
121 LB_EVENT_PD_UPDATED, /*!< Contents of the given pd is updated */
123 LB_EVENT_CREATED, /*!< A new livebox is created */
124 LB_EVENT_DELETED, /*!< A livebox is deleted */
126 LB_EVENT_GROUP_CHANGED, /*!< Group (Cluster/Sub-cluster) information is changed */
127 LB_EVENT_PINUP_CHANGED, /*!< PINUP status is changed */
128 LB_EVENT_PERIOD_CHANGED, /*!< Update period is changed */
130 LB_EVENT_LB_SIZE_CHANGED, /*!< Livebox size is changed */
131 LB_EVENT_PD_SIZE_CHANGED, /*!< PD size is changed */
133 LB_EVENT_PD_CREATED, /*!< If a PD is created even if you didn't call the livebox_create_pd API */
134 LB_EVENT_PD_DESTROYED, /*!< If a PD is destroyed even if you didn't call the livebox_destroy_pd API */
136 LB_EVENT_IGNORED, /*!< Request is ignored */
139 enum livebox_fault_type {
140 LB_FAULT_DEACTIVATED, /*!< Livebox is deactivated by its fault operation */
141 LB_FAULT_PROVIDER_DISCONNECTED, /*!< Provider is disconnected */
144 enum livebox_visible_state { /*!< Must be sync'd with the provider */
145 LB_SHOW = 0x00, /*!< Livebox is showed. Default state */
146 LB_HIDE = 0x01, /*!< Livebox is hide, Update timer is not be freezed. but you cannot receive any updates events. you should refresh(reload) the content of a livebox when you make this show again */
148 LB_HIDE_WITH_PAUSE = 0x02, /*!< Livebix is hide, it will paused the update timer, but if a livebox update its contents, update event will come to you */
150 LB_VISIBLE_ERROR = 0xFFFFFFFF, /* To enlarge the size of this enumeration type */
155 * TEXT type livebox contents handling opertators.
157 struct livebox_script_operators {
158 int (*update_begin)(struct livebox *handle); /*!< Content parser is started */
159 int (*update_end)(struct livebox *handle); /*!< Content parser is stopped */
163 * Listed functions will be called when parser meets each typed component
165 int (*update_text)(struct livebox *handle, const char *id, const char *part, const char *data); /*!< Update text content */
166 int (*update_image)(struct livebox *handle, const char *id, const char *part, const char *data); /*!< Update image content */
167 int (*update_script)(struct livebox *handle, const char *id, const char *part, const char *file, const char *group); /*!< Update script content */
168 int (*update_signal)(struct livebox *handle, const char *id, const char *emission, const char *signal); /*!< Update signal */
169 int (*update_drag)(struct livebox *handle, const char *id, const char *part, double dx, double dy); /*!< Update drag info */
170 int (*update_info_size)(struct livebox *handle, const char *id, int w, int h); /*!< Update content size */
171 int (*update_info_category)(struct livebox *handle, const char *id, const char *category); /*!< Update content category info */
175 * \brief Prototype of the return callback of every async functions.
181 typedef void (*ret_cb_t)(struct livebox *handle, int ret, void *data);
184 * \brief Initialize the livebox system
188 extern int livebox_init(void *disp);
191 * \brief Finalize the livebox system
194 extern int livebox_fini(void);
197 * \brief Client is paused.
200 extern int livebox_client_paused(void);
203 * \brief Client is rfesumed.
206 extern int livebox_client_resumed(void);
209 * \brief Add a new livebox
213 * \param[in] category
219 extern struct livebox *livebox_add(const char *pkgname, const char *content, const char *cluster, const char *category, double period, ret_cb_t cb, void *data);
220 extern struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int type, ret_cb_t cb, void *data);
223 * \brief Delete a livebox
225 * \param[in] ret_cb_t return callback
226 * \param[in] data user data for return callback
229 extern int livebox_del(struct livebox *handler, ret_cb_t cb, void *data);
232 * \brief Set a livebox events callback
233 * \param[in] cb Event handler
234 * \param[in] data User data for the event handler
236 * \sa livebox_unset_event_handler
239 extern int livebox_set_event_handler(int (*cb)(struct livebox *handler, enum livebox_event_type event, void *data), void *data);
242 * \brief Unset the livebox event handler
244 * \return void * pointer of 'data' which is registered from the livebox_event_handler_set
245 * \sa livebox_set_event_handler
247 extern void *livebox_unset_event_handler(int (*cb)(struct livebox *handler, enum livebox_event_type event, void *data));
252 * event, pkgname, filename, funcname
254 * \brief Live box fault event handler registeration function
258 * \sa livebox_unset_fault_handler
260 extern int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *), void *data);
263 * \brief Unset the live box fault event handler
265 * \return pointer of 'data'
266 * \sa livebox_set_fault_handler
268 extern void *livebox_unset_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *));
271 * \brief Activate the faulted livebox.
277 extern int livebox_activate(const char *pkgname, ret_cb_t cb, void *data);
280 * \brief Resize the livebox
281 * \param[in] handler Handler of a livebox
282 * \param[in] type Type of a livebox size, LB_SIZE_TYPE_1x1, ...
283 * \param[in] cb Result callback of the resize operation.
284 * \param[in] data User data for return callback
287 extern int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data);
290 * \brief Send the click event for a livebox.
291 * \param[in] handler Handler of a livebox
292 * \param[in] x Rational X of the content width.
293 * \param[in] y Rational Y of the content height.
296 extern int livebox_click(struct livebox *handler, double x, double y);
299 * \brief Change the cluster/sub-cluster name of given livebox handler
300 * \param[in] handler Handler of a livebox
301 * \param[in] cluster New cluster of a livebox
302 * \param[in] category New category of a livebox
303 * \param[in] cb Result callback for changing the cluster/category of a livebox
304 * \param[in] data User data for the result callback
307 extern int livebox_set_group(struct livebox *handler, const char *cluster, const char *category, ret_cb_t cb, void *data);
310 * \brief Get the cluster and category(sub-cluster) name of given livebox (It is not I18N format, only english)
311 * \param[in] handler Handler of a livebox
312 * \param[out] cluster Storage(memory) for containing the cluster name
313 * \param[out] category Storage(memory) for containing the category name
316 extern int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category);
319 * \brief Get the period of this livebox handler
320 * \param[in] handler Handler of a livebox
321 * \return double Current update period of a livebox
323 extern double livebox_period(struct livebox *handler);
326 * \brief Change the update period
327 * \param[in] handler Handler of a livebox
328 * \param[in] period New update period of a livebox
329 * \param[in] cb Result callback of changing the update period of this livebox
330 * \param[in] data User data for the result callback
333 extern int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, void *data);
336 * \brief Is this an text type livebox?
338 * \return content_type
340 extern enum livebox_lb_type livebox_lb_type(struct livebox *handler);
343 * \brief Is this livebox is created by a user?
347 extern int livebox_is_user(struct livebox *handler);
350 * \brief Get the content information string of given livebox
354 extern const char *livebox_content(struct livebox *handler);
357 * \brief Get the sub cluster title string of given livebox
359 * \return sub cluster title
361 extern const char *livebox_category_title(struct livebox *handler);
364 * \brief Get the filename of given livebox, if it is an IMAGE type livebox
368 extern const char *livebox_filename(struct livebox *handler);
371 * \brief Get the package name of given livebox handler
375 extern const char *livebox_pkgname(struct livebox *handler);
378 * \brief Get the priority of a current content.
382 extern double livebox_priority(struct livebox *handler);
385 * \brief Acquire the buffer of given livebox (Only for the buffer type)
387 * \return address of a FB
389 extern void *livebox_acquire_fb(struct livebox *handler);
392 * \brief Release the buffer of a livebox (Only for the buffer type)
396 extern int livebox_release_fb(void *buffer);
399 * \brief Get the reference count of Livebox buffer (Only for the buffer type)
403 extern int livebox_fb_refcnt(void *buffer);
406 * \brief Acquire the buffer of a PD frame (Only for the buffer type)
410 extern void *livebox_acquire_pdfb(struct livebox *handler);
413 * \brief Release the acquired buffer of the PD Frame (Only for the buffer type)
417 extern int livebox_release_pdfb(void *buffer);
420 * \brief Reference count of given PD buffer (Only for the buffer type)
424 extern int livebox_pdfb_refcnt(void *buffer);
427 * \brief Get the size of the Livebox
433 extern int livebox_size(struct livebox *handler);
436 * \brief Get the size of the Progressive Disclosure
442 extern int livebox_get_pdsize(struct livebox *handler, int *w, int *h);
445 * \brief List of supported sizes of given handler
452 extern int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list);
455 * \brief BUFFER SIZE of the livebox if it is a buffer type
459 extern int livebox_lbfb_bufsz(struct livebox *handler);
462 * \brief BUFFER SIZE of the progiressive disclosure if it is a buffer type
466 extern int livebox_pdfb_bufsz(struct livebox *handler);
469 * \brief Send the content event (for buffer type) to provider(livebox)
475 extern int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y);
478 * \brief Do pin up or not.
485 extern int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void *data);
488 * \brief Check the PIN-UP status of given handler
492 extern int livebox_is_pinned_up(struct livebox *handler);
495 * \brief Check the PINUP feature availability of the given handler
499 extern int livebox_has_pinup(struct livebox *handler);
502 * \brief Check the PD existence of given handler
506 extern int livebox_has_pd(struct livebox *handler);
509 * \brief Create the PD of given handler
515 extern int livebox_create_pd(struct livebox *handler, ret_cb_t cb, void *data);
518 * \brief Create the PD of given handler with the relative position from livebox
520 * \param[in] x 0.0 ~ 1.0
521 * \param[in] y 0.0 ~ 1.0
526 extern int livebox_create_pd_with_position(struct livebox *handler, double x, double y, ret_cb_t cb, void *data);
529 * \brief PD position is updated.
531 * \param[in] x 0.0 ~ 1.0
532 * \param[in] y 0.0 ~ 1.0
533 * \return int 0 if succeed to send request for updating position of the PD.
535 extern int livebox_move_pd(struct livebox *handler, double x, double y);
538 * \brief Destroy the PD of given handler if it is created.
544 extern int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data);
547 * \brief Check the create status of given livebox handler
551 extern int livebox_pd_is_created(struct livebox *handler);
554 * \brief Check the content type of the progressive disclosure of given handler
558 extern enum livebox_pd_type livebox_pd_type(struct livebox *handler);
561 * \brief Check the existence of a livebox about given package name
565 extern int livebox_is_exists(const char *pkgname);
568 * \brief Set function table for parsing the text content of a livebox
573 extern int livebox_set_text_handler(struct livebox *handler, struct livebox_script_operators *ops);
576 * \brief Set function table for parsing the text content of a Progressive Disclosure
581 extern int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_script_operators *ops);
584 * \brief Emit a text signal to given livebox only if it is a text type.
586 * \param[in] emission
595 extern int livebox_emit_text_signal(struct livebox *handler, const char *emission, const char *source, double sx, double sy, double ex, double ey, ret_cb_t cb, void *data);
598 * \brief Set a private data pointer to carry it using given handler
603 extern int livebox_set_data(struct livebox *handler, void *data);
606 * \brief Get private data pointer which is carried by given handler
610 extern void *livebox_get_data(struct livebox *handler);
613 * \brief Subscribe the event for liveboxes only in given cluster and sub-cluster
614 * \param[in] cluster "*" can be used for subscribe all cluster's liveboxes event.
615 * If you use the "*", value in the category will be ignored.
616 * \param[in] category "*" can be used for subscribe liveboxes events of all category(sub-cluster) in given "cluster"
617 * \return int Success 0, fails error code
619 extern int livebox_subscribe_group(const char *cluster, const char *category);
622 * \brief Unsubscribe the event for the liveboxes, but you will receive already added liveboxes event.
623 * \param[in] cluster "*" can be used for subscribe all cluster's liveboxes event.
624 * If you use the "*", value in the category will be ignored.
625 * \param[in] category "*" can be used for subscribe all sub-cluster's liveboxes event in given "cluster"
626 * \return int Success 0, fails error code
628 extern int livebox_unsubscribe_group(const char *cluster, const char *category);
631 * \brief Refresh the group(cluster/sub-cluser(aka. category))
632 * \param[in] cluster Cluster ID
633 * \param[in] category Sub-cluster ID
634 * \return int Success 0 or negative value
636 extern int livebox_refresh_group(const char *cluster, const char *category);
639 * \brief Refresh a livebox
641 * \return int Success 0 or negative value
643 extern int livebox_refresh(struct livebox *handler);
646 * \brief Pixmap Id of a livebox content
649 * \sa livebox_pd_pixmap
651 extern int livebox_lb_pixmap(const struct livebox *handler);
654 * \brief Pixmap Id of a PD content
657 * \sa livebox_lb_pixmap
659 extern int livebox_pd_pixmap(const struct livebox *handler);
667 * \sa livebox_release_pd_pixmap
668 * \sa livebox_acquire_lb_pixmap
670 extern int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void *data);
673 * \brief Release the acquired pixmap ID
677 * \sa livebox_acquire_pd_pixmap
678 * \sa livebox_release_lb_pixmap
680 extern int livebox_release_pd_pixmap(struct livebox *handler, int pixmap);
688 * \sa livebox_release_lb_pixmap
689 * \sa livebox_acquire_pd_pixmap
691 extern int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data);
698 * \sa livebox_acquire_lb_pixmap
699 * \sa livebox_release_pd_pixmap
701 extern int livebox_release_lb_pixmap(struct livebox *handler, int pixmap);
704 * \brief Update the visible state of a livebox
705 * \param[in] handler Handler of a livebox
706 * \param[in] state Configure the current visible state of a livebox
709 extern int livebox_set_visibility(struct livebox *handler, enum livebox_visible_state state);
712 * \brief Current visible state of a livebox
713 * \param[in] handler Handler of a livebox
714 * \return enum visible state
716 extern enum livebox_visible_state livebox_visibility(struct livebox *handler);