From: Sung-jae Park Date: Thu, 21 Feb 2013 10:58:07 +0000 (+0000) Subject: Add new resized event type. X-Git-Tag: 2.1b_release~12^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=ee66d255c33d3cb90a739c3a848c5f6f3dda88a3;p=platform%2Fframework%2Fweb%2Flivebox-viewer.git Add new resized event type. Client tries to use the width & height value when it gots the resize done event callback. So I change it to work like what they expected. Change-Id: I63e8da340cff685281b3927ba8cbbefd68fde111 --- diff --git a/include/livebox.h b/include/livebox.h index daaf920..b8a6951 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -121,6 +121,9 @@ enum livebox_event_type { /*!< livebox_event_handler_set Event list */ LB_EVENT_PINUP_CHANGED, /*!< PINUP status is changed */ LB_EVENT_PERIOD_CHANGED, /*!< Update period is changed */ + LB_EVENT_LB_SIZE_CHANGED, /*!< Livebox size is changed */ + LB_EVENT_PD_SIZE_CHANGED, /*!< PD size is changed */ + LB_EVENT_PD_CREATED, /*!< If a PD is created even if you didn't call the livebox_create_pd API */ LB_EVENT_PD_DESTROYED, /*!< If a PD is destroyed even if you didn't call the livebox_destroy_pd API */ diff --git a/include/livebox_internal.h b/include/livebox_internal.h index 0d3d9db..a55934c 100644 --- a/include/livebox_internal.h +++ b/include/livebox_internal.h @@ -141,6 +141,9 @@ struct livebox { ret_cb_t period_changed_cb; void *period_cbdata; + ret_cb_t size_changed_cb; + void *size_cbdata; + ret_cb_t pd_created_cb; void *pd_created_cbdata; diff --git a/packaging/liblivebox-viewer.spec b/packaging/liblivebox-viewer.spec index 7ba0449..e0c79b4 100644 --- a/packaging/liblivebox-viewer.spec +++ b/packaging/liblivebox-viewer.spec @@ -1,6 +1,6 @@ Name: liblivebox-viewer Summary: Library for developing the application. -Version: 0.9.1 +Version: 0.9.5 Release: 1 Group: framework/livebox License: Flora License diff --git a/src/client.c b/src/client.c index 119ec55..265189d 100644 --- a/src/client.c +++ b/src/client.c @@ -428,6 +428,65 @@ out: return NULL; } +static struct packet *master_size_changed(pid_t pid, int handle, const struct packet *packet) +{ + struct livebox *handler; + const char *pkgname; + const char *id; + int status; + int ret; + int w; + int h; + int is_pd; + + ret = packet_get(packet, "ssiiii", &pkgname, &id, &is_pd, &w, &h, &status); + if (ret != 6) { + ErrPrint("Invalid argument\n"); + ret = EINVAL; + goto out; + } + + handler = lb_find_livebox(pkgname, id); + if (!handler) { + ErrPrint("Livebox(%s - %s) is not found\n", pkgname, id); + ret = -ENOENT; + goto out; + } + + if (handler->state != CREATE) { + ret = -EPERM; + goto out; + } + + if (is_pd) { + /*! + * \NOTE + * PD is not able to resized by the client. + * PD is only can be managed by the provider. + * So the PD has no private resized event handler. + * Notify it via global event handler. + */ + lb_invoke_event_handler(handler, LB_EVENT_PD_SIZE_CHANGED); + if (status != 0) + ErrPrint("This is not possible. PD Size is changed but the return value is not ZERO\n"); + } else { + if (status == 0) + lb_set_size(handler, w, h); + + if (handler->size_changed_cb) { + handler->size_changed_cb(handler, status, handler->size_cbdata); + + handler->size_changed_cb = NULL; + handler->size_cbdata = NULL; + } else { + lb_invoke_event_handler(handler, LB_EVENT_LB_SIZE_CHANGED); + } + } + +out: + return NULL; +} + static struct packet *master_period_changed(pid_t pid, int handle, const struct packet *packet) { struct livebox *handler; @@ -765,6 +824,10 @@ static struct method s_table[] = { .handler = master_period_changed, }, { + .cmd = "size_changed", + .handler = master_size_changed, + }, + { .cmd = "pinup", .handler = master_pinup, }, diff --git a/src/livebox.c b/src/livebox.c index 641e3a8..798aab9 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -110,6 +110,11 @@ static inline void default_pd_destroyed_cb(struct livebox *handler, int ret, voi DbgPrint("Default PD destroyed event handler: %d\n", ret); } +static inline void default_lb_size_changed_cb(struct livebox *handler, int ret, void *data) +{ + DbgPrint("Default LB size changed event handler: %d\n", ret); +} + static inline __attribute__((always_inline)) struct cb_info *create_cb_info(ret_cb_t cb, void *data) { struct cb_info *info; @@ -157,9 +162,12 @@ static void resize_cb(struct livebox *handler, const struct packet *result, void * So the user can only get the resized value(result) from the first update event * after this request. */ - - if (cb) + if (ret == 0) { + handler->size_changed_cb = cb; + handler->size_cbdata = cbdata; + } else { cb(handler, ret, cbdata); + } } static void text_signal_cb(struct livebox *handler, const struct packet *result, void *data) @@ -882,6 +890,9 @@ EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *da return -EFAULT; } + if (!cb) + cb = default_lb_size_changed_cb; + return master_rpc_async_request(handler, packet, 0, resize_cb, create_cb_info(cb, data)); }