From b2c85d7a612198a6fd86c7f7d8e4e172a3734e20 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 18 Apr 2013 13:57:18 +0900 Subject: Various patchset applied. Clear the pixmap right after allocate it. If the slave is faulted, Every package in that slave should be faulted too. Then the user can re-activate it. Supporting the 4x5,4x6 liveboxes Update accessibility scroll event Add more log for fs free size calculation. Change-Id: I8b5ecfffca79e4f0cd17e11bda201e36a16ffe10 --- src/buffer_handler.c | 17 +- src/package.c | 10 +- src/script_handler.c | 4 +- src/server.c | 544 ++++++++++++++++++++++++++++++++++++++++++++++++++- src/util.c | 4 + 5 files changed, 565 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/buffer_handler.c b/src/buffer_handler.c index dba3e79..b410a82 100644 --- a/src/buffer_handler.c +++ b/src/buffer_handler.c @@ -171,6 +171,8 @@ static inline struct buffer *create_pixmap(struct buffer_info *info) struct buffer *buffer; Display *disp; Window parent; + XGCValues gcv; + GC gc; disp = ecore_x_display_get(); if (!disp) @@ -210,7 +212,20 @@ static inline struct buffer *create_pixmap(struct buffer_info *info) return NULL; } - XSync(disp, False); + /*! + * \note + * Clear pixmap + */ + memset(&gcv, 0, sizeof(gcv)); + gc = XCreateGC(disp, gem->pixmap, GCForeground, &gcv); + if (gc) { + XFillRectangle(disp, gem->pixmap, gc, 0, 0, info->w, info->h); + XSync(disp, False); + XFreeGC(disp, gc); + } else { + XSync(disp, False); + ErrPrint("Unable to clear the pixmap\n"); + } DbgPrint("Pixmap:0x%X is created\n", gem->pixmap); return buffer; diff --git a/src/package.c b/src/package.c index 6d14eb8..21c6ce1 100644 --- a/src/package.c +++ b/src/package.c @@ -168,7 +168,15 @@ static int slave_fault_cb(struct slave_node *slave, void *data) struct inst_info *inst; struct pkg_info *info = (struct pkg_info *)data; - DbgPrint("Slave %s has critical fault. destroy all instances\n", slave_name(slave)); + if (package_is_fault(info)) { + ErrPrint("Already faulted package: %s\n", package_name(info)); + return 0; + } + + package_set_fault_info(info, util_timestamp(), slave_name(slave), __func__); + fault_broadcast_info(package_name(info), slave_name(slave), __func__); + + DbgPrint("Slave critical fault - package: %s (by slave fault %s\n", package_name(info), slave_name(slave)); EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) { DbgPrint("Destroy instance %p\n", inst); instance_destroyed(inst); diff --git a/src/script_handler.c b/src/script_handler.c index 9fbef11..a0a2427 100644 --- a/src/script_handler.c +++ b/src/script_handler.c @@ -79,7 +79,7 @@ struct script_port { 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); + int (*feed_event)(void *handle, Evas *e, int event_type, int x, int y, int down, double timestamp); void *(*create)(const char *file, const char *option); int (*destroy)(void *handle); @@ -1367,7 +1367,7 @@ HAPI int script_handler_feed_event(struct script_info *info, int event, double t return LB_STATUS_ERROR_FAULT; } - return info->port->feed_event(info->port_data, e, event, info->x, info->y, timestamp); + return info->port->feed_event(info->port_data, e, event, info->x, info->y, info->down, timestamp); } /* End of a file */ diff --git a/src/server.c b/src/server.c index 4932f7f..a19a5cc 100644 --- a/src/server.c +++ b/src/server.c @@ -2379,7 +2379,141 @@ out: return result; } -static struct packet *client_pd_access_scroll(pid_t pid, int handle, const struct packet *packet) +static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const struct packet *packet) +{ + struct packet *result; + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + double timestamp; + int x; + int y; + struct inst_info *inst; + const struct pkg_info *pkg; + + 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, "ssdii", &pkgname, &id, ×tamp, &x, &y); + if (ret != 5) { + ErrPrint("Invalid parameter\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + /*! + * \NOTE: + * Trust the package name which are sent by the client. + * The package has to be a livebox package name. + */ + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + if (package_is_fault(pkg)) { + /*! + * \note + * If the package is registered as fault module, + * slave has not load it, so we don't need to do anything at here! + */ + DbgPrint("Package[%s] is faulted\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + // struct packet *packet; + + buffer = instance_pd_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + /* + packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_pd_script(inst); + if (!script) { + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + 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; + + 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: + 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_move(pid_t pid, int handle, const struct packet *packet) { struct packet *result; struct client_node *client; @@ -2513,6 +2647,140 @@ out: return result; } +static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const struct packet *packet) +{ + struct packet *result; + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + double timestamp; + int x; + int y; + struct inst_info *inst; + const struct pkg_info *pkg; + + 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, "ssdii", &pkgname, &id, ×tamp, &x, &y); + if (ret != 5) { + ErrPrint("Invalid parameter\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + /*! + * \NOTE: + * Trust the package name which are sent by the client. + * The package has to be a livebox package name. + */ + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + if (package_is_fault(pkg)) { + /*! + * \note + * If the package is registered as fault module, + * slave has not load it, so we don't need to do anything at here! + */ + DbgPrint("Package[%s] is faulted\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + // struct packet *packet; + + buffer = instance_pd_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + /* + packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_pd_script(inst); + if (!script) { + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, 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: + 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_unhighlight(pid_t pid, int handle, const struct packet *packet) { struct packet *result; @@ -4121,7 +4389,127 @@ out: return result; } -static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struct packet *packet) +static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet) +{ + struct packet *result; + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + double timestamp; + struct inst_info *inst; + const struct pkg_info *pkg; + int x; + int y; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Client %d is not exist\n", pid); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); + if (ret != 5) { + ErrPrint("Parameter is not matched\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + if (package_is_fault(pkg)) { + ret = LB_STATUS_ERROR_FAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Slave is not exists\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + /*! + * Enen if it fails to send packet, + * The packet will be unref'd + * So we don't need to check the ret value. + */ + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ErrPrint("Instance has no script\n"); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ErrPrint("Instance has no evas\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + 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; + + 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: + 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_move(pid_t pid, int handle, const struct packet *packet) { struct packet *result; struct client_node *client; @@ -4241,6 +4629,126 @@ out: return result; } +static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet) +{ + struct packet *result; + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + double timestamp; + struct inst_info *inst; + const struct pkg_info *pkg; + int x; + int y; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Client %d is not exist\n", pid); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); + if (ret != 5) { + ErrPrint("Parameter is not matched\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + if (package_is_fault(pkg)) { + ret = LB_STATUS_ERROR_FAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Slave is not exists\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + /*! + * Enen if it fails to send packet, + * The packet will be unref'd + * So we don't need to check the ret value. + */ + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ErrPrint("Instance has no script\n"); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ErrPrint("Instance has no evas\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + script_handler_update_pointer(script, x, y, 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: + 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; @@ -7030,14 +7538,22 @@ static struct method s_client_table[] = { .cmd = "pd_access_value_change", .handler = client_pd_access_value_change, }, - { - .cmd = "pd_access_scroll", - .handler = client_pd_access_scroll, - }, { .cmd = "pd_access_unhighlight", .handler = client_pd_access_unhighlight, }, + { + .cmd = "pd_access_scroll_down", + .handler = client_pd_access_scroll_down, + }, + { + .cmd = "pd_access_scroll_move", + .handler = client_pd_access_scroll_move, + }, + { + .cmd = "pd_access_scroll_up", + .handler = client_pd_access_scroll_up, + }, { .cmd = "lb_access_hl", @@ -7059,14 +7575,22 @@ static struct method s_client_table[] = { .cmd = "lb_access_value_change", .handler = client_lb_access_value_change, }, - { - .cmd = "lb_access_scroll", - .handler = client_lb_access_scroll, - }, { .cmd = "lb_access_unhighlight", .handler = client_lb_access_unhighlight, }, + { + .cmd = "lb_access_scroll_down", + .handler = client_lb_access_scroll_down, + }, + { + .cmd = "lb_access_scroll_move", + .handler = client_lb_access_scroll_move, + }, + { + .cmd = "lb_access_scroll_up", + .handler = client_lb_access_scroll_up, + }, { .cmd = "lb_key_down", diff --git a/src/util.c b/src/util.c index ad36896..194c762 100644 --- a/src/util.c +++ b/src/util.c @@ -146,6 +146,9 @@ HAPI int util_unlink(const char *filename) int desclen; int ret; + if (!filename) + return LB_STATUS_ERROR_INVALID; + desclen = strlen(filename) + 6; /* .desc */ descfile = malloc(desclen); if (!descfile) { @@ -199,6 +202,7 @@ HAPI unsigned long util_free_space(const char *path) } space = st.f_bsize * st.f_bfree; + DbgPrint("Available size: %lu, f_bsize: %lu, f_bfree: %lu\n", space, st.f_bsize, st.f_bfree); /*! * \note * Must have to check the overflow -- cgit v1.2.3