From 216879f7a8ad1f293df58ff306c1ff8e17ac67ac Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Wed, 10 Apr 2013 20:42:36 +0900 Subject: Merged with private repository. Update accessibility. Accessibility event is defined for script type livebox & pd. Update touch_effect & need_frame. These attributes should be described for each size type. Update parser for getting accessibility text TYPE="access" is added. "need_frame" attribute is added For handling the frame decoration of boxes. If a box set "true" for this need_frame attribute, The viewer will draw the border for it. Active/Passive update mode is added. Add update_mode. Active & Passive update mode. These two words are used for viewer. If a viewer wants to update the content of boxes without any updated events, it can use the active mode. or it can update by the updated event. passive mode is default. So every viewer will get updated event then they should to update the content of boxes. Change-Id: I928f5cdf1c99fa428a05e84f5605cdd60724a555 --- src/instance.c | 277 +++++++++++++++++- src/script_handler.c | 63 +++++ src/server.c | 783 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 1007 insertions(+), 116 deletions(-) (limited to 'src') diff --git a/src/instance.c b/src/instance.c index 6fc0f8b..18e8c51 100644 --- a/src/instance.c +++ b/src/instance.c @@ -62,6 +62,11 @@ struct resize_cbdata { int h; }; +struct update_mode_cbdata { + struct inst_info *inst; + int active_update; +}; + struct change_group_cbdata { struct inst_info *inst; char *cluster; @@ -94,7 +99,8 @@ struct inst_info { char *title; int is_pinned_up; double sleep_at; - int scroll_locked; + int scroll_locked; /*!< Scroller which is in viewer is locked. */ + int active_update; /*!< Viewer will reload the buffer by itself, so the provider doesn't need to send the updated event */ enum livebox_visible_state visible; @@ -255,6 +261,25 @@ static inline int instance_recover_visible_state(struct inst_info *inst) return ret; } +static inline void instance_send_update_mode_event(struct inst_info *inst, int active_mode, int status) +{ + struct packet *packet; + const char *pkgname; + + if (!inst->info) { + ErrPrint("Instance info is not ready to use\n"); + return; + } + + pkgname = package_name(inst->info); + + packet = packet_create_noack("update_mode", "ssii", pkgname, inst->id, status, active_mode); + if (packet) + CLIENT_SEND_EVENT(inst, packet); + else + ErrPrint("Failed to send update mode event\n"); +} + static inline void instance_send_resized_event(struct inst_info *inst, int is_pd, int w, int h, int status) { struct packet *packet; @@ -286,6 +311,36 @@ static inline void instance_send_resized_event(struct inst_info *inst, int is_pd ErrPrint("Failed to send size changed event\n"); } +static void update_mode_cb(struct slave_node *slave, const struct packet *packet, void *data) +{ + struct update_mode_cbdata *cbdata = data; + int ret; + + if (!packet) { + ErrPrint("Invalid packet\n"); + instance_send_update_mode_event(cbdata->inst, cbdata->active_update, LB_STATUS_ERROR_FAULT); + instance_unref(cbdata->inst); + DbgFree(cbdata); + return; + } + + if (packet_get(packet, "i", &ret) != 1) { + ErrPrint("Invalid parameters\n"); + instance_send_update_mode_event(cbdata->inst, cbdata->active_update, LB_STATUS_ERROR_INVALID); + instance_unref(cbdata->inst); + DbgFree(cbdata); + return; + } + + if (ret == LB_STATUS_SUCCESS) + cbdata->inst->active_update = cbdata->active_update; + + instance_send_update_mode_event(cbdata->inst, cbdata->active_update, ret); + + instance_unref(cbdata->inst); + DbgFree(cbdata); +} + HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_node *client) { struct packet *packet; @@ -1354,7 +1409,7 @@ HAPI int instance_reactivate(struct inst_info *inst) break; } - packet = packet_create("renew", "sssiidssiis", + packet = packet_create("renew", "sssiidssiisii", package_name(inst->info), inst->id, inst->content, @@ -1364,7 +1419,9 @@ HAPI int instance_reactivate(struct inst_info *inst) inst->cluster, inst->category, inst->lb.width, inst->lb.height, - package_abi(inst->info)); + package_abi(inst->info), + inst->scroll_locked, + inst->active_update); if (!packet) { ErrPrint("Failed to build a packet for %s\n", package_name(inst->info)); return LB_STATUS_ERROR_FAULT; @@ -1459,6 +1516,156 @@ HAPI int instance_activate(struct inst_info *inst) return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, activate_cb, instance_ref(inst), 1); } +HAPI int instance_lb_update_begin(struct inst_info *inst, double priority, const char *content, const char *title) +{ + struct packet *packet; + const char *fbfile; + + if (!inst->active_update) { + ErrPrint("Invalid request [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + switch (package_lb_type(inst->info)) { + case LB_TYPE_BUFFER: + if (!inst->lb.canvas.buffer) { + ErrPrint("Buffer is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + fbfile = buffer_handler_id(inst->lb.canvas.buffer); + break; + case LB_TYPE_SCRIPT: + if (!inst->lb.canvas.script) { + ErrPrint("Script is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + fbfile = fb_id(script_handler_fb(inst->lb.canvas.script)); + break; + default: + ErrPrint("Invalid request[%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + packet = packet_create_noack("lb_update_begin", "ssdsss", package_name(inst->info), inst->id, priority, content, title, fbfile); + if (!packet) { + ErrPrint("Unable to create a packet\n"); + return LB_STATUS_ERROR_FAULT; + } + + return CLIENT_SEND_EVENT(inst, packet); +} + +HAPI int instance_lb_update_end(struct inst_info *inst) +{ + struct packet *packet; + + if (!inst->active_update) { + ErrPrint("Invalid request [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + switch (package_lb_type(inst->info)) { + case LB_TYPE_BUFFER: + if (!inst->lb.canvas.buffer) { + ErrPrint("Buffer is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + break; + case LB_TYPE_SCRIPT: + if (!inst->lb.canvas.script) { + ErrPrint("Script is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + break; + default: + ErrPrint("Invalid request[%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + packet = packet_create_noack("lb_update_end", "ss", package_name(inst->info), inst->id); + if (!packet) { + ErrPrint("Unable to create a packet\n"); + return LB_STATUS_ERROR_FAULT; + } + + return CLIENT_SEND_EVENT(inst, packet); +} + +HAPI int instance_pd_update_begin(struct inst_info *inst) +{ + struct packet *packet; + const char *fbfile; + + if (!inst->active_update) { + ErrPrint("Invalid request [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + switch (package_pd_type(inst->info)) { + case PD_TYPE_BUFFER: + if (!inst->pd.canvas.buffer) { + ErrPrint("Buffer is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + fbfile = buffer_handler_id(inst->pd.canvas.buffer); + break; + case PD_TYPE_SCRIPT: + if (!inst->pd.canvas.script) { + ErrPrint("Script is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + fbfile = fb_id(script_handler_fb(inst->pd.canvas.script)); + break; + default: + ErrPrint("Invalid request[%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + packet = packet_create_noack("pd_update_begin", "sss", package_name(inst->info), inst->id, fbfile); + if (!packet) { + ErrPrint("Unable to create a packet\n"); + return LB_STATUS_ERROR_FAULT; + } + + return CLIENT_SEND_EVENT(inst, packet); +} + +HAPI int instance_pd_update_end(struct inst_info *inst) +{ + struct packet *packet; + + if (!inst->active_update) { + ErrPrint("Invalid request [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + switch (package_pd_type(inst->info)) { + case PD_TYPE_BUFFER: + if (!inst->pd.canvas.buffer) { + ErrPrint("Buffer is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + break; + case PD_TYPE_SCRIPT: + if (!inst->pd.canvas.script) { + ErrPrint("Script is null [%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + break; + default: + ErrPrint("Invalid request[%s]\n", inst->id); + return LB_STATUS_ERROR_INVALID; + } + + packet = packet_create_noack("pd_update_end", "ss", package_name(inst->info), inst->id); + if (!packet) { + ErrPrint("Unable to create a packet\n"); + return LB_STATUS_ERROR_FAULT; + } + + return CLIENT_SEND_EVENT(inst, packet); +} + HAPI void instance_lb_updated(const char *pkgname, const char *id) { struct inst_info *inst; @@ -1520,16 +1727,17 @@ HAPI int instance_hold_scroll(struct inst_info *inst, int hold) struct packet *packet; if (inst->scroll_locked == hold) { - DbgPrint("There is changes for hold state: %d\n", hold); + DbgPrint("[HOLD] There is changes for hold state: %d\n", hold); return LB_STATUS_ERROR_ALREADY; } packet = packet_create_noack("scroll", "ssi", package_name(inst->info), inst->id, hold); if (!packet) { - ErrPrint("Failed to build a packet\n"); + ErrPrint("[HOLD] Failed to build a packet\n"); return LB_STATUS_ERROR_FAULT; } + DbgPrint("[HOLD] (%s) %d\n", inst->id, hold); inst->scroll_locked = hold; return CLIENT_SEND_EVENT(inst, packet); } @@ -1600,6 +1808,47 @@ HAPI void instance_pd_updated(const char *pkgname, const char *id, const char *d instance_pd_updated_by_instance(inst, descfile); } +HAPI int instance_set_update_mode(struct inst_info *inst, int active_update) +{ + struct packet *packet; + struct update_mode_cbdata *cbdata; + + if (package_is_fault(inst->info)) { + DbgPrint("Fault package [%s]\n", package_name(inst->info)); + return LB_STATUS_ERROR_FAULT; + } + + if (inst->active_update == active_update) { + DbgPrint("Active update is not changed: %d\n", inst->active_update); + return LB_STATUS_ERROR_ALREADY; + } + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ErrPrint("Heap: %s\n", strerror(errno)); + return LB_STATUS_ERROR_MEMORY; + } + + cbdata->inst = instance_ref(inst); + cbdata->active_update = active_update; + + /* NOTE: param is resued from here */ + packet = packet_create("update_mode", "ssi", package_name(inst->info), inst->id, active_update); + if (!packet) { + ErrPrint("Failed to build a packet for %s\n", package_name(inst->info)); + instance_unref(cbdata->inst); + free(cbdata); + return LB_STATUS_ERROR_FAULT; + } + + return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, update_mode_cb, cbdata, 0); +} + +HAPI int instance_active_update(struct inst_info *inst) +{ + return inst->active_update; +} + HAPI void instance_set_lb_info(struct inst_info *inst, int w, int h, double priority, const char *content, const char *title) { char *_content = NULL; @@ -2509,6 +2758,24 @@ HAPI int instance_need_slave(struct inst_info *inst) return ret; } +HAPI int instance_forward_packet(struct inst_info *inst, struct packet *packet) +{ + return CLIENT_SEND_EVENT(inst, packet); +} + +HAPI int instance_send_access_status(struct inst_info *inst, int status) +{ + struct packet *packet; + + packet = packet_create_noack("access_status", "ssi", package_name(inst->info), inst->id, status); + if (!packet) { + ErrPrint("Failed to build a packet\n"); + return LB_STATUS_ERROR_FAULT; + } + + return CLIENT_SEND_EVENT(inst, packet); +} + HAPI void instance_slave_set_pd_pos(struct inst_info *inst, double x, double y) { inst->pd.x = x; diff --git a/src/script_handler.c b/src/script_handler.c index b9536d6..69c9217 100644 --- a/src/script_handler.c +++ b/src/script_handler.c @@ -50,6 +50,8 @@ #define TYPE_SIGNAL "signal" #define TYPE_INFO "info" #define TYPE_DRAG "drag" +#define TYPE_ACCESS "access" + #define INFO_SIZE "size" #define INFO_CATEGORY "category" #define ADDEND 256 @@ -71,11 +73,13 @@ struct script_port { int (*update_color)(void *handle, Evas *e, const char *id, const char *part, const char *rgba); int (*update_text)(void *handle, Evas *e, const char *id, const char *part, const char *text); int (*update_image)(void *handle, Evas *e, const char *id, const char *part, const char *path, const char *option); + int (*update_access)(void *handle, Evas *e, const char *id, const char *part, const char *text, const char *option); int (*update_script)(void *handle, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *option); int (*update_signal)(void *handle, Evas *e, const char *id, const char *part, const char *signal); int (*update_drag)(void *handle, Evas *e, const char *id, const char *part, double x, double y); int (*update_size)(void *handle, Evas *e, const char *id, int w, int h); int (*update_category)(void *handle, Evas *e, const char *id, const char *category); + int (*feed_event)(void *handle, Evas *e, int event_type, int x, int y, double timestamp); void *(*create)(const char *file, const char *option); int (*destroy)(void *handle); @@ -494,6 +498,35 @@ static int update_script_image(struct inst_info *inst, struct block *block, int return LB_STATUS_SUCCESS; } +static int update_access(struct inst_info *inst, struct block *block, int is_pd) +{ + struct script_info *info; + Evas *e; + + if (!block || !block->part || !block->data) { + ErrPrint("Block or block->part or block->data is NIL\n"); + return LB_STATUS_ERROR_INVALID; + } + + info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst); + if (!info) { + ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst)); + return LB_STATUS_ERROR_FAULT; + } + + if (!info->port) { + ErrPrint("info->port is NIL\n"); + return LB_STATUS_ERROR_INVALID; + } + + e = script_handler_evas(info); + if (e) + info->port->update_access(info->port_data, e, block->id, block->part, block->data, block->option); + else + ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data); + return LB_STATUS_SUCCESS; +} + static int update_script_script(struct inst_info *inst, struct block *block, int is_pd) { struct script_info *info; @@ -741,6 +774,10 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch .type = TYPE_INFO, .handler = update_info, }, + { + .type = TYPE_ACCESS, + .handler = update_access, + }, { .type = NULL, .handler = NULL, @@ -1213,6 +1250,10 @@ HAPI int script_init(void) if (!item->update_image) goto errout; + item->update_access = dlsym(item->handle, "script_update_access"); + if (!item->update_access) + goto errout; + item->update_script = dlsym(item->handle, "script_update_script"); if (!item->update_script) goto errout; @@ -1257,6 +1298,10 @@ HAPI int script_init(void) if (!item->fini) goto errout; + item->feed_event = dlsym(item->handle, "script_feed_event"); + if (!item->feed_event) + goto errout; + if (item->init() < 0) { ErrPrint("Failed to initialize script engine\n"); goto errout; @@ -1307,4 +1352,22 @@ HAPI int script_handler_update_pointer(struct script_info *info, int x, int y, i return LB_STATUS_SUCCESS; } +HAPI int script_handler_feed_event(struct script_info *info, int event, double timestamp) +{ + Evas *e; + + if (!info->port) { + ErrPrint("info->port is NIL\n"); + return LB_STATUS_ERROR_INVALID; + } + + e = script_handler_evas(info); + if (!e) { + ErrPrint("Evas is not exists\n"); + return LB_STATUS_ERROR_FAULT; + } + + return info->port->feed_event(info->port_data, e, event, info->x, info->y, timestamp); +} + /* End of a file */ diff --git a/src/server.c b/src/server.c index b6a6f43..77c45ee 100644 --- a/src/server.c +++ b/src/server.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "conf.h" #include "debug.h" @@ -68,11 +69,30 @@ enum target_type { TYPE_ERROR, }; +struct access_cbdata { + int status; + struct inst_info *inst; +}; + struct deleted_item { struct client_node *client; struct inst_info *inst; }; +static Eina_Bool lazy_access_status_cb(void *data) +{ + struct access_cbdata *cbdata = data; + + if (instance_unref(cbdata->inst)) + instance_send_access_status(cbdata->inst, cbdata->status); + /*! + * If instance_unref returns NULL, + * The instance is destroyed. it means, we don't need to send event to the viewer + */ + free(cbdata); + return ECORE_CALLBACK_CANCEL; +} + static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data) { struct inst_info *inst = data; @@ -135,17 +155,15 @@ static int event_lb_consume_cb(enum event_state state, struct event_data *event_ switch (state) { case EVENT_STATE_ACTIVATE: script_handler_update_pointer(script, event_info->x, event_info->y, 1); - evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL); - evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp); break; case EVENT_STATE_ACTIVATED: script_handler_update_pointer(script, event_info->x, event_info->y, -1); - evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp); break; case EVENT_STATE_DEACTIVATE: script_handler_update_pointer(script, event_info->x, event_info->y, 0); - evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL); - evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp); break; default: break; @@ -218,17 +236,15 @@ static int event_pd_consume_cb(enum event_state state, struct event_data *event_ switch (state) { case EVENT_STATE_ACTIVATE: script_handler_update_pointer(script, event_info->x, event_info->y, 1); - evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL); - evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp); break; case EVENT_STATE_ACTIVATED: script_handler_update_pointer(script, event_info->x, event_info->y, -1); - evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp); break; case EVENT_STATE_DEACTIVATE: script_handler_update_pointer(script, event_info->x, event_info->y, 0); - evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL); - evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp); break; default: break; @@ -315,14 +331,12 @@ static struct packet *client_clicked(pid_t pid, int handle, const struct packet client = client_find_by_pid(pid); if (!client) { ErrPrint("Client %d is not exists\n", pid); - ret = LB_STATUS_ERROR_NOT_EXIST; goto out; } ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y); if (ret != 6) { ErrPrint("Parameter is not matched\n"); - ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -335,17 +349,64 @@ static struct packet *client_clicked(pid_t pid, int handle, const struct packet */ inst = package_find_instance_by_id(pkgname, id); if (!inst) - ret = LB_STATUS_ERROR_NOT_EXIST; + ErrPrint("Instance is not exists\n"); else if (package_is_fault(instance_package(inst))) - ret = LB_STATUS_ERROR_FAULT; + ErrPrint("Fault package\n"); else - ret = instance_clicked(inst, event, timestamp, x, y); + (void)instance_clicked(inst, event, timestamp, x, y); out: /*! \note No reply packet */ return NULL; } +static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet) +{ + struct packet *result; + struct client_node *client; + int active_update; + const char *pkgname; + const char *id; + int ret; + struct inst_info *inst; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Client %d is not exists\n", pid); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + ret = packet_get(packet, "ssi", &pkgname, &id, &active_update); + if (ret != 3) { + ErrPrint("Invalid argument\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance is not exists\n"); + ret = LB_STATUS_ERROR_NOT_EXIST; + } else if (package_is_fault(instance_package(inst))) { + ErrPrint("Fault package\n"); + ret = LB_STATUS_ERROR_FAULT; + } else { + /*! + * \note + * Send change update mode request to a slave + */ + ret = instance_set_update_mode(inst, active_update); + } + +out: + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a packet\n"); + + return result; +} + /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */ static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet) { @@ -464,7 +525,6 @@ static struct packet *client_delete(pid_t pid, int handle, const struct packet * ErrPrint("Heap: %s\n", strerror(errno)); ret = LB_STATUS_ERROR_MEMORY; } else { - ret = 0; /*! * \NOTE: * Send DELETED EVENT to the client. @@ -483,6 +543,8 @@ static struct packet *client_delete(pid_t pid, int handle, const struct packet * instance_unref(inst); DbgFree(item); ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; } } } else { @@ -877,7 +939,7 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct } script_handler_update_pointer(script, x, y, -1); - evas_event_feed_mouse_in(e, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -989,7 +1051,7 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct } script_handler_update_pointer(script, x, y, -1); - evas_event_feed_mouse_out(e, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -1103,8 +1165,7 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p } script_handler_update_pointer(script, x, y, 1); - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); - evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -1217,8 +1278,7 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac } script_handler_update_pointer(script, x, y, 0); - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); - evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -1331,7 +1391,7 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p } script_handler_update_pointer(script, x, y, -1); - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -1442,7 +1502,7 @@ static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct p } script_handler_update_pointer(script, x, y, -1); - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -1834,7 +1894,7 @@ static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct } script_handler_update_pointer(script, x, y, -1); - evas_event_feed_mouse_in(e, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -1946,7 +2006,7 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct } script_handler_update_pointer(script, x, y, -1); - evas_event_feed_mouse_out(e, timestamp, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -2058,8 +2118,7 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p } script_handler_update_pointer(script, x, y, 1); - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); - evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -2171,8 +2230,7 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac } script_handler_update_pointer(script, x, y, 0); - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); - evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL); + script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp); ret = 0; } else { ErrPrint("Unsupported package\n"); @@ -2186,6 +2244,7 @@ out: static struct packet *client_pd_access_value_change(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -2284,22 +2343,42 @@ static struct packet *client_pd_access_value_change(pid_t pid, int handle, const } script_handler_update_pointer(script, x, y, -1); - /*! - * \TODO: Push up the ACCESS_VALUE_CHANGE event - */ - ret = 0; + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_pd_access_scroll(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -2398,22 +2477,42 @@ static struct packet *client_pd_access_scroll(pid_t pid, int handle, const struc } script_handler_update_pointer(script, x, y, -1); - /*! - * \TODO: Push up the ACCESS_SCROLL event - */ - ret = 0; + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -2512,22 +2611,42 @@ static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct pa } script_handler_update_pointer(script, x, y, -1); - /*! - * \TODO: Push up the ACCESS_HIGHLIGHT event - */ - ret = 0; + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -2626,22 +2745,42 @@ static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const stru } script_handler_update_pointer(script, x, y, -1); - /*! - * \TODO: Push up the ACCESS_HIGHLIGHT_PREV event - */ - ret = 0; + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -2740,22 +2879,42 @@ static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const stru } script_handler_update_pointer(script, x, y, -1); - /*! - * \TODO: Push up the ACCESS_HIGHLIGHT_NEXT event - */ - ret = 0; + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -2854,18 +3013,37 @@ static struct packet *client_pd_access_activate(pid_t pid, int handle, const str } script_handler_update_pointer(script, x, y, -1); - /*! - * \TODO: Push up the ACCESS_ACTIVATE event - */ - ret = 0; + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet) @@ -3019,15 +3197,13 @@ static struct packet *client_resume_request(pid_t pid, int handle, const struct client = client_find_by_pid(pid); if (!client) { - ErrPrint("Client %d is paused - manually reported\n", pid); - ret = LB_STATUS_ERROR_NOT_EXIST; + ErrPrint("Client %d is not exists\n", pid); goto out; } ret = packet_get(packet, "d", ×tamp); if (ret != 1) { ErrPrint("Invalid parameter\n"); - ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -3156,6 +3332,7 @@ out: static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -3254,23 +3431,42 @@ static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct pa } script_handler_update_pointer(script, x, y, -1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; - /*! - * \TODO: Feed up this ACCESS_HIGHLIGHT event - */ - ret = 0; + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -3369,23 +3565,42 @@ static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const stru } script_handler_update_pointer(script, x, y, -1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; - /*! - * \TODO: Feed up this ACCESS_HIGHLIGHT_PREV event - */ - ret = 0; + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -3484,23 +3699,42 @@ static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const stru } script_handler_update_pointer(script, x, y, -1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; - /*! - * \TODO: Feed up this ACCESS_HIGHLIGHT_NEXT event - */ - ret = 0; + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); ret = LB_STATUS_ERROR_INVALID; } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_lb_access_value_change(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -3575,21 +3809,42 @@ static struct packet *client_lb_access_value_change(pid_t pid, int handle, const goto out; } - // script_handler_update_pointer(script, x, y, -1); + script_handler_update_pointer(script, x, y, -1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; - /*! - * \TODO: Feed up this VALUE_CHANGE event - */ + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); } out: - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -3665,20 +3920,41 @@ static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struc } script_handler_update_pointer(script, x, y, -1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; - /*! - * \TODO: Feed up this ACCESS_SCROLL event - */ + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); } out: - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet) { + struct packet *result; struct client_node *client; const char *pkgname; const char *id; @@ -3771,17 +4047,36 @@ static struct packet *client_lb_access_activate(pid_t pid, int handle, const str } script_handler_update_pointer(script, x, y, -1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; - /*! - * \TODO: Feed up this ACCESS_ACTIVATE event - */ + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } } else { ErrPrint("Unsupported package\n"); } out: - /*! \note No reply packet */ - return NULL; + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; } static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet) @@ -4282,21 +4577,22 @@ out: static Eina_Bool lazy_pd_created_cb(void *data) { - int ret; - - ret = instance_client_pd_created(data, LB_STATUS_SUCCESS); - DbgPrint("Send PD Create event (%d)\n", ret); + if (instance_unref(data)) { + int ret; + ret = instance_client_pd_created(data, LB_STATUS_SUCCESS); + DbgPrint("Send PD Create event (%d)\n", ret); + } - instance_unref(data); return ECORE_CALLBACK_CANCEL; } static Eina_Bool lazy_pd_destroyed_cb(void *data) { - DbgPrint("Send PD Destroy event\n"); - instance_client_pd_destroyed(data, LB_STATUS_SUCCESS); + if (instance_unref(data)) { + DbgPrint("Send PD Destroy event\n"); + instance_client_pd_destroyed(data, LB_STATUS_SUCCESS); + } - instance_unref(data); return ECORE_CALLBACK_CANCEL; } @@ -4527,10 +4823,15 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack * \note * Send the destroyed PD event to the client */ - if (ret == 0) { + if (ret == LB_STATUS_SUCCESS) { inst = instance_ref(inst); - if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst)) + if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst)) { instance_unref(inst); + /*! + * How can we handle this? + */ + ret = LB_STATUS_ERROR_FAULT; + } } } else { ErrPrint("Invalid PD TYPE\n"); @@ -5008,6 +5309,238 @@ out: return NULL; } +static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct packet *packet) +{ + struct slave_node *slave; + struct inst_info *inst; + struct pkg_info *pkg; + const char *pkgname; + const char *id; + double priority; + const char *content; + const char *title; + int ret; + + slave = slave_find_by_pid(pid); + if (!slave) { + ErrPrint("Slave %d is not exists\n", pid); + goto out; + } + + ret = packet_get(packet, "ssdss", &pkgname, &id, &priority, &content, &title); + if (ret != 5) { + ErrPrint("Invalid parameters\n"); + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance(%s) is not exists\n", id); + goto out; + } else if (instance_state(inst) == INST_DESTROYED) { + ErrPrint("Instance(%s) is already destroyed\n", id); + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Invalid instance\n"); + } else if (package_is_fault(pkg)) { + ErrPrint("Faulted instance %s.\n", id); + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + ret = instance_lb_update_begin(inst, priority, content, title); + if (ret == LB_STATUS_SUCCESS) + slave_freeze_ttl(slave); + } else { + ErrPrint("Invalid request[%s]\n", id); + } + +out: + return NULL; +} + +static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct packet *packet) +{ + struct slave_node *slave; + struct inst_info *inst; + struct pkg_info *pkg; + const char *pkgname; + const char *id; + int ret; + + slave = slave_find_by_pid(pid); + if (!slave) { + ErrPrint("Slave %d is not exists\n", pid); + goto out; + } + + ret = packet_get(packet, "ss", &pkgname, &id); + if (ret != 2) { + ErrPrint("Invalid parameters\n"); + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + goto out; + } else if (instance_state(inst) == INST_DESTROYED) { + ErrPrint("Instance[%s] is already destroyed\n", id); + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Invalid instance\n"); + } else if (package_is_fault(pkg)) { + ErrPrint("Faulted instance %s\n", id); + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + ret = instance_lb_update_end(inst); + if (ret == LB_STATUS_SUCCESS) + slave_thaw_ttl(slave); + } else { + ErrPrint("Invalid request[%s]\n", id); + } + +out: + return NULL; +} + +static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet) +{ + struct slave_node *slave; + struct pkg_info *pkg; + struct inst_info *inst; + const char *pkgname; + const char *id; + int ret; + + slave = slave_find_by_pid(pid); + if (!slave) { + ErrPrint("Slave %d is not exists\n", pid); + goto out; + } + + ret = packet_get(packet, "ss", &pkgname, &id); + if (ret != 2) { + ErrPrint("Invalid parameters\n"); + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Invalid package\n"); + } else if (package_is_fault(pkg)) { + ErrPrint("Faulted instance %s\n", id); + } else if (instance_state(inst) == INST_DESTROYED) { + ErrPrint("Instance[%s] is already destroyed\n", id); + } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { + (void)instance_pd_update_begin(inst); + } else { + ErrPrint("Invalid request[%s]\n", id); + } + +out: + return NULL; +} + +static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet) +{ + struct slave_node *slave; + struct pkg_info *pkg; + struct inst_info *inst; + const char *pkgname; + const char *id; + int status; + int ret; + + slave = slave_find_by_pid(pid); + if (!slave) { + ErrPrint("Slave %d is not exists\n", pid); + goto out; + } + + ret = packet_get(packet, "ssi", &pkgname, &id, &status); + if (ret != 3) { + ErrPrint("Invalid parameters\n"); + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Invalid package\n"); + } else if (package_is_fault(pkg)) { + ErrPrint("Faulted instance %s\n", id); + } else if (instance_state(inst) == INST_DESTROYED) { + ErrPrint("Instance[%s] is already destroyed\n", id); + } else { + /*! + * \note + * Forward packet to client + */ + (void)instance_forward_packet(inst, packet_ref((struct packet *)packet)); + } + +out: + return NULL; +} + +static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet) +{ + struct slave_node *slave; + struct pkg_info *pkg; + struct inst_info *inst; + const char *pkgname; + const char *id; + int ret; + + slave = slave_find_by_pid(pid); + if (!slave) { + ErrPrint("Slave %d is not exists\n", pid); + goto out; + } + + ret = packet_get(packet, "ss", &pkgname, &id); + if (ret != 2) { + ErrPrint("Invalid parameters\n"); + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Invalid package\n"); + } else if (package_is_fault(pkg)) { + ErrPrint("Faulted instance %s\n", id); + } else if (instance_state(inst) == INST_DESTROYED) { + ErrPrint("Instance[%s] is already destroyed\n", id); + } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { + (void)instance_pd_update_end(inst); + } else { + ErrPrint("Invalid request[%s]\n", id); + } + +out: + return NULL; +} + static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */ { struct slave_node *slave; @@ -6243,6 +6776,11 @@ static struct method s_client_table[] = { .handler = client_resume_request, }, + { + .cmd = "update_mode", + .handler = client_update_mode, + }, + { .cmd = NULL, .handler = NULL, @@ -6313,6 +6851,29 @@ static struct method s_slave_table[] = { .cmd = "scroll", .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */ }, + + { + .cmd = "lb_update_begin", + .handler = slave_lb_update_begin, + }, + { + .cmd = "lb_update_end", + .handler = slave_lb_update_end, + }, + { + .cmd = "pd_update_begin", + .handler = slave_pd_update_begin, + }, + { + .cmd = "pd_update_end", + .handler = slave_pd_update_end, + }, + + { + .cmd = "access_status", + .handler = slave_access_status, + }, + { .cmd = NULL, .handler = NULL, -- cgit v1.2.3