+EAPI int livebox_sync_lb_fb(struct livebox *handler)
+{
+ if (!handler || handler->state != CREATE) {
+ ErrPrint("Invalid handle\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common || handler->common->state != CREATE) {
+ ErrPrint("Invalid handle\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common->id) {
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ return lb_sync_lb_fb(handler->common);
+}
+
+int lb_sync_lb_fb(struct livebox_common *common)
+{
+ int ret;
+
+ if (fb_type(lb_get_lb_fb(common)) == BUFFER_TYPE_FILE && common->lb.lock_fd >= 0) {
+ (void)do_fb_lock(common->lb.lock_fd);
+ ret = fb_sync(lb_get_lb_fb(common));
+ (void)do_fb_unlock(common->lb.lock_fd);
+ } else {
+ ret = fb_sync(lb_get_lb_fb(common));
+ }
+
+ return ret;
+}
+
+int lb_sync_pd_fb(struct livebox_common *common)
+{
+ int ret;
+
+ if (fb_type(lb_get_pd_fb(common)) == BUFFER_TYPE_FILE && common->pd.lock_fd >= 0) {
+ (void)do_fb_lock(common->pd.lock_fd);
+ ret = fb_sync(lb_get_pd_fb(common));
+ (void)do_fb_unlock(common->pd.lock_fd);
+ } else {
+ ret = fb_sync(lb_get_pd_fb(common));
+ }
+
+ return ret;
+}
+
+EAPI int livebox_sync_pd_fb(struct livebox *handler)
+{
+ if (!handler || handler->state != CREATE) {
+ ErrPrint("Invalid handle\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common || handler->common->state != CREATE) {
+ ErrPrint("Invalid handle\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handle\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ return lb_sync_pd_fb(handler->common);
+}
+
+EAPI const char *livebox_alt_icon(struct livebox *handler)
+{
+ if (!handler || handler->state != CREATE) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return NULL;
+ }
+
+ return handler->common->alt.icon;
+}
+
+EAPI const char *livebox_alt_name(struct livebox *handler)
+{
+ if (!handler || handler->state != CREATE) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return NULL;
+ }
+
+ return handler->common->alt.name;
+}
+
+EAPI int livebox_acquire_fb_lock(struct livebox *handler, int is_pd)
+{
+ int ret = LB_STATUS_SUCCESS;
+ int fd;
+
+ if (!handler || handler->state != CREATE) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common || handler->common->state != CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (is_pd) {
+ if (!handler->common->pd.lock || handler->common->pd.lock_fd < 0) {
+ DbgPrint("Lock: %s (%d)\n", handler->common->pd.lock, handler->common->pd.lock_fd);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (fb_type(lb_get_pd_fb(handler->common)) == BUFFER_TYPE_FILE) {
+ return LB_STATUS_SUCCESS;
+ }
+
+ fd = handler->common->pd.lock_fd;
+ } else {
+ if (!handler->common->lb.lock || handler->common->lb.lock_fd < 0) {
+ DbgPrint("Lock: %s (%d)\n", handler->common->lb.lock, handler->common->lb.lock_fd);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (fb_type(lb_get_lb_fb(handler->common)) == BUFFER_TYPE_FILE) {
+ return LB_STATUS_SUCCESS;
+ }
+
+ fd = handler->common->lb.lock_fd;
+ }
+
+ ret = do_fb_lock(fd);
+
+ return ret == 0 ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_FAULT;
+}
+
+EAPI int livebox_release_fb_lock(struct livebox *handler, int is_pd)
+{
+ int ret = LB_STATUS_SUCCESS;
+ int fd;
+
+ if (!handler || handler->state != CREATE) {
+ ErrPrint("Invalid handle\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common || handler->common->state != CREATE) {
+ ErrPrint("Invalid handle\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (is_pd) {
+ if (!handler->common->pd.lock || handler->common->pd.lock_fd < 0) {
+ DbgPrint("Unlock: %s (%d)\n", handler->common->pd.lock, handler->common->pd.lock_fd);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (fb_type(lb_get_pd_fb(handler->common)) == BUFFER_TYPE_FILE) {
+ return LB_STATUS_SUCCESS;
+ }
+
+ fd = handler->common->pd.lock_fd;
+ } else {
+ if (!handler->common->lb.lock || handler->common->lb.lock_fd < 0) {
+ DbgPrint("Unlock: %s (%d)\n", handler->common->lb.lock, handler->common->lb.lock_fd);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (fb_type(lb_get_lb_fb(handler->common)) == BUFFER_TYPE_FILE) {
+ return LB_STATUS_SUCCESS;
+ }
+
+ fd = handler->common->lb.lock_fd;
+ }
+
+ ret = do_fb_unlock(fd);
+
+ return ret == 0 ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_FAULT;
+}
+
+EAPI int livebox_set_option(enum livebox_option_type option, int state)
+{
+ int ret = LB_STATUS_SUCCESS;
+
+ switch (option) {
+ case LB_OPTION_MANUAL_SYNC:
+ conf_set_manual_sync(state);
+ break;
+ case LB_OPTION_FRAME_DROP_FOR_RESIZE:
+ conf_set_frame_drop_for_resizing(state);
+ break;
+ case LB_OPTION_SHARED_CONTENT:
+ conf_set_shared_content(state);
+ break;
+ default:
+ ret = LB_STATUS_ERROR_INVALID;
+ break;
+ }
+
+ return ret;
+}
+
+EAPI int livebox_option(enum livebox_option_type option)
+{
+ int ret;
+
+ switch (option) {
+ case LB_OPTION_MANUAL_SYNC:
+ ret = conf_manual_sync();
+ break;
+ case LB_OPTION_FRAME_DROP_FOR_RESIZE:
+ ret = conf_frame_drop_for_resizing();
+ break;
+ case LB_OPTION_SHARED_CONTENT:
+ ret = conf_shared_content();
+ break;
+ default:
+ ret = LB_STATUS_ERROR_INVALID;
+ break;
+ }
+
+ return ret;
+}
+
+EAPI int livebox_set_auto_launch_handler(int (*launch_handler)(struct livebox *handler, const char *appid, void *data), void *data)
+{
+ s_info.launch.handler = launch_handler;
+ s_info.launch.data = data;
+
+ return LB_STATUS_SUCCESS;
+}
+