From 1915944082905af6f8670ee50465cc168a432a1b Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Fri, 22 Mar 2013 01:36:04 +0000 Subject: [PATCH] Update the size changed callback handler. If a user tries to change the size with size changed callback, size changed callback should be called even if it failed to change size. Change-Id: Iade97b82f3f5c6ed34abf0ea529a3495a1d4d9e6 --- packaging/liblivebox-viewer.spec | 2 +- src/client.c | 28 +++++++++++++++++++--------- src/livebox.c | 32 ++++++++++++++++++++------------ 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/packaging/liblivebox-viewer.spec b/packaging/liblivebox-viewer.spec index 0ee255c..4ceff01 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.10.0 +Version: 0.10.1 Release: 1 Group: framework/livebox License: Flora License diff --git a/src/client.c b/src/client.c index f2a68fd..e3370cc 100644 --- a/src/client.c +++ b/src/client.c @@ -474,7 +474,7 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa * 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. + * Notify it via global event handler only. */ if (status == 0) { lb_set_pdsize(handler, w, h); @@ -483,31 +483,39 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa ErrPrint("This is not possible. PD Size is changed but the return value is not ZERO\n"); } } else { - DbgPrint("LB is resized\n"); if (status == 0) { - DbgPrint("Livebox size is updated (%dx%d)\n", w, h); + DbgPrint("LB is successfully resized (%dx%d)\n", w, h); lb_set_size(handler, w, h); /*! + * \NOTE * If there is a created LB FB, - * Update it too + * Update it too. */ if (lb_get_lb_fb(handler)) lb_set_lb_fb(handler, id); + /*! + * \NOTE + * I cannot believe client. + * So I added some log before & after call the user callback. + */ if (handler->size_changed_cb) { - DbgPrint("Call the size changed callback\n"); handler->size_changed_cb(handler, status, handler->size_cbdata); handler->size_changed_cb = NULL; handler->size_cbdata = NULL; } else { - DbgPrint("Call the global size changed callback\n"); lb_invoke_event_handler(handler, LB_EVENT_LB_SIZE_CHANGED); - DbgPrint("Size changed callback done\n"); } } else { - DbgPrint("Livebox size is not changed: %dx%d, %d\n", w, h, status); + DbgPrint("LB is not resized: %dx%d (%d)\n", w, h, status); + if (handler->size_changed_cb) { + handler->size_changed_cb(handler, status, handler->size_cbdata); + + handler->size_changed_cb = NULL; + handler->size_cbdata = NULL; + } } } @@ -543,6 +551,7 @@ static struct packet *master_period_changed(pid_t pid, int handle, const struct goto out; } + DbgPrint("Update period is changed? %lf (%d)\n", period, status); if (status == 0) lb_set_period(handler, period); @@ -594,6 +603,7 @@ static struct packet *master_group_changed(pid_t pid, int handle, const struct p goto out; } + DbgPrint("Group is changed? [%s] / [%s] (%d)\n", cluster, category, status); if (status == 0) lb_set_group(handler, cluster, category); @@ -909,7 +919,7 @@ static inline void make_connection(void) if (s_info.reconnector == 0) ErrPrint("Failed to fire the reconnector\n"); - ErrPrint("Try this again 10 secs later\n"); + ErrPrint("Try this again A sec later\n"); return; } diff --git a/src/livebox.c b/src/livebox.c index 6ec2916..bfa4f41 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -720,6 +720,11 @@ EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, return -EINVAL; } + if (handler->period_changed_cb) { + ErrPrint("Previous request for changing period is not finished\n"); + return -EBUSY; + } + if (!handler->is_user) { ErrPrint("CA Livebox is not able to change the period\n"); return -EPERM; @@ -730,9 +735,6 @@ EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, return -EALREADY; } - if (handler->period_changed_cb) - DbgPrint("Already requested\n"); - packet = packet_create("set_period", "ssd", handler->pkgname, handler->id, period); if (!packet) { ErrPrint("Failed to build a packet %s\n", handler->pkgname); @@ -877,6 +879,11 @@ EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *da return -EINVAL; } + if (handler->size_changed_cb) { + ErrPrint("Previous resize request is not finished yet\n"); + return -EBUSY; + } + if (!handler->is_user) { ErrPrint("CA Livebox is not able to be resized\n"); return -EPERM; @@ -892,9 +899,6 @@ EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *da return -EALREADY; } - if (handler->size_changed_cb) - DbgPrint("Already pended\n"); - packet = packet_create("resize", "ssii", handler->pkgname, handler->id, w, h); if (!packet) { ErrPrint("Failed to build param\n"); @@ -1327,6 +1331,11 @@ EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const c return -EINVAL; } + if (handler->group_changed_cb) { + ErrPrint("Previous group changing request is not finished yet\n"); + return -EBUSY; + } + if (!handler->is_user) { ErrPrint("CA Livebox is not able to change the group\n"); return -EPERM; @@ -1337,9 +1346,6 @@ EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const c return -EALREADY; } - if (handler->group_changed_cb) - DbgPrint("Already sent\n"); - packet = packet_create("change_group", "ssss", handler->pkgname, handler->id, cluster, category); if (!packet) { ErrPrint("Failed to build a param\n"); @@ -1848,14 +1854,16 @@ EAPI int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void return -EINVAL; } + if (handler->pinup_cb) { + ErrPrint("Previous pinup request is not finished\n"); + return -EBUSY; + } + if (handler->is_pinned_up == flag) { DbgPrint("No changes\n"); return -EALREADY; } - if (handler->pinup_cb) - DbgPrint("Already sent\n"); - packet = packet_create("pinup_changed", "ssi", handler->pkgname, handler->id, flag); if (!packet) { ErrPrint("Failed to build a param\n"); -- 2.7.4