+static struct packet *master_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ const char *content;
+ const char *title;
+ const char *fbfile;
+ double priority;
+ int ret;
+
+ ret = packet_get(packet, "ssdsss", &pkgname, &id, &priority, &content, &title, &fbfile);
+ if (ret != 6) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ ErrPrint("(%s) is not created\n", id);
+ goto out;
+ }
+
+ lb_set_priority(handler, priority);
+ lb_set_content(handler, content);
+ lb_set_title(handler, title);
+
+ /*!
+ * \NOTE
+ * Width & Height is not changed in this case.
+ * If the active update is began, the size should not be changed,
+ * And if the size is changed, the provider should finish the updating first.
+ * And then begin updating again after change its size.
+ */
+ if (lb_get_lb_fb(handler)) {
+ (void)lb_set_lb_fb(handler, fbfile);
+
+ ret = fb_sync(lb_get_lb_fb(handler));
+ if (ret != LB_STATUS_SUCCESS) {
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret);
+ } else {
+ lb_invoke_event_handler(handler, LB_EVENT_LB_UPDATE_BEGIN);
+ }
+ } else {
+ ErrPrint("Invalid request[%s], %s\n", id, fbfile);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ const char *fbfile;
+ int ret;
+
+ ret = packet_get(packet, "sss", &pkgname, &id, &fbfile);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (lb_get_pd_fb(handler)) {
+ (void)lb_set_lb_fb(handler, fbfile);
+
+ ret = fb_sync(lb_get_lb_fb(handler));
+ if (ret != LB_STATUS_SUCCESS) {
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret);
+ } else {
+ lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATE_BEGIN);
+ }
+ } else {
+ ErrPrint("Invalid request[%s], %s\n", id, fbfile);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_lb_update_end(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ int ret;
+
+ ret = packet_get(packet, "ss", &pkgname, &id);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (lb_get_lb_fb(handler)) {
+ lb_invoke_event_handler(handler, LB_EVENT_LB_UPDATE_END);
+ } else {
+ ErrPrint("Invalid request[%s]\n", id);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_access_status(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ int status;
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &status);
+ if (ret != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (handler->access_event_cb) {
+ ret_cb_t cb;
+ void *cbdata;
+
+ cb = handler->access_event_cb;
+ cbdata = handler->access_event_cbdata;
+
+ handler->access_event_cb = NULL;
+ handler->access_event_cbdata = NULL;
+
+ cb(handler, status, cbdata);
+ } else {
+ ErrPrint("Invalid event[%s]\n", id);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_pd_update_end(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ int ret;
+
+ ret = packet_get(packet, "ss", &pkgname, &id);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (lb_get_lb_fb(handler)) {
+ lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATE_END);
+ } else {
+ ErrPrint("Invalid request[%s]", id);
+ }
+
+out:
+ return NULL;
+}
+