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 */
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;
.handler = master_period_changed,
},
{
+ .cmd = "size_changed",
+ .handler = master_size_changed,
+ },
+ {
.cmd = "pinup",
.handler = master_pinup,
},
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;
* 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)
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));
}