diff options
author | Sung-jae Park <nicesj.park@samsung.com> | 2013-01-25 11:06:42 +0000 |
---|---|---|
committer | Sung-jae Park <nicesj.park@samsung.com> | 2013-01-25 11:06:42 +0000 |
commit | c042b723a345e8efa249e41faf9be078fc8fa1d1 (patch) | |
tree | 48d6a9902752b906af39188f15c866a8400b640b | |
parent | ccf30194ef1448fc2fd6f4ed7953f0f97e14268e (diff) | |
download | data-provider-master-c042b723a345e8efa249e41faf9be078fc8fa1d1.tar.gz data-provider-master-c042b723a345e8efa249e41faf9be078fc8fa1d1.tar.bz2 data-provider-master-c042b723a345e8efa249e41faf9be078fc8fa1d1.zip |
Update liveinfo util, key down/up, accessibility
Change-Id: I50b0dc92adaffaca248758365392243a90c3a14b
-rw-r--r-- | packaging/org.tizen.data-provider-master.spec | 2 | ||||
-rw-r--r-- | src/group.c | 2 | ||||
-rw-r--r-- | src/instance.c | 8 | ||||
-rw-r--r-- | src/server.c | 1557 | ||||
-rw-r--r-- | src/slave_life.c | 40 | ||||
-rw-r--r-- | src/xmonitor.c | 3 | ||||
-rw-r--r-- | util_liveinfo/src/liveinfo.c | 142 |
7 files changed, 1662 insertions, 92 deletions
diff --git a/packaging/org.tizen.data-provider-master.spec b/packaging/org.tizen.data-provider-master.spec index e928c79..7d46e67 100644 --- a/packaging/org.tizen.data-provider-master.spec +++ b/packaging/org.tizen.data-provider-master.spec @@ -1,6 +1,6 @@ Name: org.tizen.data-provider-master Summary: Master data provider -Version: 0.14.4 +Version: 0.14.5 Release: 1 Group: main/app License: Flora License diff --git a/src/group.c b/src/group.c index 2b94e45..4b58aa9 100644 --- a/src/group.c +++ b/src/group.c @@ -474,7 +474,6 @@ HAPI int group_add_livebox(const char *group, const char *pkgname) struct context_info *info; struct context_item *item; char *key; - char *value; char *name; char *ptr; int len; @@ -493,7 +492,6 @@ HAPI int group_add_livebox(const char *group, const char *pkgname) ptr = (char *)group; len = 0; key = NULL; - value = NULL; /* Skip the first space characters */ while (*ptr && isspace(*ptr)) ptr++; diff --git a/src/instance.c b/src/instance.c index b96cb4f..59e228a 100644 --- a/src/instance.c +++ b/src/instance.c @@ -2194,7 +2194,6 @@ HAPI int instance_destroyed(struct inst_info *inst) */ HAPI int instance_recover_state(struct inst_info *inst) { - struct pkg_info *info; int ret = 0; if (inst->changing_state) { @@ -2215,7 +2214,6 @@ HAPI int instance_recover_state(struct inst_info *inst) break; case INST_DESTROYED: DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info)); - info = inst->info; instance_state_reset(inst); instance_destroy(inst); break; @@ -2263,11 +2261,8 @@ HAPI int instance_recover_state(struct inst_info *inst) HAPI int instance_need_slave(struct inst_info *inst) { int ret = 0; - struct pkg_info *info; if (inst->client && client_is_faulted(inst->client)) { - info = inst->info; - /*! * \note * In this case, the client is faulted(disconnected) @@ -2276,7 +2271,7 @@ HAPI int instance_need_slave(struct inst_info *inst) * remove it and don't try to recover its states */ - DbgPrint("CLIENT FAULT: Req. to DESTROYED (%s)\n", package_name(info)); + DbgPrint("CLIENT FAULT: Req. to DESTROYED (%s)\n", package_name(inst->info)); switch (inst->state) { case INST_INIT: case INST_ACTIVATED: @@ -2305,7 +2300,6 @@ HAPI int instance_need_slave(struct inst_info *inst) break; case INST_DESTROYED: DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info)); - info = inst->info; instance_state_reset(inst); instance_destroy(inst); break; diff --git a/src/server.c b/src/server.c index 201910e..d896eb8 100644 --- a/src/server.c +++ b/src/server.c @@ -671,7 +671,7 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + // struct packet *packet; buffer = instance_pd_buffer(inst); if (!buffer) { @@ -687,14 +687,17 @@ static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct 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 = -EFAULT; goto out; } + */ - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + 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; @@ -782,7 +785,7 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + // struct packet *packet; buffer = instance_pd_buffer(inst); if (!buffer) { @@ -798,14 +801,17 @@ static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct goto out; } + /* packet = packet_create_noack("pd_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); if (!packet) { ErrPrint("Failed to create a packet[%s]\n", pkgname); ret = -EFAULT; goto out; } + */ - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + 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; @@ -893,7 +899,7 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + // struct packet *packet; buffer = instance_pd_buffer(inst); if (!buffer) { @@ -909,14 +915,17 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p goto out; } + /* packet = packet_create_noack("pd_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y); if (!packet) { ErrPrint("Failed to create a packet[%s]\n", pkgname); ret = -EFAULT; goto out; } + */ - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + 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; @@ -1005,7 +1014,7 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + //struct packet *packet; buffer = instance_pd_buffer(inst); if (!buffer) { @@ -1021,14 +1030,17 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac goto out; } + /* packet = packet_create_noack("pd_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y); if (!packet) { ErrPrint("Failed to create a packet[%s]\n", pkgname); ret = -EFAULT; goto out; } + */ - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + 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; @@ -1344,7 +1356,7 @@ static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + //struct packet *packet; buffer = instance_lb_buffer(inst); if (!buffer) { @@ -1360,14 +1372,16 @@ static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct goto out; } + /* packet = packet_create_noack("lb_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y); if (!packet) { ErrPrint("Failed to create a packet[%s]\n", pkgname); ret = -EFAULT; goto out; } - - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + */ + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { struct script_info *script; Evas *e; @@ -1455,7 +1469,7 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + //struct packet *packet; buffer = instance_lb_buffer(inst); if (!buffer) { @@ -1471,14 +1485,17 @@ static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct goto out; } + /* packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); if (!packet) { ErrPrint("Failed to create a packet[%s]\n", pkgname); ret = -EFAULT; goto out; } + */ - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { struct script_info *script; Evas *e; @@ -1566,7 +1583,7 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + // struct packet *packet; buffer = instance_lb_buffer(inst); if (!buffer) { @@ -1582,14 +1599,17 @@ static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct p goto out; } + /* packet = packet_create_noack("lb_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y); if (!packet) { ErrPrint("Failed to create a packet[%s]\n", pkgname); ret = -EFAULT; goto out; } + */ - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { struct script_info *script; Evas *e; @@ -1678,7 +1698,7 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { struct buffer_info *buffer; struct slave_node *slave; - struct packet *packet; + //struct packet *packet; buffer = instance_lb_buffer(inst); if (!buffer) { @@ -1694,14 +1714,17 @@ static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct pac goto out; } + /* packet = packet_create_noack("lb_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y); if (!packet) { ErrPrint("Failed to create a packet[%s]\n", pkgname); ret = -EFAULT; goto out; } + */ - ret = slave_rpc_request_only(slave, pkgname, packet, 0); + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { struct script_info *script; Evas *e; @@ -1732,6 +1755,1404 @@ out: return NULL; } +static struct packet *client_pd_access_read(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } 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 = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + 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 = -EFAULT; + 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 = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + /*! + * \TODO: Push up the ACCESS_READ event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_pd_access_read_prev(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } 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 = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + 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 = -EFAULT; + 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 = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + /*! + * \TODO: Push up the ACCESS_READ_PREV event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_pd_access_read_next(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } 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 = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + 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 = -EFAULT; + 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 = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + /*! + * \TODO: Push up the ACCESS_READ_NEXT event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } 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 = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + 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 = -EFAULT; + 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 = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + /*! + * \TODO: Push up the ACCESS_READ_ACTIVATE event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } 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 = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + 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 = -EFAULT; + 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 = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + /*! + * \TODO: Push up the KEY_DOWN event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } 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 = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + 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 = -EFAULT; + 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 = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + /*! + * \TODO: Push up the KEY_UP event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_lb_access_read(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Parameter is not matched\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + //struct packet *packet; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + goto out; + } + + /* + packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = -EFAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ret = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + + /*! + * \TODO: Feed up this ACCESS_READ event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_lb_access_read_prev(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Parameter is not matched\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + //struct packet *packet; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + goto out; + } + + /* + packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = -EFAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ret = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + + /*! + * \TODO: Feed up this ACCESS_READ_PREV event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_lb_access_read_next(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Parameter is not matched\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + //struct packet *packet; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + goto out; + } + + /* + packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = -EFAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ret = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + + /*! + * \TODO: Feed up this ACCESS_READ_NEXT event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Parameter is not matched\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + //struct packet *packet; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + goto out; + } + + /* + packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = -EFAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ret = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + + /*! + * \TODO: Feed up this ACCESS_ACTIVATE event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Parameter is not matched\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + //struct packet *packet; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + goto out; + } + + /* + packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = -EFAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ret = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + + /*! + * \TODO: Feed up this KEY_DOWN event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + +static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + int w; + int h; + double timestamp; + double x; + double 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 = -ENOENT; + goto out; + } + + ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y); + if (ret != 7) { + ErrPrint("Parameter is not matched\n"); + ret = -EINVAL; + 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 = -ENOENT; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = -EFAULT; + 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 = -EFAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + //struct packet *packet; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = -EFAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = -EINVAL; + goto out; + } + + /* + packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = -EFAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ret = -EFAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = -EFAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, -1); + + /*! + * \TODO: Feed up this KEY_UP event + */ + ret = 0; + } else { + ErrPrint("Unsupported package\n"); + ret = -EINVAL; + } + +out: + /*! \note No reply packet */ + return NULL; +} + static int release_pixmap_cb(struct client_node *client, void *canvas) { DbgPrint("Forcely unref the \"buffer\"\n"); @@ -3269,9 +4690,6 @@ static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct pa if (!fp) goto out; - fprintf(fp, "----------------------------------------------------------------------[Slave List]------------------------------------------------------------------------------\n"); - fprintf(fp, " pid slave name package name abi secured refcnt fault state inst pkg ttl \n"); - fprintf(fp, "----------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); list = (Eina_List *)slave_list(); EINA_LIST_FOREACH(list, l, slave) { fprintf(fp, " %7d %20s %39s %7s %7s %6d %5d %21s %4d %3d %3.4lf \n", @@ -3288,6 +4706,7 @@ static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct pa slave_ttl(slave) ); } + fprintf(fp, "EOD\n"); liveinfo_close_fifo(info); out: @@ -3332,7 +4751,7 @@ static struct packet *liveinfo_slave_load(pid_t pid, int handle, const struct pa if (package_slave(pkg) == slave) fprintf(fp, "%s, ", package_name(pkg)); } - fprintf(fp, "}\n"); + fprintf(fp, "}\nEOD\n"); liveinfo_close_fifo(info); @@ -3396,10 +4815,6 @@ static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct pac goto out; } - fprintf(fp, "-----------------------------------------------[Instance List]---------------------------------------\n"); - fprintf(fp, " ID | Cluster ID | Sub cluster ID | Period | Visibility | Width | Height \n"); - fprintf(fp, "-----------------------------------------------------------------------------------------------------\n"); - inst_list = package_instance_list(pkg); EINA_LIST_FOREACH(inst_list, l, inst) { fprintf(fp, " %18s %18s %18s %3.3lf %10s %5d %6d\n", @@ -3412,6 +4827,7 @@ static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct pac instance_lb_height(inst)); } + fprintf(fp, "EOD\n"); liveinfo_close_fifo(info); out: @@ -3447,9 +4863,6 @@ static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct pack if (!fp) goto out; - fprintf(fp, "+----------------------------------------------[Package List]------------------------------------------------+\n"); - fprintf(fp, " pid slave name package name abi refcnt fault inst \n"); - fprintf(fp, "+------------------------------------------------------------------------------------------------------------+\n"); list = (Eina_List *)package_list(); EINA_LIST_FOREACH(list, l, pkg) { slave = package_slave(pkg); @@ -3474,6 +4887,7 @@ static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct pack eina_list_count(inst_list) ); } + fprintf(fp, "EOD\n"); liveinfo_close_fifo(info); out: @@ -3490,6 +4904,36 @@ static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct pack return NULL; } +static struct packet *liveinfo_toggle_debug(pid_t pid, int handle, const struct packet *packet) +{ + double timestamp; + struct liveinfo *info; + FILE *fp; + + if (packet_get(packet, "d", ×tamp) != 1) { + ErrPrint("Invalid argument\n"); + goto out; + } + + info = liveinfo_find_by_pid(pid); + if (!info) { + ErrPrint("Invalid request\n"); + goto out; + } + + liveinfo_open_fifo(info); + fp = liveinfo_fifo(info); + if (!fp) + goto out; + + g_conf.debug_mode = !g_conf.debug_mode; + fprintf(fp, "Debug mode is %s\nEOD\n", g_conf.debug_mode ? "enabled" : "disabled"); + liveinfo_close_fifo(info); + +out: + return NULL; +} + static struct method s_info_table[] = { { .cmd = "liveinfo_hello", @@ -3520,6 +4964,10 @@ static struct method s_info_table[] = { .handler = liveinfo_pkg_ctrl, }, { + .cmd = "toggle_debug", + .handler = liveinfo_toggle_debug, + }, + { .cmd = NULL, .handler = NULL, }, @@ -3658,6 +5106,59 @@ static struct method s_client_table[] = { .cmd = "refresh_group", .handler = client_refresh_group, }, + + { + .cmd = "pd_access_read", + .handler = client_pd_access_read, + }, + { + .cmd = "pd_access_read_prev", + .handler = client_pd_access_read_prev, + }, + { + .cmd = "pd_access_read_next", + .handler = client_pd_access_read_next, + }, + { + .cmd = "pd_access_activate", + .handler = client_pd_access_activate, + }, + + { + .cmd = "lb_access_read", + .handler = client_lb_access_read, + }, + { + .cmd = "lb_access_read_prev", + .handler = client_lb_access_read_prev, + }, + { + .cmd = "lb_access_read_next", + .handler = client_lb_access_read_next, + }, + { + .cmd = "lb_access_activate", + .handler = client_lb_access_activate, + }, + + { + .cmd = "lb_key_down", + .handler = client_lb_key_down, + }, + { + .cmd = "lb_key_up", + .handler = client_lb_key_up, + }, + + { + .cmd = "pd_key_down", + .handler = client_pd_key_down, + }, + { + .cmd = "pd_key_up", + .handler = client_pd_key_up, + }, + { .cmd = NULL, .handler = NULL, diff --git a/src/slave_life.c b/src/slave_life.c index 252f953..771fe3d 100644 --- a/src/slave_life.c +++ b/src/slave_life.c @@ -369,7 +369,6 @@ static inline void invoke_activate_cb(struct slave_node *slave) HAPI int slave_activate(struct slave_node *slave) { - bundle *param; /*! * \note @@ -383,25 +382,32 @@ HAPI int slave_activate(struct slave_node *slave) if (slave->pid != (pid_t)-1) return -EALREADY; - param = bundle_create(); - if (!param) { - ErrPrint("Failed to create a bundle\n"); - return -EFAULT; - } + if (DEBUG_MODE) { + DbgPrint("Debug Mode enabled. name[%s] secured[%d] abi[%s]\n", slave->name, slave->secured, slave->abi); + } else { + bundle *param; + param = bundle_create(); + if (!param) { + ErrPrint("Failed to create a bundle\n"); + return -EFAULT; + } - bundle_add(param, BUNDLE_SLAVE_NAME, slave->name); - bundle_add(param, BUNDLE_SLAVE_SECURED, slave->secured ? "true" : "false"); - bundle_add(param, BUNDLE_SLAVE_ABI, slave->abi); - DbgPrint("Launch the slave package: %s\n", slave->pkgname); - slave->pid = (pid_t)aul_launch_app(slave->pkgname, param); - bundle_free(param); + bundle_add(param, BUNDLE_SLAVE_NAME, slave->name); + bundle_add(param, BUNDLE_SLAVE_SECURED, slave->secured ? "true" : "false"); + bundle_add(param, BUNDLE_SLAVE_ABI, slave->abi); - if (slave->pid < 0) { - ErrPrint("Failed to launch a new slave %s (%d)\n", slave->name, slave->pid); - slave->pid = (pid_t)-1; - return -EFAULT; + DbgPrint("Launch the slave package: %s\n", slave->pkgname); + slave->pid = (pid_t)aul_launch_app(slave->pkgname, param); + + bundle_free(param); + + if (slave->pid < 0) { + ErrPrint("Failed to launch a new slave %s (%d)\n", slave->name, slave->pid); + slave->pid = (pid_t)-1; + return -EFAULT; + } + DbgPrint("Slave launched %d for %s\n", slave->pid, slave->name); } - DbgPrint("Slave launched %d for %s\n", slave->pid, slave->name); slave->state = SLAVE_REQUEST_TO_LAUNCH; /*! diff --git a/src/xmonitor.c b/src/xmonitor.c index a587cd7..c3924c5 100644 --- a/src/xmonitor.c +++ b/src/xmonitor.c @@ -119,8 +119,7 @@ static Eina_Bool create_cb(void *data, int type, void *event) static Eina_Bool destroy_cb(void *data, int type, void *event) { - Ecore_X_Event_Window_Destroy * info; - info = event; + // Ecore_X_Event_Window_Destroy *info = event; return ECORE_CALLBACK_PASS_ON; } diff --git a/util_liveinfo/src/liveinfo.c b/util_liveinfo/src/liveinfo.c index ab3dcf8..41f82ad 100644 --- a/util_liveinfo/src/liveinfo.c +++ b/util_liveinfo/src/liveinfo.c @@ -21,6 +21,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <termios.h> #include <glib.h> #include <glib-object.h> @@ -31,23 +32,26 @@ #include <Ecore.h> +#define PROMPT "liveinfo) " + static struct info { int fifo_handle; int fd; Ecore_Fd_Handler *fd_handler; Ecore_Fd_Handler *in_handler; + int input_fd; } s_info = { .fifo_handle = -EINVAL, .fd = -EINVAL, .fd_handler = NULL, .in_handler = NULL, + .input_fd = -1, }; static void send_slave_list(void) { struct packet *packet; - printf("Send request SLAVE LIST\n"); packet = packet_create_noack("slave_list", "d", 0.0f); if (!packet) { fprintf(stderr, "Failed to create a packet\n"); @@ -56,13 +60,16 @@ static void send_slave_list(void) com_core_packet_send_only(s_info.fd, packet); packet_destroy(packet); + + printf("----------------------------------------------------------------------[Slave List]------------------------------------------------------------------------------\n"); + printf(" pid slave name package name abi secured refcnt fault state inst pkg ttl \n"); + printf("----------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); } static void send_pkg_list(void) { struct packet *packet; - printf("Send request PACKAGE LIST\n"); packet = packet_create_noack("pkg_list", "d", 0.0f); if (!packet) { fprintf(stderr, "Failed to create a packet\n"); @@ -71,13 +78,30 @@ static void send_pkg_list(void) com_core_packet_send_only(s_info.fd, packet); packet_destroy(packet); + + printf("+----------------------------------------------[Package List]------------------------------------------------+\n"); + printf(" pid slave name package name abi refcnt fault inst \n"); + printf("+------------------------------------------------------------------------------------------------------------+\n"); +} + +static void send_toggle_debug(void) +{ + struct packet *packet; + + packet = packet_create_noack("toggle_debug", "d", 0.0f); + if (!packet) { + fprintf(stderr, "Failed to create a packet\n"); + return; + } + + com_core_packet_send_only(s_info.fd, packet); + packet_destroy(packet); } static void send_slave_load(pid_t pid) { struct packet *packet; - printf("Send request Loaded package list\n"); packet = packet_create_noack("slave_load", "i", pid); if (!packet) { fprintf(stderr, "Failed to create a packet\n"); @@ -92,7 +116,6 @@ static void send_inst_list(const char *pkgname) { struct packet *packet; - printf("Send request instance list\n"); packet = packet_create_noack("inst_list", "s", pkgname); if (!packet) { fprintf(stderr, "Failed to create a packet\n"); @@ -101,6 +124,10 @@ static void send_inst_list(const char *pkgname) com_core_packet_send_only(s_info.fd, packet); packet_destroy(packet); + + printf("-----------------------------------------------[Instance List]---------------------------------------\n"); + printf(" ID | Cluster ID | Sub cluster ID | Period | Visibility | Width | Height \n"); + printf("-----------------------------------------------------------------------------------------------------\n"); } static inline void help(void) @@ -111,6 +138,7 @@ static inline void help(void) printf("[33mslave_list[0m - Display the slave list\n"); printf("[33minst_list[0m [37mLIVEBOX_PKGNAME[0m - Display the instance list of this LIVEBOX_PKGNAME\n"); printf("[33mslave_load[0m [37mSLAVE_PID[0m - Display the loaded livebox instance list on the given slave\n"); + printf("[33mtoggle_debug[0m - Enable/Disable debug mode\n"); printf("[32mexit - [0m\n"); printf("[32mquit - [0m\n"); printf("----------------------------------------------------------------------------\n"); @@ -119,30 +147,40 @@ static inline void help(void) static inline void do_command(const char *cmd) { char command[256]; - char argument[256]; - - if (sscanf(cmd, "%255[^ ] %255s", command, argument) == 2) { - if (!strcasecmp(command, "inst_list")) { - send_inst_list(argument); - } else if (!strcasecmp(command, "slave_load")) { - pid_t pid; - if (sscanf(argument, "%d", &pid) == 1) - send_slave_load(pid); - } else { - help(); - } + char argument[256] = { '\0', }; + + if (sscanf(cmd, "%255[^ ] %255s", command, argument) == 2) + cmd = command; + + if (!strcasecmp(cmd, "inst_list") && *argument) { + send_inst_list(argument); + } else if (!strcasecmp(cmd, "slave_load") && *argument) { + pid_t pid; + + if (sscanf(argument, "%d", &pid) == 1) + send_slave_load(pid); + else + goto errout; + } else if (!strcasecmp(cmd, "pkg_list")) { + send_pkg_list(); + } else if (!strcasecmp(cmd, "slave_list")) { + send_slave_list(); + } else if (!strcasecmp(cmd, "exit") || !strcasecmp(cmd, "quit")) { + ecore_main_loop_quit(); + } else if (!strcasecmp(cmd, "toggle_debug")) { + send_toggle_debug(); + } else if (!strcasecmp(cmd, "help")) { + goto errout; } else { - if (!strcasecmp(cmd, "pkg_list")) - send_pkg_list(); - else if (!strcasecmp(cmd, "slave_list")) - send_slave_list(); - else if (!strcasecmp(cmd, "exit")) - ecore_main_loop_quit(); - else if (!strcasecmp(cmd, "quit")) - ecore_main_loop_quit(); - else if (!strcasecmp(cmd, "help")) - help(); + printf("Unknown command - \"help\"\n"); + fputs(PROMPT, stdout); } + + return; + +errout: + help(); + fputs(PROMPT, stdout); } static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler) @@ -171,19 +209,25 @@ static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler) switch (ch) { case 0x08: /* BKSP */ - printf("\033[3D"); + cmd_buffer[idx] = '\0'; if (idx > 0) idx--; + cmd_buffer[idx] = ' '; + printf("\r"PROMPT"%s", cmd_buffer); /* Cleare the last bytes */ + cmd_buffer[idx] = '\0'; + printf("\r"PROMPT"%s", cmd_buffer); /* Cleare the last bytes */ break; case '\n': case '\r': cmd_buffer[idx] = '\0'; idx = 0; - printf("\n"); + putc((int)'\n', stdout); do_command(cmd_buffer); + memset(cmd_buffer, 0, sizeof(cmd_buffer)); break; default: cmd_buffer[idx++] = ch; + putc((int)ch, stdout); if (idx == sizeof(cmd_buffer) - 1) { cmd_buffer[idx] = '\0'; printf("\nCommand buffer is overflow: %s\n", cmd_buffer); @@ -198,8 +242,8 @@ static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler) static Eina_Bool read_cb(void *data, Ecore_Fd_Handler *fd_handler) { int fd; - char buffer[1024]; - int len; + static const char *eod = "EOD\n"; + char ch; fd = ecore_main_fd_handler_fd_get(fd_handler); if (fd < 0) { @@ -207,12 +251,18 @@ static Eina_Bool read_cb(void *data, Ecore_Fd_Handler *fd_handler) return ECORE_CALLBACK_RENEW; } - while ((len = read(fd, buffer, sizeof(buffer) - 1)) > 0) { - buffer[len] = '\0'; - fputs(buffer, stdout); - } + read(fd, &ch, sizeof(ch)); + if (ch == *eod) + eod++; + else + eod = "EOD\n"; + + putc(ch, stdout); - fflush(stdout); + if (*eod == '\0') { + fputs(PROMPT, stdout); + eod = "EOD\n"; + } return ECORE_CALLBACK_RENEW; } @@ -251,6 +301,10 @@ static int ret_cb(pid_t pid, int handle, const struct packet *packet, void *data return -EFAULT; } + fputs(PROMPT, stdout); + if (fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK) < 0) + fprintf(stderr, "Error: %s\n", strerror(errno)); + s_info.in_handler = ecore_main_fd_handler_add(STDIN_FILENO, ECORE_FD_READ, input_cb, NULL, NULL, NULL); if (!s_info.in_handler) { fprintf(stderr, "Failed to add a input handler\n"); @@ -298,6 +352,7 @@ static int connected_cb(int handle, void *data) int main(int argc, char *argv[]) { + struct termios ttystate; static struct method s_table[] = { { .cmd = NULL, @@ -319,8 +374,25 @@ int main(int argc, char *argv[]) printf("Type your command on below empty line\n"); + if (tcgetattr(STDIN_FILENO, &ttystate) < 0) { + fprintf(stderr, "Error: %s\n", strerror(errno)); + } else { + ttystate.c_lflag &= ~(ICANON | ECHO); + ttystate.c_cc[VMIN] = 1; + + if (tcsetattr(STDIN_FILENO, TCSANOW, &ttystate) < 0) + fprintf(stderr, "Error: %s\n", strerror(errno)); + } + + if (setvbuf(stdout, (char *)NULL, _IONBF, 0) != 0) + fprintf(stderr, "Error: %s\n", strerror(errno)); + ecore_main_loop_begin(); + ttystate.c_lflag |= ICANON | ECHO; + if (tcsetattr(STDIN_FILENO, TCSANOW, &ttystate) < 0) + fprintf(stderr, "Error: %s\n", strerror(errno)); + if (s_info.fd > 0) { com_core_packet_client_fini(s_info.fd); s_info.fd = -EINVAL; |