2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <Ecore_Evas.h> /* fb.h */
28 #include <com-core_packet.h>
29 #include <livebox-errno.h>
30 #include <livebox-service.h>
35 #include "slave_life.h"
36 #include "slave_rpc.h"
37 #include "client_life.h"
39 #include "client_rpc.h"
41 #include "script_handler.h"
42 #include "buffer_handler.h"
44 #include "fault_manager.h"
45 #include "fb.h" /* fb_type */
65 /* Share this with provider */
72 struct access_cbdata {
74 struct inst_info *inst;
78 struct client_node *client;
79 struct inst_info *inst;
82 static Eina_Bool lazy_access_status_cb(void *data)
84 struct access_cbdata *cbdata = data;
86 if (instance_unref(cbdata->inst)) {
87 instance_send_access_status(cbdata->inst, cbdata->status);
89 DbgPrint("Skip sending access status (%d)\n", cbdata->status);
92 * If instance_unref returns NULL,
93 * The instance is destroyed. it means, we don't need to send event to the viewer
96 return ECORE_CALLBACK_CANCEL;
99 static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
101 struct inst_info *inst = data;
102 const struct pkg_info *pkg;
103 struct slave_node *slave;
104 struct packet *packet;
107 pkg = instance_package(inst);
109 return LB_STATUS_ERROR_INVALID;
111 slave = package_slave(pkg);
113 return LB_STATUS_ERROR_INVALID;
116 case EVENT_STATE_ACTIVATE:
117 cmdstr = "lb_mouse_down";
119 case EVENT_STATE_ACTIVATED:
120 cmdstr = "lb_mouse_move";
122 case EVENT_STATE_DEACTIVATE:
123 cmdstr = "lb_mouse_up";
126 return LB_STATUS_ERROR_INVALID;
129 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
131 return LB_STATUS_ERROR_FAULT;
133 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
136 static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
138 struct script_info *script;
139 struct inst_info *inst = data;
140 const struct pkg_info *pkg;
144 pkg = instance_package(inst);
148 script = instance_lb_script(inst);
150 return LB_STATUS_ERROR_FAULT;
152 e = script_handler_evas(script);
154 return LB_STATUS_ERROR_FAULT;
156 timestamp = util_timestamp();
159 case EVENT_STATE_ACTIVATE:
160 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
161 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
163 case EVENT_STATE_ACTIVATED:
164 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
165 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
167 case EVENT_STATE_DEACTIVATE:
168 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
169 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
178 static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
180 struct inst_info *inst = data;
181 const struct pkg_info *pkg;
182 struct slave_node *slave;
183 struct packet *packet;
186 pkg = instance_package(inst);
188 return LB_STATUS_ERROR_INVALID;
190 slave = package_slave(pkg);
192 return LB_STATUS_ERROR_INVALID;
194 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
196 case EVENT_STATE_ACTIVATE:
197 cmdstr = "pd_mouse_down";
199 case EVENT_STATE_ACTIVATED:
200 cmdstr = "pd_mouse_move";
202 case EVENT_STATE_DEACTIVATE:
203 cmdstr = "pd_mouse_up";
206 return LB_STATUS_ERROR_INVALID;
209 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
211 return LB_STATUS_ERROR_FAULT;
213 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
216 static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
218 struct script_info *script;
219 struct inst_info *inst = data;
220 const struct pkg_info *pkg;
224 pkg = instance_package(inst);
228 script = instance_pd_script(inst);
230 return LB_STATUS_ERROR_FAULT;
232 e = script_handler_evas(script);
234 return LB_STATUS_ERROR_FAULT;
236 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
237 timestamp = util_timestamp();
240 case EVENT_STATE_ACTIVATE:
241 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
242 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
244 case EVENT_STATE_ACTIVATED:
245 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
246 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
248 case EVENT_STATE_DEACTIVATE:
249 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
250 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
258 static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
260 struct client_node *client;
261 struct packet *result;
265 client = client_find_by_pid(pid);
267 ErrPrint("Client is already exists %d\n", pid);
268 ret = LB_STATUS_ERROR_EXIST;
272 if (packet_get(packet, "d", ×tamp) != 1) {
273 ErrPrint("Invalid arguemnt\n");
274 ret = LB_STATUS_ERROR_INVALID;
281 * client_create will invoke the client created callback
283 client = client_create(pid, handle);
285 ErrPrint("Failed to create a new client for %d\n", pid);
286 ret = LB_STATUS_ERROR_FAULT;
290 result = packet_create_reply(packet, "i", ret);
292 ErrPrint("Failed to create a packet\n");
297 static struct packet *cilent_release(pid_t pid, int handle, const struct packet *packet) /*!< pid, ret */
299 struct client_node *client;
300 struct packet *result;
303 client = client_find_by_pid(pid);
305 ErrPrint("Client %d is not exists\n", pid);
306 ret = LB_STATUS_ERROR_NOT_EXIST;
310 client_destroy(client);
314 result = packet_create_reply(packet, "i", ret);
316 ErrPrint("Failed to create a packet\n");
321 /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
322 static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
324 struct client_node *client;
332 struct inst_info *inst;
334 client = client_find_by_pid(pid);
336 ErrPrint("Client %d is not exists\n", pid);
340 ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
342 ErrPrint("Parameter is not matched\n");
346 DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%lf] y[%lf]\n", pid, pkgname, id, event, timestamp, x, y);
350 * Trust the package name which are sent by the client.
351 * The package has to be a livebox package name.
353 inst = package_find_instance_by_id(pkgname, id);
355 ErrPrint("Instance is not exists\n");
356 else if (package_is_fault(instance_package(inst)))
357 ErrPrint("Fault package\n");
359 (void)instance_clicked(inst, event, timestamp, x, y);
362 /*! \note No reply packet */
366 static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet)
368 struct packet *result;
369 struct client_node *client;
374 struct inst_info *inst;
376 client = client_find_by_pid(pid);
378 ErrPrint("Client %d is not exists\n", pid);
379 ret = LB_STATUS_ERROR_INVALID;
383 ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
385 ErrPrint("Invalid argument\n");
386 ret = LB_STATUS_ERROR_INVALID;
390 inst = package_find_instance_by_id(pkgname, id);
392 ErrPrint("Instance is not exists\n");
393 ret = LB_STATUS_ERROR_NOT_EXIST;
394 } else if (package_is_fault(instance_package(inst))) {
395 ErrPrint("Fault package\n");
396 ret = LB_STATUS_ERROR_FAULT;
400 * Send change update mode request to a slave
402 ret = instance_set_update_mode(inst, active_update);
406 result = packet_create_reply(packet, "i", ret);
408 ErrPrint("Failed to create a packet\n");
413 /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
414 static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
416 struct client_node *client;
417 struct packet *result;
420 const char *emission;
426 struct inst_info *inst;
429 client = client_find_by_pid(pid);
431 ErrPrint("Client %d is not exists\n", pid);
432 ret = LB_STATUS_ERROR_NOT_EXIST;
436 ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
438 ErrPrint("Parameter is not matched\n");
439 ret = LB_STATUS_ERROR_INVALID;
443 DbgPrint("pid[%d] pkgname[%s] id[%s] emission[%s] source[%s] sx[%lf] sy[%lf] ex[%lf] ey[%lf]\n", pid, pkgname, id, emission, source, sx, sy, ex, ey);
447 * Trust the package name which are sent by the client.
448 * The package has to be a livebox package name.
450 inst = package_find_instance_by_id(pkgname, id);
452 ret = LB_STATUS_ERROR_NOT_EXIST;
453 else if (package_is_fault(instance_package(inst)))
454 ret = LB_STATUS_ERROR_FAULT;
456 ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
459 result = packet_create_reply(packet, "i", ret);
461 ErrPrint("Failed to create a packet\n");
466 static Eina_Bool lazy_delete_cb(void *data)
468 struct deleted_item *item = data;
470 DbgPrint("Send delete event to the client\n");
473 * Before invoke this callback, the instance is able to already remove this client
476 if (instance_has_client(item->inst, item->client)) {
477 instance_unicast_deleted_event(item->inst, item->client);
478 instance_del_client(item->inst, item->client);
481 client_unref(item->client);
482 instance_unref(item->inst);
484 return ECORE_CALLBACK_CANCEL;
487 static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
489 struct client_node *client;
490 struct packet *result;
493 struct inst_info *inst;
496 client = client_find_by_pid(pid);
498 ErrPrint("Client %d is not exists\n", pid);
499 ret = LB_STATUS_ERROR_NOT_EXIST;
503 ret = packet_get(packet, "ss", &pkgname, &id);
505 ErrPrint("Parameter is not matched\n");
506 ret = LB_STATUS_ERROR_INVALID;
510 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
514 * Trust the package name which are sent by the client.
515 * The package has to be a livebox package name.
517 inst = package_find_instance_by_id(pkgname, id);
519 ret = LB_STATUS_ERROR_NOT_EXIST;
520 } else if (package_is_fault(instance_package(inst))) {
521 ret = LB_STATUS_ERROR_FAULT;
522 } else if (instance_client(inst) != client) {
523 if (instance_has_client(inst, client)) {
524 struct deleted_item *item;
526 item = malloc(sizeof(*item));
528 ErrPrint("Heap: %s\n", strerror(errno));
529 ret = LB_STATUS_ERROR_MEMORY;
533 * Send DELETED EVENT to the client.
534 * after return from this function.
536 * Client will prepare the deleted event after get this function's return value.
537 * So We have to make a delay to send a deleted event.
540 item->client = client_ref(client);
541 item->inst = instance_ref(inst);
543 if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
544 ErrPrint("Failed to add a delayzed delete callback\n");
545 client_unref(client);
546 instance_unref(inst);
548 ret = LB_STATUS_ERROR_FAULT;
550 ret = LB_STATUS_SUCCESS;
554 ret = LB_STATUS_ERROR_PERMISSION;
557 ret = instance_destroy(inst);
561 result = packet_create_reply(packet, "i", ret);
563 ErrPrint("Failed to create a packet\n");
568 static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
570 struct client_node *client;
571 struct packet *result;
576 struct inst_info *inst;
579 client = client_find_by_pid(pid);
581 ErrPrint("Client %d is not exists\n", pid);
582 ret = LB_STATUS_ERROR_NOT_EXIST;
586 ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
588 ErrPrint("Parameter is not matched\n");
589 ret = LB_STATUS_ERROR_INVALID;
593 DbgPrint("pid[%d] pkgname[%s] id[%s] w[%d] h[%d]\n", pid, pkgname, id, w, h);
594 DbgPrint("RESIZE: INSTANCE[%s] Client request resize to %dx%d\n", id, w, h);
598 * Trust the package name which are sent by the client.
599 * The package has to be a livebox package name.
601 inst = package_find_instance_by_id(pkgname, id);
603 ret = LB_STATUS_ERROR_NOT_EXIST;
604 } else if (package_is_fault(instance_package(inst))) {
605 ret = LB_STATUS_ERROR_FAULT;
606 } else if (instance_client(inst) != client) {
607 ret = LB_STATUS_ERROR_PERMISSION;
609 ret = instance_resize(inst, w, h);
613 result = packet_create_reply(packet, "i", ret);
615 ErrPrint("Failed to create a packet\n");
620 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
622 struct client_node *client;
623 struct packet *result;
627 const char *category;
631 struct pkg_info *info;
636 client = client_find_by_pid(pid);
638 ErrPrint("Client %d is not exists\n", pid);
639 ret = LB_STATUS_ERROR_NOT_EXIST;
643 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
645 ErrPrint("Parameter is not matched\n");
646 ret = LB_STATUS_ERROR_INVALID;
650 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
651 pid, timestamp, pkgname, content, cluster, category, period);
653 lb_pkgname = package_lb_pkgname(pkgname);
655 ErrPrint("This %s has no livebox package\n", pkgname);
656 ret = LB_STATUS_ERROR_INVALID;
660 info = package_find(lb_pkgname);
662 info = package_create(lb_pkgname);
665 ret = LB_STATUS_ERROR_FAULT;
666 } else if (package_is_fault(info)) {
667 ret = LB_STATUS_ERROR_FAULT;
668 } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
669 ErrPrint("Not enough space\n");
670 ret = LB_STATUS_ERROR_NO_SPACE;
672 struct inst_info *inst;
674 if (period > 0.0f && period < MINIMUM_PERIOD)
675 period = MINIMUM_PERIOD;
677 inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
680 * Using the "inst" without validate its value is at my disposal. ;)
682 ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
688 result = packet_create_reply(packet, "i", ret);
690 ErrPrint("Failed to create a packet\n");
695 static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
697 struct client_node *client;
700 enum livebox_visible_state state;
702 struct inst_info *inst;
704 client = client_find_by_pid(pid);
706 ErrPrint("Client %d is not exists\n", pid);
707 ret = LB_STATUS_ERROR_NOT_EXIST;
711 ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
713 ErrPrint("Parameter is not matched\n");
714 ret = LB_STATUS_ERROR_INVALID;
718 DbgPrint("pid[%d] pkgname[%s] id[%s] state[%d]\n", pid, pkgname, id, state);
722 * Trust the package name which are sent by the client.
723 * The package has to be a livebox package name.
725 inst = package_find_instance_by_id(pkgname, id);
727 ret = LB_STATUS_ERROR_NOT_EXIST;
728 } else if (package_is_fault(instance_package(inst))) {
729 ret = LB_STATUS_ERROR_FAULT;
730 } else if (instance_client(inst) != client) {
731 ret = LB_STATUS_ERROR_PERMISSION;
733 ret = instance_set_visible_state(inst, state);
737 /*! \note No reply packet */
741 static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
743 struct client_node *client;
744 struct packet *result;
749 struct inst_info *inst;
751 client = client_find_by_pid(pid);
753 ErrPrint("Client %d is not exists\n", pid);
754 ret = LB_STATUS_ERROR_NOT_EXIST;
758 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
760 ErrPrint("Parameter is not matched\n");
761 ret = LB_STATUS_ERROR_INVALID;
765 DbgPrint("pid[%d] pkgname[%s] id[%s] period[%lf]\n", pid, pkgname, id, period);
769 * Trust the package name which are sent by the client.
770 * The package has to be a livebox package name.
772 inst = package_find_instance_by_id(pkgname, id);
774 ret = LB_STATUS_ERROR_NOT_EXIST;
775 } else if (package_is_fault(instance_package(inst))) {
776 ret = LB_STATUS_ERROR_FAULT;
777 } else if (instance_client(inst) != client) {
778 ret = LB_STATUS_ERROR_PERMISSION;
780 ret = instance_set_period(inst, period);
784 result = packet_create_reply(packet, "i", ret);
786 ErrPrint("Failed to create a packet\n");
791 static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
793 struct client_node *client;
794 struct packet *result;
798 const char *category;
799 struct inst_info *inst;
802 client = client_find_by_pid(pid);
804 ErrPrint("Client %d is not exists\n", pid);
805 ret = LB_STATUS_ERROR_NOT_EXIST;
809 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
811 ErrPrint("Parameter is not matched\n");
812 ret = LB_STATUS_ERROR_INVALID;
816 DbgPrint("pid[%d] pkgname[%s] id[%s] cluster[%s] category[%s]\n", pid, pkgname, id, cluster, category);
820 * Trust the package name which are sent by the client.
821 * The package has to be a livebox package name.
823 inst = package_find_instance_by_id(pkgname, id);
825 ret = LB_STATUS_ERROR_NOT_EXIST;
826 } else if (package_is_fault(instance_package(inst))) {
827 ret = LB_STATUS_ERROR_FAULT;
828 } else if (instance_client(inst) != client) {
829 ret = LB_STATUS_ERROR_PERMISSION;
831 ret = instance_change_group(inst, cluster, category);
835 result = packet_create_reply(packet, "i", ret);
837 ErrPrint("Failed to create a packet\n");
842 static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
844 struct client_node *client;
851 struct inst_info *inst;
852 const struct pkg_info *pkg;
854 client = client_find_by_pid(pid);
856 ErrPrint("Client %d is not exists\n", pid);
857 ret = LB_STATUS_ERROR_NOT_EXIST;
861 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
863 ErrPrint("Invalid parameter\n");
864 ret = LB_STATUS_ERROR_INVALID;
870 * Trust the package name which are sent by the client.
871 * The package has to be a livebox package name.
873 inst = package_find_instance_by_id(pkgname, id);
875 ErrPrint("Instance[%s] is not exists\n", id);
876 ret = LB_STATUS_ERROR_NOT_EXIST;
880 pkg = instance_package(inst);
882 ErrPrint("Package[%s] info is not found\n", pkgname);
883 ret = LB_STATUS_ERROR_FAULT;
887 if (package_is_fault(pkg)) {
890 * If the package is registered as fault module,
891 * slave has not load it, so we don't need to do anything at here!
893 DbgPrint("Package[%s] is faulted\n", pkgname);
894 ret = LB_STATUS_ERROR_FAULT;
895 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
896 struct buffer_info *buffer;
897 struct slave_node *slave;
898 // struct packet *packet;
900 buffer = instance_pd_buffer(inst);
902 ErrPrint("Instance[%s] has no buffer\n", id);
903 ret = LB_STATUS_ERROR_FAULT;
907 slave = package_slave(pkg);
909 ErrPrint("Package[%s] has no slave\n", pkgname);
910 ret = LB_STATUS_ERROR_INVALID;
915 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
917 ErrPrint("Failed to create a packet[%s]\n", pkgname);
918 ret = LB_STATUS_ERROR_FAULT;
923 packet_ref((struct packet *)packet);
924 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
925 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
926 struct script_info *script;
929 script = instance_pd_script(inst);
931 ret = LB_STATUS_ERROR_FAULT;
935 e = script_handler_evas(script);
937 ret = LB_STATUS_ERROR_FAULT;
941 script_handler_update_pointer(script, x, y, -1);
942 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
945 ErrPrint("Unsupported package\n");
946 ret = LB_STATUS_ERROR_INVALID;
950 /*! \note No reply packet */
954 static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
956 struct client_node *client;
963 struct inst_info *inst;
964 const struct pkg_info *pkg;
966 client = client_find_by_pid(pid);
968 ErrPrint("Client %d is not exists\n", pid);
969 ret = LB_STATUS_ERROR_NOT_EXIST;
973 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
975 ErrPrint("Parameter is not matched\n");
976 ret = LB_STATUS_ERROR_INVALID;
982 * Trust the package name which are sent by the client.
983 * The package has to be a livebox package name.
985 inst = package_find_instance_by_id(pkgname, id);
987 ErrPrint("Instance[%s] is not exists\n", id);
988 ret = LB_STATUS_ERROR_NOT_EXIST;
992 pkg = instance_package(inst);
994 ErrPrint("Package[%s] info is not found\n", pkgname);
995 ret = LB_STATUS_ERROR_FAULT;
999 if (package_is_fault(pkg)) {
1002 * If the package is registered as fault module,
1003 * slave has not load it, so we don't need to do anything at here!
1005 DbgPrint("Package[%s] is faulted\n", pkgname);
1006 ret = LB_STATUS_ERROR_FAULT;
1007 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1008 struct buffer_info *buffer;
1009 struct slave_node *slave;
1010 // struct packet *packet;
1012 buffer = instance_pd_buffer(inst);
1014 ErrPrint("Instance[%s] has no buffer\n", id);
1015 ret = LB_STATUS_ERROR_FAULT;
1019 slave = package_slave(pkg);
1021 ErrPrint("Package[%s] has no slave\n", pkgname);
1022 ret = LB_STATUS_ERROR_INVALID;
1027 packet = packet_create_noack("pd_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1029 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1030 ret = LB_STATUS_ERROR_FAULT;
1035 packet_ref((struct packet *)packet);
1036 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1037 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1038 struct script_info *script;
1041 script = instance_pd_script(inst);
1043 ret = LB_STATUS_ERROR_FAULT;
1047 e = script_handler_evas(script);
1049 ret = LB_STATUS_ERROR_FAULT;
1053 script_handler_update_pointer(script, x, y, -1);
1054 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
1057 ErrPrint("Unsupported package\n");
1058 ret = LB_STATUS_ERROR_INVALID;
1062 /*! \note No reply packet */
1066 static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, id, width, height, timestamp, x, y, ret */
1068 struct client_node *client;
1069 const char *pkgname;
1075 struct inst_info *inst;
1076 const struct pkg_info *pkg;
1078 client = client_find_by_pid(pid);
1080 ErrPrint("Client %d is not exists\n", pid);
1081 ret = LB_STATUS_ERROR_NOT_EXIST;
1085 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1087 ErrPrint("Parameter is not matched\n");
1088 ret = LB_STATUS_ERROR_INVALID;
1092 DbgPrint("(%dx%d)\n", x, y);
1096 * Trust the package name which are sent by the client.
1097 * The package has to be a livebox package name.
1099 inst = package_find_instance_by_id(pkgname, id);
1101 ErrPrint("Instance[%s] is not exists\n", id);
1102 ret = LB_STATUS_ERROR_NOT_EXIST;
1106 pkg = instance_package(inst);
1108 ErrPrint("Package[%s] info is not found\n", pkgname);
1109 ret = LB_STATUS_ERROR_FAULT;
1113 if (package_is_fault(pkg)) {
1116 * If the package is registered as fault module,
1117 * slave has not load it, so we don't need to do anything at here!
1119 DbgPrint("Package[%s] is faulted\n", pkgname);
1120 ret = LB_STATUS_ERROR_FAULT;
1121 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1122 struct buffer_info *buffer;
1123 struct slave_node *slave;
1124 // struct packet *packet;
1126 buffer = instance_pd_buffer(inst);
1128 ErrPrint("Instance[%s] has no buffer\n", id);
1129 ret = LB_STATUS_ERROR_FAULT;
1133 slave = package_slave(pkg);
1135 ErrPrint("Package[%s] has no slave\n", pkgname);
1136 ret = LB_STATUS_ERROR_INVALID;
1141 packet = packet_create_noack("pd_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1143 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1144 ret = LB_STATUS_ERROR_FAULT;
1149 packet_ref((struct packet *)packet);
1150 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1151 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1152 struct script_info *script;
1155 script = instance_pd_script(inst);
1157 ret = LB_STATUS_ERROR_FAULT;
1161 e = script_handler_evas(script);
1163 ret = LB_STATUS_ERROR_FAULT;
1167 script_handler_update_pointer(script, x, y, 1);
1168 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
1171 ErrPrint("Unsupported package\n");
1172 ret = LB_STATUS_ERROR_INVALID;
1176 /*! \note No reply packet */
1180 static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
1182 struct client_node *client;
1183 const char *pkgname;
1189 struct inst_info *inst;
1190 const struct pkg_info *pkg;
1192 client = client_find_by_pid(pid);
1194 ErrPrint("Client %d is not exists\n", pid);
1195 ret = LB_STATUS_ERROR_NOT_EXIST;
1199 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1201 ErrPrint("Parameter is not matched\n");
1202 ret = LB_STATUS_ERROR_INVALID;
1206 DbgPrint("(%dx%d)\n", x, y);
1209 * Trust the package name which are sent by the client.
1210 * The package has to be a livebox package name.
1212 inst = package_find_instance_by_id(pkgname, id);
1214 ErrPrint("Instance[%s] is not exists\n", id);
1215 ret = LB_STATUS_ERROR_NOT_EXIST;
1219 pkg = instance_package(inst);
1221 ErrPrint("Package[%s] info is not exists\n", pkgname);
1222 ret = LB_STATUS_ERROR_FAULT;
1226 if (package_is_fault(pkg)) {
1229 * If the package is registered as fault module,
1230 * slave has not load it, so we don't need to do anything at here!
1232 DbgPrint("Package[%s] is faulted\n", pkgname);
1233 ret = LB_STATUS_ERROR_FAULT;
1234 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1235 struct buffer_info *buffer;
1236 struct slave_node *slave;
1237 //struct packet *packet;
1239 buffer = instance_pd_buffer(inst);
1241 ErrPrint("Instance[%s] has no buffer\n", id);
1242 ret = LB_STATUS_ERROR_FAULT;
1246 slave = package_slave(pkg);
1248 ErrPrint("Package[%s] has no slave\n", pkgname);
1249 ret = LB_STATUS_ERROR_INVALID;
1254 packet = packet_create_noack("pd_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1256 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1257 ret = LB_STATUS_ERROR_FAULT;
1262 packet_ref((struct packet *)packet);
1263 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1264 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1265 struct script_info *script;
1268 script = instance_pd_script(inst);
1270 ret = LB_STATUS_ERROR_FAULT;
1274 e = script_handler_evas(script);
1276 ret = LB_STATUS_ERROR_FAULT;
1280 script_handler_update_pointer(script, x, y, 0);
1281 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
1284 ErrPrint("Unsupported package\n");
1285 ret = LB_STATUS_ERROR_INVALID;
1289 /*! \note No reply packet */
1293 static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
1295 struct client_node *client;
1296 const char *pkgname;
1302 struct inst_info *inst;
1303 const struct pkg_info *pkg;
1305 client = client_find_by_pid(pid);
1307 ErrPrint("Client %d is not exists\n", pid);
1308 ret = LB_STATUS_ERROR_NOT_EXIST;
1312 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1314 ErrPrint("Parameter is not matched\n");
1315 ret = LB_STATUS_ERROR_INVALID;
1319 DbgPrint("(%dx%d)\n", x, y);
1322 * Trust the package name which are sent by the client.
1323 * The package has to be a livebox package name.
1325 inst = package_find_instance_by_id(pkgname, id);
1327 ErrPrint("Instance[%s] is not exists\n", id);
1328 ret = LB_STATUS_ERROR_NOT_EXIST;
1332 pkg = instance_package(inst);
1334 ErrPrint("Package[%s] info is not exists\n", pkgname);
1335 ret = LB_STATUS_ERROR_FAULT;
1339 if (package_is_fault(pkg)) {
1342 * If the package is registered as fault module,
1343 * slave has not load it, so we don't need to do anything at here!
1345 DbgPrint("Package[%s] is faulted\n", pkgname);
1346 ret = LB_STATUS_ERROR_FAULT;
1347 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1348 struct buffer_info *buffer;
1349 struct slave_node *slave;
1350 //struct packet *packet;
1352 buffer = instance_pd_buffer(inst);
1354 ErrPrint("Instance[%s] has no buffer\n", id);
1355 ret = LB_STATUS_ERROR_FAULT;
1359 slave = package_slave(pkg);
1361 ErrPrint("Package[%s] has no slave\n", pkgname);
1362 ret = LB_STATUS_ERROR_INVALID;
1368 packet = packet_create_noack("pd_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1370 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1371 ret = LB_STATUS_ERROR_FAULT;
1375 packet_ref((struct packet *)packet);
1376 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1377 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1378 struct script_info *script;
1381 script = instance_pd_script(inst);
1383 ret = LB_STATUS_ERROR_FAULT;
1387 e = script_handler_evas(script);
1389 ret = LB_STATUS_ERROR_FAULT;
1393 script_handler_update_pointer(script, x, y, -1);
1394 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1397 ErrPrint("Unsupported package\n");
1398 ret = LB_STATUS_ERROR_INVALID;
1402 /*! \note No reply packet */
1406 static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
1408 struct client_node *client;
1409 const char *pkgname;
1415 struct inst_info *inst;
1416 const struct pkg_info *pkg;
1418 client = client_find_by_pid(pid);
1420 ErrPrint("Client %d is not exists\n", pid);
1421 ret = LB_STATUS_ERROR_NOT_EXIST;
1425 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1427 ErrPrint("Parameter is not matched\n");
1428 ret = LB_STATUS_ERROR_INVALID;
1434 * Trust the package name which are sent by the client.
1435 * The package has to be a livebox package name.
1437 inst = package_find_instance_by_id(pkgname, id);
1439 ErrPrint("Instance[%s] is not exists\n", id);
1440 ret = LB_STATUS_ERROR_NOT_EXIST;
1444 pkg = instance_package(inst);
1446 ErrPrint("Package[%s] info is not exists\n", pkgname);
1447 ret = LB_STATUS_ERROR_FAULT;
1451 if (package_is_fault(pkg)) {
1454 * If the package is registered as fault module,
1455 * slave has not load it, so we don't need to do anything at here!
1457 DbgPrint("Package[%s] is faulted\n", pkgname);
1458 ret = LB_STATUS_ERROR_FAULT;
1459 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1460 struct buffer_info *buffer;
1461 struct slave_node *slave;
1462 //struct packet *packet;
1464 buffer = instance_lb_buffer(inst);
1466 ErrPrint("Instance[%s] has no buffer\n", id);
1467 ret = LB_STATUS_ERROR_FAULT;
1471 slave = package_slave(pkg);
1473 ErrPrint("Package[%s] has no slave\n", pkgname);
1474 ret = LB_STATUS_ERROR_INVALID;
1479 packet = packet_create_noack("lb_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1481 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1482 ret = LB_STATUS_ERROR_FAULT;
1486 packet_ref((struct packet *)packet);
1487 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1488 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1489 struct script_info *script;
1492 script = instance_lb_script(inst);
1494 ret = LB_STATUS_ERROR_FAULT;
1498 e = script_handler_evas(script);
1500 ret = LB_STATUS_ERROR_FAULT;
1504 script_handler_update_pointer(script, x, y, -1);
1505 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1508 ErrPrint("Unsupported package\n");
1509 ret = LB_STATUS_ERROR_INVALID;
1513 /*! \note No reply packet */
1517 static int inst_del_cb(struct inst_info *inst, void *data)
1519 (void)event_deactivate();
1520 return -1; /* Delete this callback */
1523 static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
1525 struct client_node *client;
1526 const char *pkgname;
1532 struct inst_info *inst;
1533 const struct pkg_info *pkg;
1535 client = client_find_by_pid(pid);
1537 ErrPrint("Client %d is not exists\n", pid);
1538 ret = LB_STATUS_ERROR_NOT_EXIST;
1542 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1544 ErrPrint("Parameter is not matched\n");
1545 ret = LB_STATUS_ERROR_INVALID;
1549 inst = package_find_instance_by_id(pkgname, id);
1551 ErrPrint("Instance[%s] is not exists\n", id);
1552 ret = LB_STATUS_ERROR_NOT_EXIST;
1556 pkg = instance_package(inst);
1558 ErrPrint("Package[%s] info is not exists\n", pkgname);
1559 ret = LB_STATUS_ERROR_FAULT;
1563 if (package_is_fault(pkg)) {
1566 * If the package is registered as fault module,
1567 * slave has not load it, so we don't need to do anything at here!
1569 DbgPrint("Package[%s] is faulted\n", pkgname);
1570 ret = LB_STATUS_ERROR_FAULT;
1571 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1572 if (event_is_activated()) {
1573 if (event_deactivate() == 0)
1574 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1577 ret = event_activate(x, y, event_lb_route_cb, inst);
1579 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1580 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1581 if (event_is_activated()) {
1582 if (event_deactivate() == 0)
1583 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1586 ret = event_activate(x, y, event_lb_consume_cb, inst);
1588 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1590 ErrPrint("Unsupported package\n");
1591 ret = LB_STATUS_ERROR_INVALID;
1597 static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1599 struct client_node *client;
1600 const char *pkgname;
1606 struct inst_info *inst;
1607 const struct pkg_info *pkg;
1608 client = client_find_by_pid(pid);
1610 ErrPrint("Client %d is not exists\n", pid);
1611 ret = LB_STATUS_ERROR_NOT_EXIST;
1614 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1616 ErrPrint("Parameter is not matched\n");
1617 ret = LB_STATUS_ERROR_INVALID;
1621 inst = package_find_instance_by_id(pkgname, id);
1623 ErrPrint("Instance[%s] is not exists\n", id);
1624 ret = LB_STATUS_ERROR_NOT_EXIST;
1628 pkg = instance_package(inst);
1630 ErrPrint("Package[%s] info is not exists\n", pkgname);
1631 ret = LB_STATUS_ERROR_FAULT;
1635 if (package_is_fault(pkg)) {
1638 * If the package is registered as fault module,
1639 * slave has not load it, so we don't need to do anything at here!
1641 DbgPrint("Package[%s] is faulted\n", pkgname);
1642 ret = LB_STATUS_ERROR_FAULT;
1643 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1644 ret = event_deactivate();
1646 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1647 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1648 ret = event_deactivate();
1650 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1652 ErrPrint("Unsupported package\n");
1653 ret = LB_STATUS_ERROR_INVALID;
1659 static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
1661 struct client_node *client;
1662 const char *pkgname;
1668 struct inst_info *inst;
1669 const struct pkg_info *pkg;
1671 client = client_find_by_pid(pid);
1673 ErrPrint("Client %d is not exists\n", pid);
1674 ret = LB_STATUS_ERROR_NOT_EXIST;
1678 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1680 ErrPrint("Parameter is not matched\n");
1681 ret = LB_STATUS_ERROR_INVALID;
1685 inst = package_find_instance_by_id(pkgname, id);
1687 ErrPrint("Instance[%s] is not exists\n", id);
1688 ret = LB_STATUS_ERROR_NOT_EXIST;
1692 pkg = instance_package(inst);
1694 ErrPrint("Package[%s] info is not exists\n", pkgname);
1695 ret = LB_STATUS_ERROR_FAULT;
1699 if (package_is_fault(pkg)) {
1702 * If the package is registered as fault module,
1703 * slave has not load it, so we don't need to do anything at here!
1705 DbgPrint("Package[%s] is faulted\n", pkgname);
1706 ret = LB_STATUS_ERROR_FAULT;
1707 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1708 if (event_is_activated()) {
1709 if (event_deactivate() == 0)
1710 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1713 ret = event_activate(x, y, event_pd_route_cb, inst);
1715 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1716 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1717 if (event_is_activated()) {
1718 if (event_deactivate() == 0)
1719 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1722 ret = event_activate(x, y, event_pd_consume_cb, inst);
1724 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1726 ErrPrint("Unsupported package\n");
1727 ret = LB_STATUS_ERROR_INVALID;
1734 static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1736 struct client_node *client;
1737 const char *pkgname;
1743 struct inst_info *inst;
1744 const struct pkg_info *pkg;
1746 client = client_find_by_pid(pid);
1748 ErrPrint("Client %d is not exists\n", pid);
1749 ret = LB_STATUS_ERROR_NOT_EXIST;
1753 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1755 ErrPrint("Parameter is not matched\n");
1756 ret = LB_STATUS_ERROR_INVALID;
1760 inst = package_find_instance_by_id(pkgname, id);
1762 ErrPrint("Instance[%s] is not exists\n", id);
1763 ret = LB_STATUS_ERROR_NOT_EXIST;
1767 pkg = instance_package(inst);
1769 ErrPrint("Package[%s] info is not exists\n", pkgname);
1770 ret = LB_STATUS_ERROR_FAULT;
1774 if (package_is_fault(pkg)) {
1777 * If the package is registered as fault module,
1778 * slave has not load it, so we don't need to do anything at here!
1780 DbgPrint("Package[%s] is faulted\n", pkgname);
1781 ret = LB_STATUS_ERROR_FAULT;
1782 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1783 ret = event_deactivate();
1785 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1786 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1787 ret = event_deactivate();
1789 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1791 ErrPrint("Unsupported package\n");
1792 ret = LB_STATUS_ERROR_INVALID;
1798 static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
1800 struct client_node *client;
1801 const char *pkgname;
1807 struct inst_info *inst;
1808 const struct pkg_info *pkg;
1810 client = client_find_by_pid(pid);
1812 ErrPrint("Client %d is not exists\n", pid);
1813 ret = LB_STATUS_ERROR_NOT_EXIST;
1817 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1819 ErrPrint("Parameter is not matched\n");
1820 ret = LB_STATUS_ERROR_INVALID;
1826 * Trust the package name which are sent by the client.
1827 * The package has to be a livebox package name.
1829 inst = package_find_instance_by_id(pkgname, id);
1831 ErrPrint("Instance[%s] is not exists\n", id);
1832 ret = LB_STATUS_ERROR_NOT_EXIST;
1836 pkg = instance_package(inst);
1838 ErrPrint("Package[%s] info is not exists\n", pkgname);
1839 ret = LB_STATUS_ERROR_FAULT;
1843 if (package_is_fault(pkg)) {
1846 * If the package is registered as fault module,
1847 * slave has not load it, so we don't need to do anything at here!
1849 DbgPrint("Package[%s] is faulted\n", pkgname);
1850 ret = LB_STATUS_ERROR_FAULT;
1851 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1852 struct buffer_info *buffer;
1853 struct slave_node *slave;
1854 //struct packet *packet;
1856 buffer = instance_lb_buffer(inst);
1858 ErrPrint("Instance[%s] has no buffer\n", id);
1859 ret = LB_STATUS_ERROR_FAULT;
1863 slave = package_slave(pkg);
1865 ErrPrint("Package[%s] has no slave\n", pkgname);
1866 ret = LB_STATUS_ERROR_INVALID;
1871 packet = packet_create_noack("lb_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1873 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1874 ret = LB_STATUS_ERROR_FAULT;
1878 packet_ref((struct packet *)packet);
1879 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1880 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1881 struct script_info *script;
1884 script = instance_lb_script(inst);
1886 ret = LB_STATUS_ERROR_FAULT;
1890 e = script_handler_evas(script);
1892 ret = LB_STATUS_ERROR_FAULT;
1896 script_handler_update_pointer(script, x, y, -1);
1897 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
1900 ErrPrint("Unsupported package\n");
1901 ret = LB_STATUS_ERROR_INVALID;
1905 /*! \note No reply packet */
1909 static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
1911 struct client_node *client;
1912 const char *pkgname;
1918 struct inst_info *inst;
1919 const struct pkg_info *pkg;
1921 client = client_find_by_pid(pid);
1923 ErrPrint("Client %d is not exists\n", pid);
1924 ret = LB_STATUS_ERROR_NOT_EXIST;
1928 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1930 ErrPrint("Parameter is not matched\n");
1931 ret = LB_STATUS_ERROR_INVALID;
1937 * Trust the package name which are sent by the client.
1938 * The package has to be a livebox package name.
1940 inst = package_find_instance_by_id(pkgname, id);
1942 ErrPrint("Instance[%s] is not exists\n", id);
1943 ret = LB_STATUS_ERROR_NOT_EXIST;
1947 pkg = instance_package(inst);
1949 ErrPrint("Package[%s] info is not exists\n", pkgname);
1950 ret = LB_STATUS_ERROR_FAULT;
1954 if (package_is_fault(pkg)) {
1957 * If the package is registered as fault module,
1958 * slave has not load it, so we don't need to do anything at here!
1960 DbgPrint("Package[%s] is faulted\n", pkgname);
1961 ret = LB_STATUS_ERROR_FAULT;
1962 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1963 struct buffer_info *buffer;
1964 struct slave_node *slave;
1965 //struct packet *packet;
1967 buffer = instance_lb_buffer(inst);
1969 ErrPrint("Instance[%s] has no buffer\n", id);
1970 ret = LB_STATUS_ERROR_FAULT;
1974 slave = package_slave(pkg);
1976 ErrPrint("Package[%s] has no slave\n", pkgname);
1977 ret = LB_STATUS_ERROR_INVALID;
1982 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1984 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1985 ret = LB_STATUS_ERROR_FAULT;
1990 packet_ref((struct packet *)packet);
1991 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1992 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1993 struct script_info *script;
1996 script = instance_lb_script(inst);
1998 ret = LB_STATUS_ERROR_FAULT;
2002 e = script_handler_evas(script);
2004 ret = LB_STATUS_ERROR_FAULT;
2008 script_handler_update_pointer(script, x, y, -1);
2009 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
2012 ErrPrint("Unsupported package\n");
2013 ret = LB_STATUS_ERROR_INVALID;
2017 /*! \note No reply packet */
2021 static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
2023 struct client_node *client;
2024 const char *pkgname;
2030 struct inst_info *inst;
2031 const struct pkg_info *pkg;
2033 client = client_find_by_pid(pid);
2035 ErrPrint("Client %d is not exists\n", pid);
2036 ret = LB_STATUS_ERROR_NOT_EXIST;
2040 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2042 ErrPrint("Parameter is not matched\n");
2043 ret = LB_STATUS_ERROR_INVALID;
2049 * Trust the package name which are sent by the client.
2050 * The package has to be a livebox package name.
2052 inst = package_find_instance_by_id(pkgname, id);
2054 ErrPrint("Instance[%s] is not exists\n", id);
2055 ret = LB_STATUS_ERROR_NOT_EXIST;
2059 pkg = instance_package(inst);
2061 ErrPrint("Package[%s] info is not exists\n", pkgname);
2062 ret = LB_STATUS_ERROR_FAULT;
2066 if (package_is_fault(pkg)) {
2069 * If the package is registered as fault module,
2070 * slave has not load it, so we don't need to do anything at here!
2072 DbgPrint("Package[%s] is faulted\n", pkgname);
2073 ret = LB_STATUS_ERROR_FAULT;
2074 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2075 struct buffer_info *buffer;
2076 struct slave_node *slave;
2077 // struct packet *packet;
2079 buffer = instance_lb_buffer(inst);
2081 ErrPrint("Instance[%s] has no buffer\n", id);
2082 ret = LB_STATUS_ERROR_FAULT;
2086 slave = package_slave(pkg);
2088 ErrPrint("Package[%s] has no slave\n", pkgname);
2089 ret = LB_STATUS_ERROR_INVALID;
2094 packet = packet_create_noack("lb_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2096 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2097 ret = LB_STATUS_ERROR_FAULT;
2102 packet_ref((struct packet *)packet);
2103 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2104 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2105 struct script_info *script;
2108 script = instance_lb_script(inst);
2110 ret = LB_STATUS_ERROR_FAULT;
2114 e = script_handler_evas(script);
2116 ret = LB_STATUS_ERROR_FAULT;
2120 script_handler_update_pointer(script, x, y, 1);
2121 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
2124 ErrPrint("Unsupported package\n");
2125 ret = LB_STATUS_ERROR_INVALID;
2129 /*! \note No reply packet */
2133 static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
2135 struct client_node *client;
2136 const char *pkgname;
2142 struct inst_info *inst;
2143 const struct pkg_info *pkg;
2145 client = client_find_by_pid(pid);
2147 ErrPrint("Client %d is not exists\n", pid);
2148 ret = LB_STATUS_ERROR_NOT_EXIST;
2152 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2154 ErrPrint("Parameter is not matched\n");
2155 ret = LB_STATUS_ERROR_INVALID;
2161 * Trust the package name which are sent by the client.
2162 * The package has to be a livebox package name.
2164 inst = package_find_instance_by_id(pkgname, id);
2166 ErrPrint("Instance[%s] is not exists\n", id);
2167 ret = LB_STATUS_ERROR_NOT_EXIST;
2171 pkg = instance_package(inst);
2173 ErrPrint("Package[%s] info is not exists\n", pkgname);
2174 ret = LB_STATUS_ERROR_FAULT;
2178 if (package_is_fault(pkg)) {
2181 * If the package is registered as fault module,
2182 * slave has not load it, so we don't need to do anything at here!
2184 DbgPrint("Package[%s] is faulted\n", pkgname);
2185 ret = LB_STATUS_ERROR_FAULT;
2186 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2187 struct buffer_info *buffer;
2188 struct slave_node *slave;
2189 //struct packet *packet;
2191 buffer = instance_lb_buffer(inst);
2193 ErrPrint("Instance[%s] has no buffer\n", id);
2194 ret = LB_STATUS_ERROR_FAULT;
2198 slave = package_slave(pkg);
2200 ErrPrint("Package[%s] has no slave\n", pkgname);
2201 ret = LB_STATUS_ERROR_INVALID;
2206 packet = packet_create_noack("lb_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2208 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2209 ret = LB_STATUS_ERROR_FAULT;
2214 packet_ref((struct packet *)packet);
2215 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2216 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2217 struct script_info *script;
2220 script = instance_lb_script(inst);
2222 ret = LB_STATUS_ERROR_FAULT;
2226 e = script_handler_evas(script);
2228 ret = LB_STATUS_ERROR_FAULT;
2232 script_handler_update_pointer(script, x, y, 0);
2233 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
2236 ErrPrint("Unsupported package\n");
2237 ret = LB_STATUS_ERROR_INVALID;
2241 /*! \note No reply packet */
2245 static struct packet *client_pd_access_action_up(pid_t pid, int handle, const struct packet *packet)
2247 struct packet *result;
2248 struct client_node *client;
2249 const char *pkgname;
2255 struct inst_info *inst;
2256 const struct pkg_info *pkg;
2258 client = client_find_by_pid(pid);
2260 ErrPrint("Client %d is not exists\n", pid);
2261 ret = LB_STATUS_ERROR_NOT_EXIST;
2265 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2267 ErrPrint("Invalid parameter\n");
2268 ret = LB_STATUS_ERROR_INVALID;
2274 * Trust the package name which are sent by the client.
2275 * The package has to be a livebox package name.
2277 inst = package_find_instance_by_id(pkgname, id);
2279 ErrPrint("Instance[%s] is not exists\n", id);
2280 ret = LB_STATUS_ERROR_NOT_EXIST;
2284 pkg = instance_package(inst);
2286 ErrPrint("Package[%s] info is not found\n", pkgname);
2287 ret = LB_STATUS_ERROR_FAULT;
2291 if (package_is_fault(pkg)) {
2294 * If the package is registered as fault module,
2295 * slave has not load it, so we don't need to do anything at here!
2297 DbgPrint("Package[%s] is faulted\n", pkgname);
2298 ret = LB_STATUS_ERROR_FAULT;
2299 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2300 struct buffer_info *buffer;
2301 struct slave_node *slave;
2302 // struct packet *packet;
2304 buffer = instance_pd_buffer(inst);
2306 ErrPrint("Instance[%s] has no buffer\n", id);
2307 ret = LB_STATUS_ERROR_FAULT;
2311 slave = package_slave(pkg);
2313 ErrPrint("Package[%s] has no slave\n", pkgname);
2314 ret = LB_STATUS_ERROR_INVALID;
2319 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2321 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2322 ret = LB_STATUS_ERROR_FAULT;
2327 packet_ref((struct packet *)packet);
2328 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2329 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2330 struct script_info *script;
2333 script = instance_pd_script(inst);
2335 ret = LB_STATUS_ERROR_FAULT;
2339 e = script_handler_evas(script);
2341 ret = LB_STATUS_ERROR_FAULT;
2345 script_handler_update_pointer(script, x, y, 0);
2346 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
2348 struct access_cbdata *cbdata;
2350 cbdata = malloc(sizeof(*cbdata));
2352 ret = LB_STATUS_ERROR_MEMORY;
2354 cbdata->inst = instance_ref(inst);
2355 cbdata->status = ret;
2357 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2358 instance_unref(cbdata->inst);
2360 ret = LB_STATUS_ERROR_FAULT;
2362 ret = LB_STATUS_SUCCESS;
2367 ErrPrint("Unsupported package\n");
2368 ret = LB_STATUS_ERROR_INVALID;
2372 result = packet_create_reply(packet, "i", ret);
2374 ErrPrint("Failed to create a reply packet\n");
2379 static struct packet *client_pd_access_action_down(pid_t pid, int handle, const struct packet *packet)
2381 struct packet *result;
2382 struct client_node *client;
2383 const char *pkgname;
2389 struct inst_info *inst;
2390 const struct pkg_info *pkg;
2392 client = client_find_by_pid(pid);
2394 ErrPrint("Client %d is not exists\n", pid);
2395 ret = LB_STATUS_ERROR_NOT_EXIST;
2399 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2401 ErrPrint("Invalid parameter\n");
2402 ret = LB_STATUS_ERROR_INVALID;
2408 * Trust the package name which are sent by the client.
2409 * The package has to be a livebox package name.
2411 inst = package_find_instance_by_id(pkgname, id);
2413 ErrPrint("Instance[%s] is not exists\n", id);
2414 ret = LB_STATUS_ERROR_NOT_EXIST;
2418 pkg = instance_package(inst);
2420 ErrPrint("Package[%s] info is not found\n", pkgname);
2421 ret = LB_STATUS_ERROR_FAULT;
2425 if (package_is_fault(pkg)) {
2428 * If the package is registered as fault module,
2429 * slave has not load it, so we don't need to do anything at here!
2431 DbgPrint("Package[%s] is faulted\n", pkgname);
2432 ret = LB_STATUS_ERROR_FAULT;
2433 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2434 struct buffer_info *buffer;
2435 struct slave_node *slave;
2436 // struct packet *packet;
2438 buffer = instance_pd_buffer(inst);
2440 ErrPrint("Instance[%s] has no buffer\n", id);
2441 ret = LB_STATUS_ERROR_FAULT;
2445 slave = package_slave(pkg);
2447 ErrPrint("Package[%s] has no slave\n", pkgname);
2448 ret = LB_STATUS_ERROR_INVALID;
2453 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2455 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2456 ret = LB_STATUS_ERROR_FAULT;
2461 packet_ref((struct packet *)packet);
2462 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2463 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2464 struct script_info *script;
2467 script = instance_pd_script(inst);
2469 ret = LB_STATUS_ERROR_FAULT;
2473 e = script_handler_evas(script);
2475 ret = LB_STATUS_ERROR_FAULT;
2479 script_handler_update_pointer(script, x, y, 1);
2480 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
2482 struct access_cbdata *cbdata;
2484 cbdata = malloc(sizeof(*cbdata));
2486 ret = LB_STATUS_ERROR_MEMORY;
2488 cbdata->inst = instance_ref(inst);
2489 cbdata->status = ret;
2491 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2492 instance_unref(cbdata->inst);
2494 ret = LB_STATUS_ERROR_FAULT;
2496 ret = LB_STATUS_SUCCESS;
2501 ErrPrint("Unsupported package\n");
2502 ret = LB_STATUS_ERROR_INVALID;
2506 result = packet_create_reply(packet, "i", ret);
2508 ErrPrint("Failed to create a reply packet\n");
2513 static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
2515 struct packet *result;
2516 struct client_node *client;
2517 const char *pkgname;
2523 struct inst_info *inst;
2524 const struct pkg_info *pkg;
2526 client = client_find_by_pid(pid);
2528 ErrPrint("Client %d is not exists\n", pid);
2529 ret = LB_STATUS_ERROR_NOT_EXIST;
2533 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2535 ErrPrint("Invalid parameter\n");
2536 ret = LB_STATUS_ERROR_INVALID;
2542 * Trust the package name which are sent by the client.
2543 * The package has to be a livebox package name.
2545 inst = package_find_instance_by_id(pkgname, id);
2547 ErrPrint("Instance[%s] is not exists\n", id);
2548 ret = LB_STATUS_ERROR_NOT_EXIST;
2552 pkg = instance_package(inst);
2554 ErrPrint("Package[%s] info is not found\n", pkgname);
2555 ret = LB_STATUS_ERROR_FAULT;
2559 if (package_is_fault(pkg)) {
2562 * If the package is registered as fault module,
2563 * slave has not load it, so we don't need to do anything at here!
2565 DbgPrint("Package[%s] is faulted\n", pkgname);
2566 ret = LB_STATUS_ERROR_FAULT;
2567 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2568 struct buffer_info *buffer;
2569 struct slave_node *slave;
2570 // struct packet *packet;
2572 buffer = instance_pd_buffer(inst);
2574 ErrPrint("Instance[%s] has no buffer\n", id);
2575 ret = LB_STATUS_ERROR_FAULT;
2579 slave = package_slave(pkg);
2581 ErrPrint("Package[%s] has no slave\n", pkgname);
2582 ret = LB_STATUS_ERROR_INVALID;
2587 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2589 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2590 ret = LB_STATUS_ERROR_FAULT;
2595 packet_ref((struct packet *)packet);
2596 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2597 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2598 struct script_info *script;
2601 script = instance_pd_script(inst);
2603 ret = LB_STATUS_ERROR_FAULT;
2607 e = script_handler_evas(script);
2609 ret = LB_STATUS_ERROR_FAULT;
2613 script_handler_update_pointer(script, x, y, 1);
2614 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2616 struct access_cbdata *cbdata;
2618 cbdata = malloc(sizeof(*cbdata));
2620 ret = LB_STATUS_ERROR_MEMORY;
2622 cbdata->inst = instance_ref(inst);
2623 cbdata->status = ret;
2625 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2626 instance_unref(cbdata->inst);
2628 ret = LB_STATUS_ERROR_FAULT;
2630 ret = LB_STATUS_SUCCESS;
2635 ErrPrint("Unsupported package\n");
2636 ret = LB_STATUS_ERROR_INVALID;
2640 result = packet_create_reply(packet, "i", ret);
2642 ErrPrint("Failed to create a reply packet\n");
2647 static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
2649 struct packet *result;
2650 struct client_node *client;
2651 const char *pkgname;
2657 struct inst_info *inst;
2658 const struct pkg_info *pkg;
2660 client = client_find_by_pid(pid);
2662 ErrPrint("Client %d is not exists\n", pid);
2663 ret = LB_STATUS_ERROR_NOT_EXIST;
2667 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2669 ErrPrint("Invalid parameter\n");
2670 ret = LB_STATUS_ERROR_INVALID;
2676 * Trust the package name which are sent by the client.
2677 * The package has to be a livebox package name.
2679 inst = package_find_instance_by_id(pkgname, id);
2681 ErrPrint("Instance[%s] is not exists\n", id);
2682 ret = LB_STATUS_ERROR_NOT_EXIST;
2686 pkg = instance_package(inst);
2688 ErrPrint("Package[%s] info is not found\n", pkgname);
2689 ret = LB_STATUS_ERROR_FAULT;
2693 if (package_is_fault(pkg)) {
2696 * If the package is registered as fault module,
2697 * slave has not load it, so we don't need to do anything at here!
2699 DbgPrint("Package[%s] is faulted\n", pkgname);
2700 ret = LB_STATUS_ERROR_FAULT;
2701 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2702 struct buffer_info *buffer;
2703 struct slave_node *slave;
2704 // struct packet *packet;
2706 buffer = instance_pd_buffer(inst);
2708 ErrPrint("Instance[%s] has no buffer\n", id);
2709 ret = LB_STATUS_ERROR_FAULT;
2713 slave = package_slave(pkg);
2715 ErrPrint("Package[%s] has no slave\n", pkgname);
2716 ret = LB_STATUS_ERROR_INVALID;
2721 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2723 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2724 ret = LB_STATUS_ERROR_FAULT;
2729 packet_ref((struct packet *)packet);
2730 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2731 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2732 struct script_info *script;
2735 script = instance_pd_script(inst);
2737 ret = LB_STATUS_ERROR_FAULT;
2741 e = script_handler_evas(script);
2743 ret = LB_STATUS_ERROR_FAULT;
2747 script_handler_update_pointer(script, x, y, -1);
2748 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2750 struct access_cbdata *cbdata;
2752 cbdata = malloc(sizeof(*cbdata));
2754 ret = LB_STATUS_ERROR_MEMORY;
2756 cbdata->inst = instance_ref(inst);
2757 cbdata->status = ret;
2759 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2760 instance_unref(cbdata->inst);
2762 ret = LB_STATUS_ERROR_FAULT;
2764 ret = LB_STATUS_SUCCESS;
2769 ErrPrint("Unsupported package\n");
2770 ret = LB_STATUS_ERROR_INVALID;
2774 result = packet_create_reply(packet, "i", ret);
2776 ErrPrint("Failed to create a reply packet\n");
2781 static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
2783 struct packet *result;
2784 struct client_node *client;
2785 const char *pkgname;
2791 struct inst_info *inst;
2792 const struct pkg_info *pkg;
2794 client = client_find_by_pid(pid);
2796 ErrPrint("Client %d is not exists\n", pid);
2797 ret = LB_STATUS_ERROR_NOT_EXIST;
2801 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2803 ErrPrint("Invalid parameter\n");
2804 ret = LB_STATUS_ERROR_INVALID;
2810 * Trust the package name which are sent by the client.
2811 * The package has to be a livebox package name.
2813 inst = package_find_instance_by_id(pkgname, id);
2815 ErrPrint("Instance[%s] is not exists\n", id);
2816 ret = LB_STATUS_ERROR_NOT_EXIST;
2820 pkg = instance_package(inst);
2822 ErrPrint("Package[%s] info is not found\n", pkgname);
2823 ret = LB_STATUS_ERROR_FAULT;
2827 if (package_is_fault(pkg)) {
2830 * If the package is registered as fault module,
2831 * slave has not load it, so we don't need to do anything at here!
2833 DbgPrint("Package[%s] is faulted\n", pkgname);
2834 ret = LB_STATUS_ERROR_FAULT;
2835 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2836 struct buffer_info *buffer;
2837 struct slave_node *slave;
2838 // struct packet *packet;
2840 buffer = instance_pd_buffer(inst);
2842 ErrPrint("Instance[%s] has no buffer\n", id);
2843 ret = LB_STATUS_ERROR_FAULT;
2847 slave = package_slave(pkg);
2849 ErrPrint("Package[%s] has no slave\n", pkgname);
2850 ret = LB_STATUS_ERROR_INVALID;
2855 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2857 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2858 ret = LB_STATUS_ERROR_FAULT;
2863 packet_ref((struct packet *)packet);
2864 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2865 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2866 struct script_info *script;
2869 script = instance_pd_script(inst);
2871 ret = LB_STATUS_ERROR_FAULT;
2875 e = script_handler_evas(script);
2877 ret = LB_STATUS_ERROR_FAULT;
2881 script_handler_update_pointer(script, x, y, 0);
2882 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2884 struct access_cbdata *cbdata;
2886 cbdata = malloc(sizeof(*cbdata));
2888 ret = LB_STATUS_ERROR_MEMORY;
2890 cbdata->inst = instance_ref(inst);
2891 cbdata->status = ret;
2893 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2894 instance_unref(cbdata->inst);
2896 ret = LB_STATUS_ERROR_FAULT;
2898 ret = LB_STATUS_SUCCESS;
2903 ErrPrint("Unsupported package\n");
2904 ret = LB_STATUS_ERROR_INVALID;
2908 result = packet_create_reply(packet, "i", ret);
2910 ErrPrint("Failed to create a reply packet\n");
2915 static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
2917 struct packet *result;
2918 struct client_node *client;
2919 const char *pkgname;
2923 struct inst_info *inst;
2924 const struct pkg_info *pkg;
2928 client = client_find_by_pid(pid);
2930 ErrPrint("Client %d is not exists\n", pid);
2931 ret = LB_STATUS_ERROR_NOT_EXIST;
2935 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2937 ErrPrint("Invalid parameter\n");
2938 ret = LB_STATUS_ERROR_INVALID;
2942 inst = package_find_instance_by_id(pkgname, id);
2944 ErrPrint("Instance[%s] is not exists\n", id);
2945 ret = LB_STATUS_ERROR_NOT_EXIST;
2949 pkg = instance_package(inst);
2951 ErrPrint("Package[%s] info is not found\n", pkgname);
2952 ret = LB_STATUS_ERROR_FAULT;
2956 if (package_is_fault(pkg)) {
2957 DbgPrint("Package[%s] is faulted\n", pkgname);
2958 ret = LB_STATUS_ERROR_FAULT;
2959 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2960 struct buffer_info *buffer;
2961 struct slave_node *slave;
2962 // struct packet *packet;
2964 buffer = instance_pd_buffer(inst);
2966 ErrPrint("Instance[%s] has no buffer\n", id);
2967 ret = LB_STATUS_ERROR_FAULT;
2971 slave = package_slave(pkg);
2973 ErrPrint("Package[%s] has no slave\n", pkgname);
2974 ret = LB_STATUS_ERROR_INVALID;
2979 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2981 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2982 ret = LB_STATUS_ERROR_FAULT;
2987 packet_ref((struct packet *)packet);
2988 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2989 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2990 struct script_info *script;
2993 script = instance_pd_script(inst);
2995 ret = LB_STATUS_ERROR_FAULT;
2999 e = script_handler_evas(script);
3001 ret = LB_STATUS_ERROR_FAULT;
3005 script_handler_update_pointer(script, x, y, -1);
3006 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
3008 struct access_cbdata *cbdata;
3010 cbdata = malloc(sizeof(*cbdata));
3012 ret = LB_STATUS_ERROR_MEMORY;
3014 cbdata->inst = instance_ref(inst);
3015 cbdata->status = ret;
3017 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3018 instance_unref(cbdata->inst);
3020 ret = LB_STATUS_ERROR_FAULT;
3022 ret = LB_STATUS_SUCCESS;
3027 ErrPrint("Unsupported package\n");
3028 ret = LB_STATUS_ERROR_INVALID;
3031 result = packet_create_reply(packet, "i", ret);
3033 ErrPrint("Failed to create a reply packet\n");
3038 static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct packet *packet)
3040 struct packet *result;
3041 struct client_node *client;
3042 const char *pkgname;
3048 struct inst_info *inst;
3049 const struct pkg_info *pkg;
3051 client = client_find_by_pid(pid);
3053 ErrPrint("Client %d is not exists\n", pid);
3054 ret = LB_STATUS_ERROR_NOT_EXIST;
3058 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3060 ErrPrint("Invalid parameter\n");
3061 ret = LB_STATUS_ERROR_INVALID;
3067 * Trust the package name which are sent by the client.
3068 * The package has to be a livebox package name.
3070 inst = package_find_instance_by_id(pkgname, id);
3072 ErrPrint("Instance[%s] is not exists\n", id);
3073 ret = LB_STATUS_ERROR_NOT_EXIST;
3077 pkg = instance_package(inst);
3079 ErrPrint("Package[%s] info is not found\n", pkgname);
3080 ret = LB_STATUS_ERROR_FAULT;
3084 if (package_is_fault(pkg)) {
3087 * If the package is registered as fault module,
3088 * slave has not load it, so we don't need to do anything at here!
3090 DbgPrint("Package[%s] is faulted\n", pkgname);
3091 ret = LB_STATUS_ERROR_FAULT;
3092 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3093 struct buffer_info *buffer;
3094 struct slave_node *slave;
3095 // struct packet *packet;
3097 buffer = instance_pd_buffer(inst);
3099 ErrPrint("Instance[%s] has no buffer\n", id);
3100 ret = LB_STATUS_ERROR_FAULT;
3104 slave = package_slave(pkg);
3106 ErrPrint("Package[%s] has no slave\n", pkgname);
3107 ret = LB_STATUS_ERROR_INVALID;
3112 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3114 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3115 ret = LB_STATUS_ERROR_FAULT;
3120 packet_ref((struct packet *)packet);
3121 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3122 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3123 struct script_info *script;
3126 script = instance_pd_script(inst);
3128 ret = LB_STATUS_ERROR_FAULT;
3132 e = script_handler_evas(script);
3134 ret = LB_STATUS_ERROR_FAULT;
3138 script_handler_update_pointer(script, x, y, -1);
3139 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
3141 struct access_cbdata *cbdata;
3143 cbdata = malloc(sizeof(*cbdata));
3145 ret = LB_STATUS_ERROR_MEMORY;
3147 cbdata->inst = instance_ref(inst);
3148 cbdata->status = ret;
3150 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3151 instance_unref(cbdata->inst);
3153 ret = LB_STATUS_ERROR_FAULT;
3155 ret = LB_STATUS_SUCCESS;
3160 ErrPrint("Unsupported package\n");
3161 ret = LB_STATUS_ERROR_INVALID;
3165 result = packet_create_reply(packet, "i", ret);
3167 ErrPrint("Failed to create a reply packet\n");
3172 static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
3174 struct packet *result;
3175 struct client_node *client;
3176 const char *pkgname;
3182 struct inst_info *inst;
3183 const struct pkg_info *pkg;
3185 client = client_find_by_pid(pid);
3187 ErrPrint("Client %d is not exists\n", pid);
3188 ret = LB_STATUS_ERROR_NOT_EXIST;
3192 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3194 ErrPrint("Invalid parameter\n");
3195 ret = LB_STATUS_ERROR_INVALID;
3201 * Trust the package name which are sent by the client.
3202 * The package has to be a livebox package name.
3204 inst = package_find_instance_by_id(pkgname, id);
3206 ErrPrint("Instance[%s] is not exists\n", id);
3207 ret = LB_STATUS_ERROR_NOT_EXIST;
3211 pkg = instance_package(inst);
3213 ErrPrint("Package[%s] info is not found\n", pkgname);
3214 ret = LB_STATUS_ERROR_FAULT;
3218 if (package_is_fault(pkg)) {
3221 * If the package is registered as fault module,
3222 * slave has not load it, so we don't need to do anything at here!
3224 DbgPrint("Package[%s] is faulted\n", pkgname);
3225 ret = LB_STATUS_ERROR_FAULT;
3226 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3227 struct buffer_info *buffer;
3228 struct slave_node *slave;
3229 // struct packet *packet;
3231 buffer = instance_pd_buffer(inst);
3233 ErrPrint("Instance[%s] has no buffer\n", id);
3234 ret = LB_STATUS_ERROR_FAULT;
3238 slave = package_slave(pkg);
3240 ErrPrint("Package[%s] has no slave\n", pkgname);
3241 ret = LB_STATUS_ERROR_INVALID;
3246 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3248 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3249 ret = LB_STATUS_ERROR_FAULT;
3254 packet_ref((struct packet *)packet);
3255 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3256 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3257 struct script_info *script;
3260 script = instance_pd_script(inst);
3262 ret = LB_STATUS_ERROR_FAULT;
3266 e = script_handler_evas(script);
3268 ret = LB_STATUS_ERROR_FAULT;
3272 script_handler_update_pointer(script, x, y, -1);
3273 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
3275 struct access_cbdata *cbdata;
3277 cbdata = malloc(sizeof(*cbdata));
3279 ret = LB_STATUS_ERROR_MEMORY;
3281 cbdata->inst = instance_ref(inst);
3282 cbdata->status = ret;
3284 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3285 instance_unref(cbdata->inst);
3287 ret = LB_STATUS_ERROR_FAULT;
3289 ret = LB_STATUS_SUCCESS;
3294 ErrPrint("Unsupported package\n");
3295 ret = LB_STATUS_ERROR_INVALID;
3299 result = packet_create_reply(packet, "i", ret);
3301 ErrPrint("Failed to create a reply packet\n");
3306 static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const struct packet *packet)
3308 struct packet *result;
3309 struct client_node *client;
3310 const char *pkgname;
3316 struct inst_info *inst;
3317 const struct pkg_info *pkg;
3319 client = client_find_by_pid(pid);
3321 ErrPrint("Client %d is not exists\n", pid);
3322 ret = LB_STATUS_ERROR_NOT_EXIST;
3326 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3328 ErrPrint("Invalid parameter\n");
3329 ret = LB_STATUS_ERROR_INVALID;
3333 DbgPrint("%s %s %lf %d %d\n", pkgname, id, timestamp, x, y);
3336 * Trust the package name which are sent by the client.
3337 * The package has to be a livebox package name.
3339 inst = package_find_instance_by_id(pkgname, id);
3341 ErrPrint("Instance[%s] is not exists\n", id);
3342 ret = LB_STATUS_ERROR_NOT_EXIST;
3346 pkg = instance_package(inst);
3348 ErrPrint("Package[%s] info is not found\n", pkgname);
3349 ret = LB_STATUS_ERROR_FAULT;
3353 if (package_is_fault(pkg)) {
3356 * If the package is registered as fault module,
3357 * slave has not load it, so we don't need to do anything at here!
3359 DbgPrint("Package[%s] is faulted\n", pkgname);
3360 ret = LB_STATUS_ERROR_FAULT;
3361 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3362 struct buffer_info *buffer;
3363 struct slave_node *slave;
3364 // struct packet *packet;
3366 buffer = instance_pd_buffer(inst);
3368 ErrPrint("Instance[%s] has no buffer\n", id);
3369 ret = LB_STATUS_ERROR_FAULT;
3373 slave = package_slave(pkg);
3375 ErrPrint("Package[%s] has no slave\n", pkgname);
3376 ret = LB_STATUS_ERROR_INVALID;
3381 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3383 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3384 ret = LB_STATUS_ERROR_FAULT;
3388 DbgPrint("Buffer type PD\n");
3390 packet_ref((struct packet *)packet);
3391 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3392 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3393 struct script_info *script;
3396 script = instance_pd_script(inst);
3398 DbgPrint("Script is not created yet\n");
3399 ret = LB_STATUS_ERROR_FAULT;
3403 e = script_handler_evas(script);
3405 DbgPrint("Evas is not exists\n");
3406 ret = LB_STATUS_ERROR_FAULT;
3410 script_handler_update_pointer(script, x, y, -1);
3411 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
3413 struct access_cbdata *cbdata;
3415 cbdata = malloc(sizeof(*cbdata));
3417 ErrPrint("Heap: %s\n", strerror(errno));
3418 ret = LB_STATUS_ERROR_MEMORY;
3420 cbdata->inst = instance_ref(inst);
3421 cbdata->status = ret;
3423 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3424 DbgPrint("Failed to add timer\n");
3425 instance_unref(cbdata->inst);
3427 ret = LB_STATUS_ERROR_FAULT;
3429 DbgPrint("Timer is added\n");
3430 ret = LB_STATUS_SUCCESS;
3434 DbgPrint("Returns: %d\n", ret);
3437 ErrPrint("Unsupported package\n");
3438 ret = LB_STATUS_ERROR_INVALID;
3442 result = packet_create_reply(packet, "i", ret);
3444 ErrPrint("Failed to create a reply packet\n");
3449 static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
3451 struct packet *result;
3452 struct client_node *client;
3453 const char *pkgname;
3459 struct inst_info *inst;
3460 const struct pkg_info *pkg;
3462 client = client_find_by_pid(pid);
3464 ErrPrint("Client %d is not exists\n", pid);
3465 ret = LB_STATUS_ERROR_NOT_EXIST;
3469 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3471 ErrPrint("Invalid parameter\n");
3472 ret = LB_STATUS_ERROR_INVALID;
3478 * Trust the package name which are sent by the client.
3479 * The package has to be a livebox package name.
3481 inst = package_find_instance_by_id(pkgname, id);
3483 ErrPrint("Instance[%s] is not exists\n", id);
3484 ret = LB_STATUS_ERROR_NOT_EXIST;
3488 pkg = instance_package(inst);
3490 ErrPrint("Package[%s] info is not found\n", pkgname);
3491 ret = LB_STATUS_ERROR_FAULT;
3495 if (package_is_fault(pkg)) {
3498 * If the package is registered as fault module,
3499 * slave has not load it, so we don't need to do anything at here!
3501 DbgPrint("Package[%s] is faulted\n", pkgname);
3502 ret = LB_STATUS_ERROR_FAULT;
3503 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3504 struct buffer_info *buffer;
3505 struct slave_node *slave;
3506 // struct packet *packet;
3508 buffer = instance_pd_buffer(inst);
3510 ErrPrint("Instance[%s] has no buffer\n", id);
3511 ret = LB_STATUS_ERROR_FAULT;
3515 slave = package_slave(pkg);
3517 ErrPrint("Package[%s] has no slave\n", pkgname);
3518 ret = LB_STATUS_ERROR_INVALID;
3523 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3525 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3526 ret = LB_STATUS_ERROR_FAULT;
3531 packet_ref((struct packet *)packet);
3532 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3533 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3534 struct script_info *script;
3537 script = instance_pd_script(inst);
3539 ret = LB_STATUS_ERROR_FAULT;
3543 e = script_handler_evas(script);
3545 ret = LB_STATUS_ERROR_FAULT;
3549 script_handler_update_pointer(script, x, y, -1);
3550 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
3552 struct access_cbdata *cbdata;
3554 cbdata = malloc(sizeof(*cbdata));
3556 ret = LB_STATUS_ERROR_MEMORY;
3558 cbdata->inst = instance_ref(inst);
3559 cbdata->status = ret;
3561 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3562 instance_unref(cbdata->inst);
3564 ret = LB_STATUS_ERROR_FAULT;
3566 ret = LB_STATUS_SUCCESS;
3571 ErrPrint("Unsupported package\n");
3572 ret = LB_STATUS_ERROR_INVALID;
3576 result = packet_create_reply(packet, "i", ret);
3578 ErrPrint("Failed to create a reply packet\n");
3583 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
3585 struct client_node *client;
3586 const char *pkgname;
3592 struct inst_info *inst;
3593 const struct pkg_info *pkg;
3595 client = client_find_by_pid(pid);
3597 ErrPrint("Client %d is not exists\n", pid);
3598 ret = LB_STATUS_ERROR_NOT_EXIST;
3602 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3604 ErrPrint("Invalid parameter\n");
3605 ret = LB_STATUS_ERROR_INVALID;
3611 * Trust the package name which are sent by the client.
3612 * The package has to be a livebox package name.
3614 inst = package_find_instance_by_id(pkgname, id);
3616 ErrPrint("Instance[%s] is not exists\n", id);
3617 ret = LB_STATUS_ERROR_NOT_EXIST;
3621 pkg = instance_package(inst);
3623 ErrPrint("Package[%s] info is not found\n", pkgname);
3624 ret = LB_STATUS_ERROR_FAULT;
3628 if (package_is_fault(pkg)) {
3631 * If the package is registered as fault module,
3632 * slave has not load it, so we don't need to do anything at here!
3634 DbgPrint("Package[%s] is faulted\n", pkgname);
3635 ret = LB_STATUS_ERROR_FAULT;
3636 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3637 struct buffer_info *buffer;
3638 struct slave_node *slave;
3639 // struct packet *packet;
3641 buffer = instance_pd_buffer(inst);
3643 ErrPrint("Instance[%s] has no buffer\n", id);
3644 ret = LB_STATUS_ERROR_FAULT;
3648 slave = package_slave(pkg);
3650 ErrPrint("Package[%s] has no slave\n", pkgname);
3651 ret = LB_STATUS_ERROR_INVALID;
3656 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3658 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3659 ret = LB_STATUS_ERROR_FAULT;
3664 packet_ref((struct packet *)packet);
3665 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3666 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3667 struct script_info *script;
3670 script = instance_pd_script(inst);
3672 ret = LB_STATUS_ERROR_FAULT;
3676 e = script_handler_evas(script);
3678 ret = LB_STATUS_ERROR_FAULT;
3682 script_handler_update_pointer(script, x, y, -1);
3684 * \TODO: Push up the KEY_DOWN event
3688 ErrPrint("Unsupported package\n");
3689 ret = LB_STATUS_ERROR_INVALID;
3693 /*! \note No reply packet */
3697 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
3699 struct client_node *client;
3703 client = client_find_by_pid(pid);
3705 ErrPrint("Client %d is paused - manually reported\n", pid);
3706 ret = LB_STATUS_ERROR_NOT_EXIST;
3710 ret = packet_get(packet, "d", ×tamp);
3712 ErrPrint("Invalid parameter\n");
3713 ret = LB_STATUS_ERROR_INVALID;
3718 DbgPrint("XMONITOR enabled. ignore client paused request\n");
3720 xmonitor_pause(client);
3726 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
3728 struct client_node *client;
3732 client = client_find_by_pid(pid);
3734 ErrPrint("Client %d is not exists\n", pid);
3738 ret = packet_get(packet, "d", ×tamp);
3740 ErrPrint("Invalid parameter\n");
3745 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
3747 xmonitor_resume(client);
3753 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
3755 struct client_node *client;
3756 const char *pkgname;
3762 struct inst_info *inst;
3763 const struct pkg_info *pkg;
3765 client = client_find_by_pid(pid);
3767 ErrPrint("Client %d is not exists\n", pid);
3768 ret = LB_STATUS_ERROR_NOT_EXIST;
3772 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3774 ErrPrint("Invalid parameter\n");
3775 ret = LB_STATUS_ERROR_INVALID;
3781 * Trust the package name which are sent by the client.
3782 * The package has to be a livebox package name.
3784 inst = package_find_instance_by_id(pkgname, id);
3786 ErrPrint("Instance[%s] is not exists\n", id);
3787 ret = LB_STATUS_ERROR_NOT_EXIST;
3791 pkg = instance_package(inst);
3793 ErrPrint("Package[%s] info is not found\n", pkgname);
3794 ret = LB_STATUS_ERROR_FAULT;
3798 if (package_is_fault(pkg)) {
3801 * If the package is registered as fault module,
3802 * slave has not load it, so we don't need to do anything at here!
3804 DbgPrint("Package[%s] is faulted\n", pkgname);
3805 ret = LB_STATUS_ERROR_FAULT;
3806 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3807 struct buffer_info *buffer;
3808 struct slave_node *slave;
3809 // struct packet *packet;
3811 buffer = instance_pd_buffer(inst);
3813 ErrPrint("Instance[%s] has no buffer\n", id);
3814 ret = LB_STATUS_ERROR_FAULT;
3818 slave = package_slave(pkg);
3820 ErrPrint("Package[%s] has no slave\n", pkgname);
3821 ret = LB_STATUS_ERROR_INVALID;
3826 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3828 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3829 ret = LB_STATUS_ERROR_FAULT;
3834 packet_ref((struct packet *)packet);
3835 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3836 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3837 struct script_info *script;
3840 script = instance_pd_script(inst);
3842 ret = LB_STATUS_ERROR_FAULT;
3846 e = script_handler_evas(script);
3848 ret = LB_STATUS_ERROR_FAULT;
3852 script_handler_update_pointer(script, x, y, -1);
3854 * \TODO: Push up the KEY_UP event
3858 ErrPrint("Unsupported package\n");
3859 ret = LB_STATUS_ERROR_INVALID;
3863 /*! \note No reply packet */
3867 static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
3869 struct packet *result;
3870 struct client_node *client;
3871 const char *pkgname;
3877 struct inst_info *inst;
3878 const struct pkg_info *pkg;
3880 client = client_find_by_pid(pid);
3882 ErrPrint("Client %d is not exists\n", pid);
3883 ret = LB_STATUS_ERROR_NOT_EXIST;
3887 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3889 ErrPrint("Parameter is not matched\n");
3890 ret = LB_STATUS_ERROR_INVALID;
3896 * Trust the package name which are sent by the client.
3897 * The package has to be a livebox package name.
3899 inst = package_find_instance_by_id(pkgname, id);
3901 ErrPrint("Instance[%s] is not exists\n", id);
3902 ret = LB_STATUS_ERROR_NOT_EXIST;
3906 pkg = instance_package(inst);
3908 ErrPrint("Package[%s] info is not exists\n", pkgname);
3909 ret = LB_STATUS_ERROR_FAULT;
3913 if (package_is_fault(pkg)) {
3916 * If the package is registered as fault module,
3917 * slave has not load it, so we don't need to do anything at here!
3919 DbgPrint("Package[%s] is faulted\n", pkgname);
3920 ret = LB_STATUS_ERROR_FAULT;
3921 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3922 struct buffer_info *buffer;
3923 struct slave_node *slave;
3924 //struct packet *packet;
3926 buffer = instance_lb_buffer(inst);
3928 ErrPrint("Instance[%s] has no buffer\n", id);
3929 ret = LB_STATUS_ERROR_FAULT;
3933 slave = package_slave(pkg);
3935 ErrPrint("Package[%s] has no slave\n", pkgname);
3936 ret = LB_STATUS_ERROR_INVALID;
3941 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3943 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3944 ret = LB_STATUS_ERROR_FAULT;
3949 packet_ref((struct packet *)packet);
3950 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3951 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3952 struct script_info *script;
3955 script = instance_lb_script(inst);
3957 ret = LB_STATUS_ERROR_FAULT;
3961 e = script_handler_evas(script);
3963 ret = LB_STATUS_ERROR_FAULT;
3967 script_handler_update_pointer(script, x, y, -1);
3968 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
3970 struct access_cbdata *cbdata;
3972 cbdata = malloc(sizeof(*cbdata));
3974 ret = LB_STATUS_ERROR_MEMORY;
3976 cbdata->inst = instance_ref(inst);
3977 cbdata->status = ret;
3979 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3980 instance_unref(cbdata->inst);
3982 ret = LB_STATUS_ERROR_FAULT;
3984 ret = LB_STATUS_SUCCESS;
3989 ErrPrint("Unsupported package\n");
3990 ret = LB_STATUS_ERROR_INVALID;
3994 result = packet_create_reply(packet, "i", ret);
3996 ErrPrint("Failed to create a reply packet\n");
4001 static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
4003 struct packet *result;
4004 struct client_node *client;
4005 const char *pkgname;
4011 struct inst_info *inst;
4012 const struct pkg_info *pkg;
4014 client = client_find_by_pid(pid);
4016 ErrPrint("Client %d is not exists\n", pid);
4017 ret = LB_STATUS_ERROR_NOT_EXIST;
4021 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4023 ErrPrint("Parameter is not matched\n");
4024 ret = LB_STATUS_ERROR_INVALID;
4030 * Trust the package name which are sent by the client.
4031 * The package has to be a livebox package name.
4033 inst = package_find_instance_by_id(pkgname, id);
4035 ErrPrint("Instance[%s] is not exists\n", id);
4036 ret = LB_STATUS_ERROR_NOT_EXIST;
4040 pkg = instance_package(inst);
4042 ErrPrint("Package[%s] info is not exists\n", pkgname);
4043 ret = LB_STATUS_ERROR_FAULT;
4047 if (package_is_fault(pkg)) {
4050 * If the package is registered as fault module,
4051 * slave has not load it, so we don't need to do anything at here!
4053 DbgPrint("Package[%s] is faulted\n", pkgname);
4054 ret = LB_STATUS_ERROR_FAULT;
4055 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4056 struct buffer_info *buffer;
4057 struct slave_node *slave;
4058 //struct packet *packet;
4060 buffer = instance_lb_buffer(inst);
4062 ErrPrint("Instance[%s] has no buffer\n", id);
4063 ret = LB_STATUS_ERROR_FAULT;
4067 slave = package_slave(pkg);
4069 ErrPrint("Package[%s] has no slave\n", pkgname);
4070 ret = LB_STATUS_ERROR_INVALID;
4075 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4077 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4078 ret = LB_STATUS_ERROR_FAULT;
4083 packet_ref((struct packet *)packet);
4084 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4085 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4086 struct script_info *script;
4089 script = instance_lb_script(inst);
4091 ret = LB_STATUS_ERROR_FAULT;
4095 e = script_handler_evas(script);
4097 ret = LB_STATUS_ERROR_FAULT;
4101 script_handler_update_pointer(script, x, y, -1);
4102 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
4104 struct access_cbdata *cbdata;
4106 cbdata = malloc(sizeof(*cbdata));
4108 ret = LB_STATUS_ERROR_MEMORY;
4110 cbdata->inst = instance_ref(inst);
4111 cbdata->status = ret;
4113 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4114 instance_unref(cbdata->inst);
4116 ret = LB_STATUS_ERROR_FAULT;
4118 ret = LB_STATUS_SUCCESS;
4123 ErrPrint("Unsupported package\n");
4124 ret = LB_STATUS_ERROR_INVALID;
4128 result = packet_create_reply(packet, "i", ret);
4130 ErrPrint("Failed to create a reply packet\n");
4135 static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet)
4137 struct packet *result;
4138 struct client_node *client;
4139 const char *pkgname;
4145 struct inst_info *inst;
4146 const struct pkg_info *pkg;
4148 client = client_find_by_pid(pid);
4150 ErrPrint("Client %d is not exists\n", pid);
4151 ret = LB_STATUS_ERROR_NOT_EXIST;
4155 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4157 ErrPrint("Parameter is not matched\n");
4158 ret = LB_STATUS_ERROR_INVALID;
4164 * Trust the package name which are sent by the client.
4165 * The package has to be a livebox package name.
4167 inst = package_find_instance_by_id(pkgname, id);
4169 ErrPrint("Instance[%s] is not exists\n", id);
4170 ret = LB_STATUS_ERROR_NOT_EXIST;
4174 pkg = instance_package(inst);
4176 ErrPrint("Package[%s] info is not exists\n", pkgname);
4177 ret = LB_STATUS_ERROR_FAULT;
4181 if (package_is_fault(pkg)) {
4184 * If the package is registered as fault module,
4185 * slave has not load it, so we don't need to do anything at here!
4187 DbgPrint("Package[%s] is faulted\n", pkgname);
4188 ret = LB_STATUS_ERROR_FAULT;
4189 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4190 struct buffer_info *buffer;
4191 struct slave_node *slave;
4192 //struct packet *packet;
4194 buffer = instance_lb_buffer(inst);
4196 ErrPrint("Instance[%s] has no buffer\n", id);
4197 ret = LB_STATUS_ERROR_FAULT;
4201 slave = package_slave(pkg);
4203 ErrPrint("Package[%s] has no slave\n", pkgname);
4204 ret = LB_STATUS_ERROR_INVALID;
4209 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4211 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4212 ret = LB_STATUS_ERROR_FAULT;
4217 packet_ref((struct packet *)packet);
4218 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4219 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4220 struct script_info *script;
4223 script = instance_lb_script(inst);
4225 ret = LB_STATUS_ERROR_FAULT;
4229 e = script_handler_evas(script);
4231 ret = LB_STATUS_ERROR_FAULT;
4235 script_handler_update_pointer(script, x, y, -1);
4236 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
4238 struct access_cbdata *cbdata;
4240 cbdata = malloc(sizeof(*cbdata));
4242 ret = LB_STATUS_ERROR_MEMORY;
4244 cbdata->inst = instance_ref(inst);
4245 cbdata->status = ret;
4247 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4248 instance_unref(cbdata->inst);
4250 ret = LB_STATUS_ERROR_FAULT;
4252 ret = LB_STATUS_SUCCESS;
4257 ErrPrint("Unsupported package\n");
4258 ret = LB_STATUS_ERROR_INVALID;
4262 result = packet_create_reply(packet, "i", ret);
4264 ErrPrint("Failed to create a reply packet\n");
4269 static struct packet *client_lb_access_action_up(pid_t pid, int handle, const struct packet *packet)
4271 struct packet *result;
4272 struct client_node *client;
4273 const char *pkgname;
4277 struct inst_info *inst;
4278 const struct pkg_info *pkg;
4282 client = client_find_by_pid(pid);
4284 ErrPrint("Client %d is not exist\n", pid);
4285 ret = LB_STATUS_ERROR_NOT_EXIST;
4289 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4291 ErrPrint("Parameter is not matched\n");
4292 ret = LB_STATUS_ERROR_INVALID;
4296 inst = package_find_instance_by_id(pkgname, id);
4298 ErrPrint("Instance[%s] is not exists\n", id);
4299 ret = LB_STATUS_ERROR_NOT_EXIST;
4303 pkg = instance_package(inst);
4305 ErrPrint("Package[%s] info is not exists\n", pkgname);
4306 ret = LB_STATUS_ERROR_FAULT;
4310 if (package_is_fault(pkg)) {
4311 ret = LB_STATUS_ERROR_FAULT;
4312 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4313 struct buffer_info *buffer;
4314 struct slave_node *slave;
4316 buffer = instance_lb_buffer(inst);
4318 ErrPrint("Instance[%s] has no buffer\n", id);
4319 ret = LB_STATUS_ERROR_FAULT;
4323 slave = package_slave(pkg);
4325 ErrPrint("Slave is not exists\n");
4326 ret = LB_STATUS_ERROR_INVALID;
4330 packet_ref((struct packet *)packet);
4331 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4333 * Enen if it fails to send packet,
4334 * The packet will be unref'd
4335 * So we don't need to check the ret value.
4337 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4338 struct script_info *script;
4341 script = instance_lb_script(inst);
4343 ErrPrint("Instance has no script\n");
4344 ret = LB_STATUS_ERROR_FAULT;
4348 e = script_handler_evas(script);
4350 ErrPrint("Script has no evas\n");
4351 ret = LB_STATUS_ERROR_INVALID;
4355 script_handler_update_pointer(script, x, y, 0);
4356 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
4358 struct access_cbdata *cbdata;
4360 cbdata = malloc(sizeof(*cbdata));
4362 ret = LB_STATUS_ERROR_MEMORY;
4364 cbdata->inst = instance_ref(inst);
4365 cbdata->status = ret;
4367 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4368 instance_unref(cbdata->inst);
4370 ret = LB_STATUS_ERROR_FAULT;
4372 ret = LB_STATUS_SUCCESS;
4377 ErrPrint("Unsupported package\n");
4378 ret = LB_STATUS_ERROR_INVALID;
4382 result = packet_create_reply(packet, "i", ret);
4384 ErrPrint("Failed to create a reply packet\n");
4389 static struct packet *client_lb_access_action_down(pid_t pid, int handle, const struct packet *packet)
4391 struct packet *result;
4392 struct client_node *client;
4393 const char *pkgname;
4397 struct inst_info *inst;
4398 const struct pkg_info *pkg;
4402 client = client_find_by_pid(pid);
4404 ErrPrint("Client %d is not exist\n", pid);
4405 ret = LB_STATUS_ERROR_NOT_EXIST;
4409 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4411 ErrPrint("Parameter is not matched\n");
4412 ret = LB_STATUS_ERROR_INVALID;
4416 inst = package_find_instance_by_id(pkgname, id);
4418 ErrPrint("Instance[%s] is not exists\n", id);
4419 ret = LB_STATUS_ERROR_NOT_EXIST;
4423 pkg = instance_package(inst);
4425 ErrPrint("Package[%s] info is not exists\n", pkgname);
4426 ret = LB_STATUS_ERROR_FAULT;
4430 if (package_is_fault(pkg)) {
4431 ret = LB_STATUS_ERROR_FAULT;
4432 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4433 struct buffer_info *buffer;
4434 struct slave_node *slave;
4436 buffer = instance_lb_buffer(inst);
4438 ErrPrint("Instance[%s] has no buffer\n", id);
4439 ret = LB_STATUS_ERROR_FAULT;
4443 slave = package_slave(pkg);
4445 ErrPrint("Slave is not exists\n");
4446 ret = LB_STATUS_ERROR_INVALID;
4450 packet_ref((struct packet *)packet);
4451 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4453 * Enen if it fails to send packet,
4454 * The packet will be unref'd
4455 * So we don't need to check the ret value.
4457 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4458 struct script_info *script;
4461 script = instance_lb_script(inst);
4463 ErrPrint("Instance has no script\n");
4464 ret = LB_STATUS_ERROR_FAULT;
4468 e = script_handler_evas(script);
4470 ErrPrint("Script has no evas\n");
4471 ret = LB_STATUS_ERROR_INVALID;
4475 script_handler_update_pointer(script, x, y, 1);
4476 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
4478 struct access_cbdata *cbdata;
4480 cbdata = malloc(sizeof(*cbdata));
4482 ret = LB_STATUS_ERROR_MEMORY;
4484 cbdata->inst = instance_ref(inst);
4485 cbdata->status = ret;
4487 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4488 instance_unref(cbdata->inst);
4490 ret = LB_STATUS_ERROR_FAULT;
4492 ret = LB_STATUS_SUCCESS;
4497 ErrPrint("Unsupported package\n");
4498 ret = LB_STATUS_ERROR_INVALID;
4502 result = packet_create_reply(packet, "i", ret);
4504 ErrPrint("Failed to create a reply packet\n");
4509 static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
4511 struct packet *result;
4512 struct client_node *client;
4513 const char *pkgname;
4519 struct inst_info *inst;
4520 const struct pkg_info *pkg;
4522 client = client_find_by_pid(pid);
4524 ErrPrint("Client %d is not exists\n", pid);
4525 ret = LB_STATUS_ERROR_NOT_EXIST;
4529 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4531 ErrPrint("Parameter is not matched\n");
4532 ret = LB_STATUS_ERROR_INVALID;
4538 * Trust the package name which are sent by the client.
4539 * The package has to be a livebox package name.
4541 inst = package_find_instance_by_id(pkgname, id);
4543 ErrPrint("Instance[%s] is not exists\n", id);
4544 ret = LB_STATUS_ERROR_NOT_EXIST;
4548 pkg = instance_package(inst);
4550 ErrPrint("Package[%s] info is not exists\n", pkgname);
4551 ret = LB_STATUS_ERROR_FAULT;
4555 if (package_is_fault(pkg)) {
4558 * If the package is registered as fault module,
4559 * slave has not load it, so we don't need to do anything at here!
4561 DbgPrint("Package[%s] is faulted\n", pkgname);
4562 ret = LB_STATUS_ERROR_FAULT;
4563 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4564 struct buffer_info *buffer;
4565 struct slave_node *slave;
4566 //struct packet *packet;
4568 buffer = instance_lb_buffer(inst);
4570 ErrPrint("Instance[%s] has no buffer\n", id);
4571 ret = LB_STATUS_ERROR_FAULT;
4575 slave = package_slave(pkg);
4577 ErrPrint("Package[%s] has no slave\n", pkgname);
4578 ret = LB_STATUS_ERROR_INVALID;
4583 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4585 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4586 ret = LB_STATUS_ERROR_FAULT;
4591 packet_ref((struct packet *)packet);
4592 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4593 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4594 struct script_info *script;
4597 script = instance_lb_script(inst);
4599 ret = LB_STATUS_ERROR_FAULT;
4603 e = script_handler_evas(script);
4605 ret = LB_STATUS_ERROR_FAULT;
4609 script_handler_update_pointer(script, x, y, -1);
4610 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
4612 struct access_cbdata *cbdata;
4614 cbdata = malloc(sizeof(*cbdata));
4616 ret = LB_STATUS_ERROR_MEMORY;
4618 cbdata->inst = instance_ref(inst);
4619 cbdata->status = ret;
4621 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4622 instance_unref(cbdata->inst);
4624 ret = LB_STATUS_ERROR_FAULT;
4626 ret = LB_STATUS_SUCCESS;
4631 ErrPrint("Unsupported package\n");
4632 ret = LB_STATUS_ERROR_INVALID;
4636 result = packet_create_reply(packet, "i", ret);
4638 ErrPrint("Failed to create a reply packet\n");
4643 static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
4645 struct packet *result;
4646 struct client_node *client;
4647 const char *pkgname;
4651 struct inst_info *inst;
4652 const struct pkg_info *pkg;
4656 client = client_find_by_pid(pid);
4658 ErrPrint("Client %d is not exist\n", pid);
4659 ret = LB_STATUS_ERROR_NOT_EXIST;
4663 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4665 ErrPrint("Parameter is not matched\n");
4666 ret = LB_STATUS_ERROR_INVALID;
4670 inst = package_find_instance_by_id(pkgname, id);
4672 ErrPrint("Instance[%s] is not exists\n", id);
4673 ret = LB_STATUS_ERROR_NOT_EXIST;
4677 pkg = instance_package(inst);
4679 ErrPrint("Package[%s] info is not exists\n", pkgname);
4680 ret = LB_STATUS_ERROR_FAULT;
4684 if (package_is_fault(pkg)) {
4685 ret = LB_STATUS_ERROR_FAULT;
4686 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4687 struct buffer_info *buffer;
4688 struct slave_node *slave;
4690 buffer = instance_lb_buffer(inst);
4692 ErrPrint("Instance[%s] has no buffer\n", id);
4693 ret = LB_STATUS_ERROR_FAULT;
4697 slave = package_slave(pkg);
4699 ErrPrint("Slave is not exists\n");
4700 ret = LB_STATUS_ERROR_INVALID;
4704 packet_ref((struct packet *)packet);
4705 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4707 * Enen if it fails to send packet,
4708 * The packet will be unref'd
4709 * So we don't need to check the ret value.
4711 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4712 struct script_info *script;
4715 script = instance_lb_script(inst);
4717 ErrPrint("Instance has no script\n");
4718 ret = LB_STATUS_ERROR_FAULT;
4722 e = script_handler_evas(script);
4724 ErrPrint("Instance has no evas\n");
4725 ret = LB_STATUS_ERROR_INVALID;
4729 script_handler_update_pointer(script, x, y, 1);
4730 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
4732 struct access_cbdata *cbdata;
4734 cbdata = malloc(sizeof(*cbdata));
4736 ret = LB_STATUS_ERROR_MEMORY;
4738 cbdata->inst = instance_ref(inst);
4739 cbdata->status = ret;
4741 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4742 instance_unref(cbdata->inst);
4744 ret = LB_STATUS_ERROR_FAULT;
4746 ret = LB_STATUS_SUCCESS;
4751 ErrPrint("Unsupported package\n");
4752 ret = LB_STATUS_ERROR_INVALID;
4756 result = packet_create_reply(packet, "i", ret);
4758 ErrPrint("Failed to create a reply packet\n");
4763 static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
4765 struct packet *result;
4766 struct client_node *client;
4767 const char *pkgname;
4771 struct inst_info *inst;
4772 const struct pkg_info *pkg;
4776 client = client_find_by_pid(pid);
4778 ErrPrint("Client %d is not exist\n", pid);
4779 ret = LB_STATUS_ERROR_NOT_EXIST;
4783 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4785 ErrPrint("Parameter is not matched\n");
4786 ret = LB_STATUS_ERROR_INVALID;
4790 inst = package_find_instance_by_id(pkgname, id);
4792 ErrPrint("Instance[%s] is not exists\n", id);
4793 ret = LB_STATUS_ERROR_NOT_EXIST;
4797 pkg = instance_package(inst);
4799 ErrPrint("Package[%s] info is not exists\n", pkgname);
4800 ret = LB_STATUS_ERROR_FAULT;
4804 if (package_is_fault(pkg)) {
4805 ret = LB_STATUS_ERROR_FAULT;
4806 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4807 struct buffer_info *buffer;
4808 struct slave_node *slave;
4810 buffer = instance_lb_buffer(inst);
4812 ErrPrint("Instance[%s] has no buffer\n", id);
4813 ret = LB_STATUS_ERROR_FAULT;
4817 slave = package_slave(pkg);
4819 ErrPrint("Slave is not exists\n");
4820 ret = LB_STATUS_ERROR_INVALID;
4824 packet_ref((struct packet *)packet);
4825 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4827 * Enen if it fails to send packet,
4828 * The packet will be unref'd
4829 * So we don't need to check the ret value.
4831 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4832 struct script_info *script;
4835 script = instance_lb_script(inst);
4837 ErrPrint("Instance has no script\n");
4838 ret = LB_STATUS_ERROR_FAULT;
4842 e = script_handler_evas(script);
4844 ErrPrint("Instance has no evas\n");
4845 ret = LB_STATUS_ERROR_INVALID;
4849 script_handler_update_pointer(script, x, y, -1);
4850 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
4852 struct access_cbdata *cbdata;
4854 cbdata = malloc(sizeof(*cbdata));
4856 ret = LB_STATUS_ERROR_MEMORY;
4858 cbdata->inst = instance_ref(inst);
4859 cbdata->status = ret;
4861 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4862 instance_unref(cbdata->inst);
4864 ret = LB_STATUS_ERROR_FAULT;
4866 ret = LB_STATUS_SUCCESS;
4871 ErrPrint("Unsupported package\n");
4872 ret = LB_STATUS_ERROR_INVALID;
4876 result = packet_create_reply(packet, "i", ret);
4878 ErrPrint("Failed to create a reply packet\n");
4883 static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
4885 struct packet *result;
4886 struct client_node *client;
4887 const char *pkgname;
4891 struct inst_info *inst;
4892 const struct pkg_info *pkg;
4896 client = client_find_by_pid(pid);
4898 ErrPrint("Client %d is not exist\n", pid);
4899 ret = LB_STATUS_ERROR_NOT_EXIST;
4903 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4905 ErrPrint("Parameter is not matched\n");
4906 ret = LB_STATUS_ERROR_INVALID;
4910 inst = package_find_instance_by_id(pkgname, id);
4912 ErrPrint("Instance[%s] is not exists\n", id);
4913 ret = LB_STATUS_ERROR_NOT_EXIST;
4917 pkg = instance_package(inst);
4919 ErrPrint("Package[%s] info is not exists\n", pkgname);
4920 ret = LB_STATUS_ERROR_FAULT;
4924 if (package_is_fault(pkg)) {
4925 ret = LB_STATUS_ERROR_FAULT;
4926 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4927 struct buffer_info *buffer;
4928 struct slave_node *slave;
4930 buffer = instance_lb_buffer(inst);
4932 ErrPrint("Instance[%s] has no buffer\n", id);
4933 ret = LB_STATUS_ERROR_FAULT;
4937 slave = package_slave(pkg);
4939 ErrPrint("Slave is not exists\n");
4940 ret = LB_STATUS_ERROR_INVALID;
4944 packet_ref((struct packet *)packet);
4945 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4947 * Enen if it fails to send packet,
4948 * The packet will be unref'd
4949 * So we don't need to check the ret value.
4951 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4952 struct script_info *script;
4955 script = instance_lb_script(inst);
4957 ErrPrint("Instance has no script\n");
4958 ret = LB_STATUS_ERROR_FAULT;
4962 e = script_handler_evas(script);
4964 ErrPrint("Instance has no evas\n");
4965 ret = LB_STATUS_ERROR_INVALID;
4969 script_handler_update_pointer(script, x, y, 0);
4970 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
4972 struct access_cbdata *cbdata;
4974 cbdata = malloc(sizeof(*cbdata));
4976 ret = LB_STATUS_ERROR_MEMORY;
4978 cbdata->inst = instance_ref(inst);
4979 cbdata->status = ret;
4981 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4982 instance_unref(cbdata->inst);
4984 ret = LB_STATUS_ERROR_FAULT;
4986 ret = LB_STATUS_SUCCESS;
4991 ErrPrint("Unsupported package\n");
4992 ret = LB_STATUS_ERROR_INVALID;
4996 result = packet_create_reply(packet, "i", ret);
4998 ErrPrint("Failed to create a reply packet\n");
5003 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
5005 struct packet *result;
5006 struct client_node *client;
5007 const char *pkgname;
5013 struct inst_info *inst;
5014 const struct pkg_info *pkg;
5016 client = client_find_by_pid(pid);
5018 ErrPrint("Client %d is not exists\n", pid);
5019 ret = LB_STATUS_ERROR_NOT_EXIST;
5023 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
5025 ErrPrint("Parameter is not matched\n");
5026 ret = LB_STATUS_ERROR_INVALID;
5032 * Trust the package name which are sent by the client.
5033 * The package has to be a livebox package name.
5035 inst = package_find_instance_by_id(pkgname, id);
5037 ErrPrint("Instance[%s] is not exists\n", id);
5038 ret = LB_STATUS_ERROR_NOT_EXIST;
5042 pkg = instance_package(inst);
5044 ErrPrint("Package[%s] info is not exists\n", pkgname);
5045 ret = LB_STATUS_ERROR_INVALID;
5049 if (package_is_fault(pkg)) {
5052 * If the package is registered as fault module,
5053 * slave has not load it, so we don't need to do anything at here!
5055 DbgPrint("Package[%s] is faulted\n", pkgname);
5056 ret = LB_STATUS_ERROR_FAULT;
5057 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5058 struct buffer_info *buffer;
5059 struct slave_node *slave;
5060 //struct packet *packet;
5062 buffer = instance_lb_buffer(inst);
5064 ErrPrint("Instance[%s] has no buffer\n", id);
5065 ret = LB_STATUS_ERROR_FAULT;
5069 slave = package_slave(pkg);
5071 ErrPrint("Package[%s] has no slave\n", pkgname);
5072 ret = LB_STATUS_ERROR_INVALID;
5077 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
5079 ErrPrint("Failed to create a packet[%s]\n", pkgname);
5080 ret = LB_STATUS_ERROR_FAULT;
5085 packet_ref((struct packet *)packet);
5086 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
5087 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
5088 struct script_info *script;
5091 script = instance_lb_script(inst);
5093 ErrPrint("Instance has no script\n");
5094 ret = LB_STATUS_ERROR_FAULT;
5098 e = script_handler_evas(script);
5100 ErrPrint("Script has no Evas\n");
5101 ret = LB_STATUS_ERROR_INVALID;
5105 script_handler_update_pointer(script, x, y, -1);
5106 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
5108 struct access_cbdata *cbdata;
5110 cbdata = malloc(sizeof(*cbdata));
5112 ret = LB_STATUS_ERROR_MEMORY;
5114 cbdata->inst = instance_ref(inst);
5115 cbdata->status = ret;
5117 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
5118 instance_unref(cbdata->inst);
5120 ret = LB_STATUS_ERROR_FAULT;
5122 ret = LB_STATUS_SUCCESS;
5127 ErrPrint("Unsupported package\n");
5128 ret = LB_STATUS_ERROR_INVALID;
5132 result = packet_create_reply(packet, "i", ret);
5134 ErrPrint("Failed to create a reply packet\n");
5139 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
5141 struct client_node *client;
5142 const char *pkgname;
5148 struct inst_info *inst;
5149 const struct pkg_info *pkg;
5151 client = client_find_by_pid(pid);
5153 ErrPrint("Client %d is not exists\n", pid);
5154 ret = LB_STATUS_ERROR_NOT_EXIST;
5158 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
5160 ErrPrint("Parameter is not matched\n");
5161 ret = LB_STATUS_ERROR_INVALID;
5167 * Trust the package name which are sent by the client.
5168 * The package has to be a livebox package name.
5170 inst = package_find_instance_by_id(pkgname, id);
5172 ErrPrint("Instance[%s] is not exists\n", id);
5173 ret = LB_STATUS_ERROR_NOT_EXIST;
5177 pkg = instance_package(inst);
5179 ErrPrint("Package[%s] info is not exists\n", pkgname);
5180 ret = LB_STATUS_ERROR_FAULT;
5184 if (package_is_fault(pkg)) {
5187 * If the package is registered as fault module,
5188 * slave has not load it, so we don't need to do anything at here!
5190 DbgPrint("Package[%s] is faulted\n", pkgname);
5191 ret = LB_STATUS_ERROR_FAULT;
5192 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5193 struct buffer_info *buffer;
5194 struct slave_node *slave;
5195 //struct packet *packet;
5197 buffer = instance_lb_buffer(inst);
5199 ErrPrint("Instance[%s] has no buffer\n", id);
5200 ret = LB_STATUS_ERROR_FAULT;
5204 slave = package_slave(pkg);
5206 ErrPrint("Package[%s] has no slave\n", pkgname);
5207 ret = LB_STATUS_ERROR_INVALID;
5212 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
5214 ErrPrint("Failed to create a packet[%s]\n", pkgname);
5215 ret = LB_STATUS_ERROR_FAULT;
5220 packet_ref((struct packet *)packet);
5221 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
5222 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
5223 struct script_info *script;
5226 script = instance_lb_script(inst);
5228 ret = LB_STATUS_ERROR_FAULT;
5232 e = script_handler_evas(script);
5234 ret = LB_STATUS_ERROR_FAULT;
5238 script_handler_update_pointer(script, x, y, -1);
5241 * \TODO: Feed up this KEY_DOWN event
5245 ErrPrint("Unsupported package\n");
5246 ret = LB_STATUS_ERROR_INVALID;
5250 /*! \note No reply packet */
5254 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
5256 struct client_node *client;
5257 const char *pkgname;
5263 struct inst_info *inst;
5264 const struct pkg_info *pkg;
5266 client = client_find_by_pid(pid);
5268 ErrPrint("Client %d is not exists\n", pid);
5269 ret = LB_STATUS_ERROR_NOT_EXIST;
5273 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
5275 ErrPrint("Parameter is not matched\n");
5276 ret = LB_STATUS_ERROR_INVALID;
5282 * Trust the package name which are sent by the client.
5283 * The package has to be a livebox package name.
5285 inst = package_find_instance_by_id(pkgname, id);
5287 ErrPrint("Instance[%s] is not exists\n", id);
5288 ret = LB_STATUS_ERROR_NOT_EXIST;
5292 pkg = instance_package(inst);
5294 ErrPrint("Package[%s] info is not exists\n", pkgname);
5295 ret = LB_STATUS_ERROR_FAULT;
5299 if (package_is_fault(pkg)) {
5302 * If the package is registered as fault module,
5303 * slave has not load it, so we don't need to do anything at here!
5305 DbgPrint("Package[%s] is faulted\n", pkgname);
5306 ret = LB_STATUS_ERROR_FAULT;
5307 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5308 struct buffer_info *buffer;
5309 struct slave_node *slave;
5310 //struct packet *packet;
5312 buffer = instance_lb_buffer(inst);
5314 ErrPrint("Instance[%s] has no buffer\n", id);
5315 ret = LB_STATUS_ERROR_FAULT;
5319 slave = package_slave(pkg);
5321 ErrPrint("Package[%s] has no slave\n", pkgname);
5322 ret = LB_STATUS_ERROR_INVALID;
5327 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
5329 ErrPrint("Failed to create a packet[%s]\n", pkgname);
5330 ret = LB_STATUS_ERROR_FAULT;
5335 packet_ref((struct packet *)packet);
5336 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
5337 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
5338 struct script_info *script;
5341 script = instance_lb_script(inst);
5343 ret = LB_STATUS_ERROR_FAULT;
5347 e = script_handler_evas(script);
5349 ret = LB_STATUS_ERROR_FAULT;
5353 script_handler_update_pointer(script, x, y, -1);
5356 * \TODO: Feed up this KEY_UP event
5360 ErrPrint("Unsupported package\n");
5361 ret = LB_STATUS_ERROR_INVALID;
5365 /*! \note No reply packet */
5369 static int release_pixmap_cb(struct client_node *client, void *canvas)
5371 DbgPrint("Forcely unref the \"buffer\"\n");
5372 buffer_handler_pixmap_unref(canvas);
5373 return -1; /* Delete this callback */
5376 static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5378 struct packet *result;
5379 const char *pkgname;
5381 struct client_node *client;
5382 struct inst_info *inst;
5386 struct buffer_info *buffer;
5388 client = client_find_by_pid(pid);
5390 ErrPrint("Client %d is not exists\n", pid);
5394 ret = packet_get(packet, "ss", &pkgname, &id);
5396 ErrPrint("Parameter is not matched\n");
5402 * Trust the package name which are sent by the client.
5403 * The package has to be a livebox package name.
5405 inst = package_find_instance_by_id(pkgname, id);
5407 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
5411 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
5412 buffer = instance_lb_buffer(inst);
5414 ErrPrint("Unable to get LB buffer: %s\n", id);
5418 buf_ptr = buffer_handler_pixmap_ref(buffer);
5420 ErrPrint("Failed to ref pixmap\n");
5424 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
5426 ErrPrint("Failed to add a new client deactivate callback\n");
5427 buffer_handler_pixmap_unref(buf_ptr);
5429 pixmap = buffer_handler_pixmap(buffer);
5433 result = packet_create_reply(packet, "i", pixmap);
5435 ErrPrint("Failed to create a reply packet\n");
5440 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
5442 const char *pkgname;
5444 struct client_node *client;
5445 struct inst_info *inst;
5450 client = client_find_by_pid(pid);
5452 ErrPrint("Client %d is not exists\n", pid);
5456 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
5458 ErrPrint("Parameter is not matched\n");
5461 DbgPrint("pid[%d] pkgname[%s] id[%s] Pixmap[0x%X]\n", pid, pkgname, id, pixmap);
5465 * Trust the package name which are sent by the client.
5466 * The package has to be a livebox package name.
5468 inst = package_find_instance_by_id(pkgname, id);
5470 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
5474 buf_ptr = buffer_handler_pixmap_find(pixmap);
5476 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
5480 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
5481 buffer_handler_pixmap_unref(buf_ptr);
5484 /*! \note No reply packet */
5488 static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5490 struct packet *result;
5491 const char *pkgname;
5493 struct client_node *client;
5494 struct inst_info *inst;
5498 struct buffer_info *buffer;
5500 client = client_find_by_pid(pid);
5502 ErrPrint("Client %d is not exists\n", pid);
5506 ret = packet_get(packet, "ss", &pkgname, &id);
5508 ErrPrint("Parameter is not matched\n");
5514 * Trust the package name which are sent by the client.
5515 * The package has to be a livebox package name.
5517 inst = package_find_instance_by_id(pkgname, id);
5519 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
5523 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
5524 buffer = instance_pd_buffer(inst);
5526 ErrPrint("Unable to get PD buffer (%s)\n", id);
5530 buf_ptr = buffer_handler_pixmap_ref(buffer);
5532 ErrPrint("Failed to ref pixmap\n");
5536 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
5538 buffer_handler_pixmap_unref(buf_ptr);
5540 pixmap = buffer_handler_pixmap(buffer);
5542 result = packet_create_reply(packet, "i", pixmap);
5544 ErrPrint("Failed to create a reply packet\n");
5549 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
5551 const char *pkgname;
5553 struct client_node *client;
5554 struct inst_info *inst;
5559 client = client_find_by_pid(pid);
5561 ErrPrint("Client %d is not exists\n", pid);
5565 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
5567 ErrPrint("Parameter is not matched\n");
5570 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
5574 * Trust the package name which are sent by the client.
5575 * The package has to be a livebox package name.
5577 inst = package_find_instance_by_id(pkgname, id);
5579 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
5583 buf_ptr = buffer_handler_pixmap_find(pixmap);
5585 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
5589 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
5590 buffer_handler_pixmap_unref(buf_ptr);
5593 /*! \note No reply packet */
5597 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
5599 struct client_node *client;
5600 struct packet *result;
5601 const char *pkgname;
5605 struct inst_info *inst;
5607 client = client_find_by_pid(pid);
5609 ErrPrint("Client %d is not exists\n", pid);
5610 ret = LB_STATUS_ERROR_NOT_EXIST;
5615 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
5617 ErrPrint("Parameter is not matched\n");
5618 ret = LB_STATUS_ERROR_INVALID;
5623 DbgPrint("pid[%d] pkgname[%s] id[%s] pinup[%d]\n", pid, pkgname, id, pinup);
5627 * Trust the package name which are sent by the client.
5628 * The package has to be a livebox package name.
5630 inst = package_find_instance_by_id(pkgname, id);
5632 ret = LB_STATUS_ERROR_NOT_EXIST;
5633 else if (package_is_fault(instance_package(inst)))
5634 ret = LB_STATUS_ERROR_FAULT;
5636 ret = instance_set_pinup(inst, pinup);
5639 result = packet_create_reply(packet, "i", ret);
5641 ErrPrint("Failed to create a packet\n");
5646 static Eina_Bool lazy_pd_created_cb(void *data)
5648 if (instance_unref(data)) {
5650 ret = instance_client_pd_created(data, LB_STATUS_SUCCESS);
5651 DbgPrint("Send PD Create event (%d)\n", ret);
5654 return ECORE_CALLBACK_CANCEL;
5657 static Eina_Bool lazy_pd_destroyed_cb(void *data)
5659 if (instance_unref(data)) {
5660 DbgPrint("Send PD Destroy event\n");
5661 instance_client_pd_destroyed(data, LB_STATUS_SUCCESS);
5664 return ECORE_CALLBACK_CANCEL;
5667 static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
5669 struct client_node *client;
5670 struct inst_info *inst;
5671 const char *pkgname;
5677 client = client_find_by_pid(pid);
5679 ErrPrint("Client %d is not exists\n", pid);
5680 ret = LB_STATUS_ERROR_NOT_EXIST;
5684 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
5686 ErrPrint("Parameter is not correct\n");
5687 ret = LB_STATUS_ERROR_INVALID;
5691 DbgPrint("pid[%d] pkgname[%s] id[%s] %lfx%lf\n", pid, pkgname, id, x, y);
5693 inst = package_find_instance_by_id(pkgname, id);
5695 ret = LB_STATUS_ERROR_NOT_EXIST;
5696 else if (package_is_fault(instance_package(inst)))
5697 ret = LB_STATUS_ERROR_FAULT;
5698 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
5699 instance_slave_set_pd_pos(inst, x, y);
5700 ret = instance_signal_emit(inst,
5701 "pd,move", util_uri_to_path(instance_id(inst)),
5702 0.0, 0.0, 0.0, 0.0, x, y, 0);
5703 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
5707 instance_slave_set_pd_pos(inst, x, y);
5708 ix = x * instance_pd_width(inst);
5709 iy = y * instance_pd_height(inst);
5710 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
5711 ret = instance_signal_emit(inst,
5712 "pd,move", util_uri_to_path(instance_id(inst)),
5713 0.0, 0.0, 0.0, 0.0, x, y, 0);
5715 ErrPrint("Invalid PD type\n");
5716 ret = LB_STATUS_ERROR_INVALID;
5719 DbgPrint("Update PD position: %lfx%lf (%d)\n", x, y, ret);
5723 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
5725 struct client_node *client;
5726 struct packet *result;
5727 const char *pkgname;
5730 struct inst_info *inst;
5734 client = client_find_by_pid(pid);
5736 ErrPrint("Client %d is not exists\n", pid);
5737 ret = LB_STATUS_ERROR_NOT_EXIST;
5741 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
5743 ErrPrint("Parameter is not matched\n");
5744 ret = LB_STATUS_ERROR_INVALID;
5748 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
5752 * Trust the package name which are sent by the client.
5753 * The package has to be a livebox package name.
5755 inst = package_find_instance_by_id(pkgname, id);
5757 ret = LB_STATUS_ERROR_NOT_EXIST;
5758 else if (package_is_fault(instance_package(inst)))
5759 ret = LB_STATUS_ERROR_FAULT;
5760 else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
5761 ret = LB_STATUS_ERROR_NO_SPACE;
5762 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
5763 instance_slave_set_pd_pos(inst, x, y);
5764 ret = instance_slave_open_pd(inst, client);
5765 ret = instance_signal_emit(inst,
5766 "pd,show", util_uri_to_path(instance_id(inst)),
5767 0.0, 0.0, 0.0, 0.0, x, y, 0);
5770 * PD craeted event will be send by the acquire_buffer function.
5771 * Because the slave will make request the acquire_buffer to
5774 * instance_client_pd_created(inst);
5776 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
5781 * ret value should be cared but in this case,
5782 * we ignore this for this moment, so we have to handle this error later.
5784 * if ret is less than 0, the slave has some problem.
5785 * but the script mode doesn't need slave for rendering default view of PD
5786 * so we can hanle it later.
5788 instance_slave_set_pd_pos(inst, x, y);
5789 ix = x * instance_pd_width(inst);
5790 iy = y * instance_pd_height(inst);
5792 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
5794 ret = instance_slave_open_pd(inst, client);
5795 if (ret == LB_STATUS_SUCCESS) {
5796 ret = script_handler_load(instance_pd_script(inst), 1);
5800 * Send the PD created event to the clients,
5802 if (ret == LB_STATUS_SUCCESS) {
5805 * But the created event has to be send afte return
5806 * from this function or the viewer couldn't care
5807 * the event correctly.
5809 inst = instance_ref(inst); /* To guarantee the inst */
5810 if (!ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst)) {
5811 instance_unref(inst);
5812 script_handler_unload(instance_pd_script(inst), 1);
5813 instance_slave_close_pd(inst, client);
5815 ErrPrint("Failed to add delayed timer\n");
5816 ret = LB_STATUS_ERROR_FAULT;
5819 instance_slave_close_pd(inst, client);
5822 ErrPrint("Failed to request open PD to the slave\n");
5825 ErrPrint("Invalid PD TYPE\n");
5826 ret = LB_STATUS_ERROR_INVALID;
5830 result = packet_create_reply(packet, "i", ret);
5832 ErrPrint("Failed to create a packet\n");
5837 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
5839 struct client_node *client;
5840 struct packet *result;
5841 const char *pkgname;
5844 struct inst_info *inst;
5846 client = client_find_by_pid(pid);
5848 ErrPrint("Client %d is not exists\n", pid);
5849 ret = LB_STATUS_ERROR_NOT_EXIST;
5853 ret = packet_get(packet, "ss", &pkgname, &id);
5855 ErrPrint("Parameter is not matched\n");
5856 ret = LB_STATUS_ERROR_INVALID;
5860 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
5864 * Trust the package name which are sent by the client.
5865 * The package has to be a livebox package name.
5867 inst = package_find_instance_by_id(pkgname, id);
5869 ret = LB_STATUS_ERROR_NOT_EXIST;
5870 else if (package_is_fault(instance_package(inst)))
5871 ret = LB_STATUS_ERROR_FAULT;
5872 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
5873 ret = instance_signal_emit(inst,
5874 "pd,hide", util_uri_to_path(instance_id(inst)),
5875 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
5876 ret = instance_slave_close_pd(inst, client);
5880 * release_buffer will be called by the slave after this.
5881 * Then it will send the "pd_destroyed" event to the client
5883 * instance_client_pd_destroyed(inst);
5886 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
5887 ret = script_handler_unload(instance_pd_script(inst), 1);
5888 ret = instance_slave_close_pd(inst, client);
5892 * Send the destroyed PD event to the client
5894 if (ret == LB_STATUS_SUCCESS) {
5895 inst = instance_ref(inst);
5896 if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst)) {
5897 instance_unref(inst);
5899 * How can we handle this?
5901 ret = LB_STATUS_ERROR_FAULT;
5905 ErrPrint("Invalid PD TYPE\n");
5906 ret = LB_STATUS_ERROR_INVALID;
5910 result = packet_create_reply(packet, "i", ret);
5912 ErrPrint("Failed to create a packet\n");
5917 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
5919 struct client_node *client;
5920 struct packet *result;
5921 const char *pkgname;
5923 struct pkg_info *info;
5925 client = client_find_by_pid(pid);
5927 ErrPrint("Client %d is not exists\n", pid);
5928 ret = LB_STATUS_ERROR_NOT_EXIST;
5933 ret = packet_get(packet, "s", &pkgname);
5935 ErrPrint("Parameter is not matched\n");
5936 ret = LB_STATUS_ERROR_INVALID;
5941 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
5945 * Validate the livebox package name.
5947 if (!package_is_lb_pkgname(pkgname)) {
5948 ErrPrint("%s is not a valid livebox package\n", pkgname);
5950 ret = LB_STATUS_ERROR_INVALID;
5954 info = package_find(pkgname);
5956 ret = LB_STATUS_ERROR_NOT_EXIST;
5958 ret = package_clear_fault(info);
5961 result = packet_create_reply(packet, "is", ret, pkgname);
5963 ErrPrint("Failed to create a packet\n");
5968 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
5970 const char *cluster;
5971 const char *category;
5972 struct client_node *client;
5975 client = client_find_by_pid(pid);
5977 ErrPrint("Client %d is not exists\n", pid);
5978 ret = LB_STATUS_ERROR_NOT_EXIST;
5982 ret = packet_get(packet, "ss", &cluster, &category);
5984 ErrPrint("Invalid argument\n");
5985 ret = LB_STATUS_ERROR_INVALID;
5989 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5990 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5991 ErrPrint("Invalid cluster name\n");
5997 * SUBSCRIBE cluster & sub-cluster for a client.
5999 ret = client_subscribe(client, cluster, category);
6001 package_alter_instances_to_client(client, ALTER_CREATE);
6004 /*! \note No reply packet */
6008 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
6010 const char *cluster;
6011 struct client_node *client;
6012 struct packet *result;
6015 client = client_find_by_pid(pid);
6017 ErrPrint("Client %d is not exists\n", pid);
6018 ret = LB_STATUS_ERROR_NOT_EXIST;
6022 ret = packet_get(packet, "s", &cluster);
6024 ErrPrint("Invalid parameters\n");
6025 ret = LB_STATUS_ERROR_INVALID;
6029 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
6031 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
6032 ErrPrint("Invalid cluster: %s\n", cluster);
6033 ret = LB_STATUS_ERROR_INVALID;
6040 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
6043 result = packet_create_reply(packet, "i", ret);
6045 ErrPrint("Failed to create a packet\n");
6049 static inline int update_pkg_cb(struct category *category, const char *pkgname)
6054 c_name = group_cluster_name_by_category(category);
6055 s_name = group_category_name(category);
6057 if (!c_name || !s_name || !pkgname) {
6058 ErrPrint("Name is not valid\n");
6059 return EXIT_FAILURE;
6062 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
6063 slave_rpc_request_update(pkgname, "", c_name, s_name);
6065 /* Just try to create a new package */
6066 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
6068 struct inst_info *inst;
6070 timestamp = util_timestamp();
6073 * Don't need to check the subscribed clients.
6074 * Because this callback is called by the requests of clients.
6075 * It means. some clients wants to handle this instances ;)
6077 inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DEFAULT_PERIOD, 0, 0);
6079 ErrPrint("Failed to create a new instance\n");
6081 ErrPrint("Not enough space\n");
6083 return EXIT_SUCCESS;
6086 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
6088 struct inst_info *inst;
6089 struct client_node *client;
6090 const char *pkgname;
6094 client = client_find_by_pid(pid);
6096 ErrPrint("Cilent %d is not exists\n", pid);
6100 ret = packet_get(packet, "ss", &pkgname, &id);
6102 ErrPrint("Invalid argument\n");
6106 inst = package_find_instance_by_id(pkgname, id);
6108 } else if (package_is_fault(instance_package(inst))) {
6109 } else if (instance_client(inst) != client) {
6111 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
6115 /*! \note No reply packet */
6119 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
6121 const char *cluster_id;
6122 const char *category_id;
6123 struct client_node *client;
6125 struct cluster *cluster;
6126 struct category *category;
6127 struct context_info *info;
6128 Eina_List *info_list;
6131 client = client_find_by_pid(pid);
6133 ErrPrint("Cilent %d is not exists\n", pid);
6137 ret = packet_get(packet, "ss", &cluster_id, &category_id);
6139 ErrPrint("Invalid parameter\n");
6143 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
6145 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
6146 ErrPrint("Invalid cluster name: %s\n", cluster_id);
6150 cluster = group_find_cluster(cluster_id);
6152 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
6156 category = group_find_category(cluster, category_id);
6158 ErrPrint("Category [%s] is not registered\n", category_id);
6162 info_list = group_context_info_list(category);
6163 EINA_LIST_FOREACH(info_list, l, info) {
6164 update_pkg_cb(category, group_pkgname_from_context_info(info));
6168 /*! \note No reply packet */
6172 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
6174 const char *cluster;
6175 const char *category;
6176 struct client_node *client;
6177 struct packet *result;
6180 client = client_find_by_pid(pid);
6182 ErrPrint("Client %d is not exists\n", pid);
6183 ret = LB_STATUS_ERROR_NOT_EXIST;
6187 ret = packet_get(packet, "ss", &cluster, &category);
6189 ErrPrint("Invalid paramenters\n");
6190 ret = LB_STATUS_ERROR_INVALID;
6194 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
6195 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
6196 ErrPrint("Invalid cluster: %s\n", cluster);
6197 ret = LB_STATUS_ERROR_INVALID;
6204 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
6207 result = packet_create_reply(packet, "i", ret);
6209 ErrPrint("Failed to create a packet\n");
6213 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
6215 const char *cluster;
6216 const char *category;
6217 struct client_node *client;
6220 client = client_find_by_pid(pid);
6222 ErrPrint("Client %d is not exists\n", pid);
6223 ret = LB_STATUS_ERROR_NOT_EXIST;
6227 ret = packet_get(packet, "ss", &cluster, &category);
6229 ErrPrint("Invalid argument\n");
6230 ret = LB_STATUS_ERROR_INVALID;
6234 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
6236 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
6237 ErrPrint("Invalid cluster name: %s\n", cluster);
6243 * UNSUBSCRIBE cluster & sub-cluster for a client.
6245 ret = client_unsubscribe(client, cluster, category);
6247 package_alter_instances_to_client(client, ALTER_DESTROY);
6250 /*! \note No reply packet */
6254 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
6256 struct slave_node *slave;
6257 const char *slavename;
6260 ret = packet_get(packet, "s", &slavename);
6262 ErrPrint("Parameter is not matched\n");
6266 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
6268 slave = slave_find_by_pid(pid);
6271 char pkgname[pathconf("/", _PC_PATH_MAX)];
6274 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
6275 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
6276 slave = slave_find_by_name(slavename);
6277 pkgname[0] = '\0'; /* Reset the pkgname */
6279 slave = slave_find_by_pkgname(pkgname);
6283 abi = abi_find_by_pkgname(pkgname);
6286 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
6289 slave = slave_create(slavename, 1, abi, pkgname, 0);
6291 ErrPrint("Failed to create a new slave for %s\n", slavename);
6295 DbgPrint("New slave is created (net: 0)\n");
6297 DbgPrint("Registered slave is replaced with this new one\n");
6298 abi = slave_abi(slave);
6301 slave_set_pid(slave, pid);
6302 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
6304 ErrPrint("Slave[%d] is not exists\n", pid);
6311 * After updating handle,
6312 * slave activated callback will be called.
6314 slave_rpc_update_handle(slave, handle);
6320 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
6322 struct slave_node *slave;
6323 const char *slavename;
6326 slave = slave_find_by_pid(pid);
6328 ErrPrint("Slave %d is not exists\n", pid);
6332 ret = packet_get(packet, "s", &slavename);
6334 ErrPrint("Parameter is not matched\n");
6336 slave_rpc_ping(slave);
6342 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
6344 struct slave_node *slave;
6345 struct inst_info *inst;
6346 const char *pkgname;
6351 slave = slave_find_by_pid(pid);
6353 ErrPrint("Slave %d is not exists\n", pid);
6357 ret = packet_get(packet, "sss", &pkgname, &id, &func);
6359 ErrPrint("Parameter is not matched\n");
6363 ret = fault_info_set(slave, pkgname, id, func);
6364 DbgPrint("Slave Faulted: %s (%d)\n", slave_name(slave), ret);
6366 inst = package_find_instance_by_id(pkgname, id);
6368 DbgPrint("There is a no such instance(%s)\n", id);
6369 } else if (instance_state(inst) == INST_DESTROYED) {
6370 ErrPrint("Instance(%s) is already destroyed\n", id);
6372 ret = instance_destroy(inst);
6373 DbgPrint("Destroy instance(%s) %d\n", id, ret);
6380 static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
6382 struct slave_node *slave;
6383 struct inst_info *inst;
6384 struct pkg_info *pkg;
6385 const char *pkgname;
6388 const char *content;
6392 slave = slave_find_by_pid(pid);
6394 ErrPrint("Slave %d is not exists\n", pid);
6398 ret = packet_get(packet, "ssdss", &pkgname, &id, &priority, &content, &title);
6400 ErrPrint("Invalid parameters\n");
6404 inst = package_find_instance_by_id(pkgname, id);
6406 ErrPrint("Instance(%s) is not exists\n", id);
6408 } else if (instance_state(inst) == INST_DESTROYED) {
6409 ErrPrint("Instance(%s) is already destroyed\n", id);
6413 pkg = instance_package(inst);
6415 ErrPrint("Invalid instance\n");
6416 } else if (package_is_fault(pkg)) {
6417 ErrPrint("Faulted instance %s.\n", id);
6418 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
6419 ret = instance_lb_update_begin(inst, priority, content, title);
6420 if (ret == LB_STATUS_SUCCESS)
6421 slave_freeze_ttl(slave);
6423 ErrPrint("Invalid request[%s]\n", id);
6430 static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct packet *packet)
6432 struct slave_node *slave;
6433 struct inst_info *inst;
6434 struct pkg_info *pkg;
6435 const char *pkgname;
6439 slave = slave_find_by_pid(pid);
6441 ErrPrint("Slave %d is not exists\n", pid);
6445 ret = packet_get(packet, "ss", &pkgname, &id);
6447 ErrPrint("Invalid parameters\n");
6451 inst = package_find_instance_by_id(pkgname, id);
6453 ErrPrint("Instance[%s] is not exists\n", id);
6455 } else if (instance_state(inst) == INST_DESTROYED) {
6456 ErrPrint("Instance[%s] is already destroyed\n", id);
6460 pkg = instance_package(inst);
6462 ErrPrint("Invalid instance\n");
6463 } else if (package_is_fault(pkg)) {
6464 ErrPrint("Faulted instance %s\n", id);
6465 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
6466 ret = instance_lb_update_end(inst);
6467 if (ret == LB_STATUS_SUCCESS)
6468 slave_thaw_ttl(slave);
6470 ErrPrint("Invalid request[%s]\n", id);
6477 static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
6479 struct slave_node *slave;
6480 struct pkg_info *pkg;
6481 struct inst_info *inst;
6482 const char *pkgname;
6486 slave = slave_find_by_pid(pid);
6488 ErrPrint("Slave %d is not exists\n", pid);
6492 ret = packet_get(packet, "ss", &pkgname, &id);
6494 ErrPrint("Invalid parameters\n");
6498 inst = package_find_instance_by_id(pkgname, id);
6500 ErrPrint("Instance[%s] is not exists\n", id);
6504 pkg = instance_package(inst);
6506 ErrPrint("Invalid package\n");
6507 } else if (package_is_fault(pkg)) {
6508 ErrPrint("Faulted instance %s\n", id);
6509 } else if (instance_state(inst) == INST_DESTROYED) {
6510 ErrPrint("Instance[%s] is already destroyed\n", id);
6511 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
6512 (void)instance_pd_update_begin(inst);
6514 ErrPrint("Invalid request[%s]\n", id);
6521 static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
6523 struct slave_node *slave;
6524 struct pkg_info *pkg;
6525 struct inst_info *inst;
6526 const char *pkgname;
6531 slave = slave_find_by_pid(pid);
6533 ErrPrint("Slave %d is not exists\n", pid);
6537 ret = packet_get(packet, "ssi", &pkgname, &id, &status);
6539 ErrPrint("Invalid parameters\n");
6543 inst = package_find_instance_by_id(pkgname, id);
6545 ErrPrint("Instance[%s] is not exists\n", id);
6549 pkg = instance_package(inst);
6551 ErrPrint("Invalid package\n");
6552 } else if (package_is_fault(pkg)) {
6553 ErrPrint("Faulted instance %s\n", id);
6554 } else if (instance_state(inst) == INST_DESTROYED) {
6555 ErrPrint("Instance[%s] is already destroyed\n", id);
6559 * Forward packet to client
6561 (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
6568 static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
6570 struct slave_node *slave;
6571 struct pkg_info *pkg;
6572 struct inst_info *inst;
6573 const char *pkgname;
6577 slave = slave_find_by_pid(pid);
6579 ErrPrint("Slave %d is not exists\n", pid);
6583 ret = packet_get(packet, "ss", &pkgname, &id);
6585 ErrPrint("Invalid parameters\n");
6589 inst = package_find_instance_by_id(pkgname, id);
6591 ErrPrint("Instance[%s] is not exists\n", id);
6595 pkg = instance_package(inst);
6597 ErrPrint("Invalid package\n");
6598 } else if (package_is_fault(pkg)) {
6599 ErrPrint("Faulted instance %s\n", id);
6600 } else if (instance_state(inst) == INST_DESTROYED) {
6601 ErrPrint("Instance[%s] is already destroyed\n", id);
6602 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
6603 (void)instance_pd_update_end(inst);
6605 ErrPrint("Invalid request[%s]\n", id);
6612 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
6614 struct slave_node *slave;
6615 const char *pkgname;
6620 slave = slave_find_by_pid(pid);
6622 ErrPrint("Slave %d is not exists\n", pid);
6626 ret = packet_get(packet, "sss", &pkgname, &id, &func);
6628 ErrPrint("Parameter is not matched\n");
6632 ret = fault_func_call(slave, pkgname, id, func);
6633 slave_give_more_ttl(slave);
6639 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
6641 struct slave_node *slave;
6642 const char *pkgname;
6647 slave = slave_find_by_pid(pid);
6649 ErrPrint("Slave %d is not exists\n", pid);
6653 ret = packet_get(packet, "sss", &pkgname, &id, &func);
6655 ErrPrint("Parameter is not matched\n");
6659 ret = fault_func_ret(slave, pkgname, id, func);
6660 slave_give_more_ttl(slave);
6666 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
6668 struct slave_node *slave;
6669 const char *pkgname;
6671 const char *content_info;
6677 struct inst_info *inst;
6679 slave = slave_find_by_pid(pid);
6681 ErrPrint("Slave %d is not exists\n", pid);
6685 ret = packet_get(packet, "ssiidss", &pkgname, &id,
6687 &content_info, &title);
6689 ErrPrint("Parameter is not matched\n");
6693 inst = package_find_instance_by_id(pkgname, id);
6695 } else if (package_is_fault(instance_package(inst))) {
6696 ErrPrint("Faulted instance cannot make any event.\n");
6697 } else if (instance_state(inst) == INST_DESTROYED) {
6698 ErrPrint("Instance is already destroyed\n");
6702 instance_set_lb_info(inst, priority, content_info, title);
6704 switch (package_lb_type(instance_package(inst))) {
6705 case LB_TYPE_SCRIPT:
6706 script_handler_resize(instance_lb_script(inst), w, h);
6707 filename = util_get_file_kept_in_safe(id);
6709 (void)script_handler_parse_desc(pkgname, id,
6713 (void)script_handler_parse_desc(pkgname, id,
6714 util_uri_to_path(id), 0);
6717 case LB_TYPE_BUFFER:
6721 * text format (inst)
6723 instance_set_lb_size(inst, w, h);
6724 instance_lb_updated_by_instance(inst);
6728 slave_give_more_ttl(slave);
6735 static struct packet *slave_hold_scroll(pid_t pid, int handle, const struct packet *packet)
6737 struct slave_node *slave;
6738 struct inst_info *inst;
6739 const char *pkgname;
6744 slave = slave_find_by_pid(pid);
6746 ErrPrint("Slave %d is not exists\n", pid);
6750 ret = packet_get(packet, "ssi", &pkgname, &id, &seize);
6752 ErrPrint("Parameter is not matched\n");
6756 inst = package_find_instance_by_id(pkgname, id);
6758 ErrPrint("No such instance(%s)\n", id);
6759 } else if (package_is_fault(instance_package(inst))) {
6760 ErrPrint("Faulted instance cannot seize the screen\n");
6761 } else if (instance_state(inst) == INST_DESTROYED) {
6762 ErrPrint("Instance(%s) is already destroyed\n", id);
6764 (void)instance_hold_scroll(inst, seize);
6771 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
6773 struct slave_node *slave;
6774 const char *pkgname;
6776 const char *descfile;
6778 struct inst_info *inst;
6780 slave = slave_find_by_pid(pid);
6782 ErrPrint("Slave %d is not exists\n", pid);
6786 ret = packet_get(packet, "sss", &pkgname, &id, &descfile);
6788 ErrPrint("Parameter is not matched\n");
6792 inst = package_find_instance_by_id(pkgname, id);
6794 } else if (package_is_fault(instance_package(inst))) {
6795 ErrPrint("Faulted package cannot make event\n");
6796 } else if (instance_state(inst) == INST_DESTROYED) {
6797 ErrPrint("Instance is already destroyed\n");
6799 switch (package_pd_type(instance_package(inst))) {
6800 case PD_TYPE_SCRIPT:
6801 DbgPrint("Script (%s)\n", id);
6802 if (script_handler_is_loaded(instance_pd_script(inst))) {
6803 (void)script_handler_parse_desc(pkgname, id,
6808 instance_set_pd_size(inst, 0, 0);
6809 case PD_TYPE_BUFFER:
6810 instance_pd_updated(pkgname, id, descfile);
6813 DbgPrint("Ignore updated DESC(%s - %s - %s)\n",
6814 pkgname, id, descfile);
6823 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
6825 struct slave_node *slave;
6826 const char *pkgname;
6829 struct inst_info *inst;
6831 slave = slave_find_by_pid(pid);
6833 ErrPrint("Slave %d is not exists\n", pid);
6837 ret = packet_get(packet, "ss", &pkgname, &id);
6839 ErrPrint("Parameter is not matched\n");
6843 inst = package_find_instance_by_id(pkgname, id);
6845 } else if (package_is_fault(instance_package(inst))) {
6847 ret = instance_destroyed(inst);
6848 DbgPrint("Destroy instance %d\n", ret);
6856 * \note for the BUFFER Type slave
6858 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
6860 enum target_type target;
6861 const char *pkgname;
6866 struct packet *result;
6867 struct slave_node *slave;
6868 struct inst_info *inst;
6869 const struct pkg_info *pkg;
6872 slave = slave_find_by_pid(pid);
6874 ErrPrint("Failed to find a slave\n");
6876 ret = LB_STATUS_ERROR_NOT_EXIST;
6880 ret = packet_get(packet, "issiii", &target, &pkgname, &id, &w, &h, &pixel_size);
6882 ErrPrint("Invalid argument\n");
6884 ret = LB_STATUS_ERROR_INVALID;
6888 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
6889 DbgPrint("No space\n");
6890 ret = LB_STATUS_ERROR_NO_SPACE;
6896 inst = package_find_instance_by_id(pkgname, id);
6898 DbgPrint("Package[%s] Id[%s] is not found\n", pkgname, id);
6899 ret = LB_STATUS_ERROR_INVALID;
6904 pkg = instance_package(inst);
6906 ret = LB_STATUS_ERROR_INVALID;
6907 if (target == TYPE_LB) {
6908 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
6909 struct buffer_info *info;
6911 info = instance_lb_buffer(inst);
6913 if (!instance_create_lb_buffer(inst)) {
6914 ErrPrint("Failed to create a LB buffer\n");
6916 info = instance_lb_buffer(inst);
6918 ErrPrint("LB buffer is not valid\n");
6919 ret = LB_STATUS_ERROR_INVALID;
6926 ret = buffer_handler_resize(info, w, h);
6927 DbgPrint("Buffer resize returns %d\n", ret);
6929 ret = buffer_handler_load(info);
6931 instance_set_lb_size(inst, w, h);
6932 instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
6933 id = buffer_handler_id(info);
6934 DbgPrint("Buffer handler ID: %s\n", id);
6936 DbgPrint("Failed to load a buffer(%d)\n", ret);
6939 } else if (target == TYPE_PD) {
6940 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
6941 struct buffer_info *info;
6943 DbgPrint("Slave acquire buffer for PD\n");
6945 info = instance_pd_buffer(inst);
6947 if (!instance_create_pd_buffer(inst)) {
6948 ErrPrint("Failed to create a PD buffer\n");
6950 info = instance_pd_buffer(inst);
6952 ErrPrint("PD buffer is not valid\n");
6953 ret = LB_STATUS_ERROR_INVALID;
6955 instance_client_pd_created(inst, ret);
6961 ret = buffer_handler_resize(info, w, h);
6962 DbgPrint("Buffer resize returns %d\n", ret);
6964 ret = buffer_handler_load(info);
6966 instance_set_pd_size(inst, w, h);
6967 id = buffer_handler_id(info);
6968 DbgPrint("Buffer handler ID: %s\n", id);
6970 DbgPrint("Failed to load a buffer (%d)\n", ret);
6974 * Send the PD created event to the client
6976 instance_client_pd_created(inst, ret);
6981 result = packet_create_reply(packet, "is", ret, id);
6983 ErrPrint("Failed to create a packet\n");
6988 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
6990 struct slave_node *slave;
6991 struct packet *result;
6992 enum target_type type;
6993 const char *pkgname;
6997 struct inst_info *inst;
6998 const struct pkg_info *pkg;
7001 slave = slave_find_by_pid(pid);
7003 ErrPrint("Failed to find a slave\n");
7004 ret = LB_STATUS_ERROR_NOT_EXIST;
7009 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
7010 ErrPrint("Not enough space\n");
7011 ret = LB_STATUS_ERROR_NO_SPACE;
7016 ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
7018 ErrPrint("Invalid argument\n");
7019 ret = LB_STATUS_ERROR_INVALID;
7024 inst = package_find_instance_by_id(pkgname, id);
7026 DbgPrint("Instance is not found[%s] [%s]\n", pkgname, id);
7027 ret = LB_STATUS_ERROR_NOT_EXIST;
7032 pkg = instance_package(inst);
7036 * THIS statement should not be entered.
7038 ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
7039 ret = LB_STATUS_ERROR_FAULT;
7044 ret = LB_STATUS_ERROR_INVALID;
7047 * Reset "id", It will be re-used from here
7050 if (type == TYPE_LB) {
7051 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
7052 struct buffer_info *info;
7054 info = instance_lb_buffer(inst);
7056 ret = buffer_handler_resize(info, w, h);
7059 * id is resued for newly assigned ID
7062 id = buffer_handler_id(info);
7063 instance_set_lb_size(inst, w, h);
7064 instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
7068 } else if (type == TYPE_PD) {
7069 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
7070 struct buffer_info *info;
7072 info = instance_pd_buffer(inst);
7074 ret = buffer_handler_resize(info, w, h);
7077 * id is resued for newly assigned ID
7080 id = buffer_handler_id(info);
7081 instance_set_pd_size(inst, w, h);
7088 result = packet_create_reply(packet, "is", ret, id);
7090 ErrPrint("Failed to create a packet\n");
7095 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
7097 enum target_type type;
7098 const char *pkgname;
7100 struct packet *result;
7101 struct slave_node *slave;
7102 struct inst_info *inst;
7105 slave = slave_find_by_pid(pid);
7107 ErrPrint("Failed to find a slave\n");
7108 ret = LB_STATUS_ERROR_NOT_EXIST;
7112 if (packet_get(packet, "iss", &type, &pkgname, &id) != 3) {
7113 ErrPrint("Inavlid argument\n");
7114 ret = LB_STATUS_ERROR_INVALID;
7118 inst = package_find_instance_by_id(pkgname, id);
7120 ErrPrint("Instance is not found [%s - %s]\n", pkgname, id);
7121 ret = LB_STATUS_ERROR_NOT_EXIST;
7125 ret = LB_STATUS_ERROR_INVALID;
7126 if (type == TYPE_LB) {
7127 struct buffer_info *info;
7129 info = instance_lb_buffer(inst);
7130 ret = buffer_handler_unload(info);
7131 } else if (type == TYPE_PD) {
7132 struct buffer_info *info;
7134 DbgPrint("Slave release buffer for PD\n");
7136 info = instance_pd_buffer(inst);
7137 ret = buffer_handler_unload(info);
7141 * Send the PD destroyed event to the client
7143 instance_client_pd_destroyed(inst, ret);
7147 result = packet_create_reply(packet, "i", ret);
7149 ErrPrint("Failed to create a packet\n");
7154 static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
7156 struct inst_info *inst;
7157 struct packet *result;
7158 const char *pkgname;
7163 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
7165 ErrPrint("Invalid packet\n");
7166 ret = LB_STATUS_ERROR_INVALID;
7171 struct pkg_info *pkg;
7173 pkg = package_find(pkgname);
7175 ret = LB_STATUS_ERROR_NOT_EXIST;
7176 } else if (package_is_fault(pkg)) {
7177 ret = LB_STATUS_ERROR_FAULT;
7179 Eina_List *inst_list;
7182 inst_list = package_instance_list(pkg);
7183 EINA_LIST_FOREACH(inst_list, l, inst) {
7184 ret = instance_set_period(inst, period);
7186 DbgPrint("Failed to change the period of %s to (%lf)\n", instance_id(inst), period);
7190 inst = package_find_instance_by_id(pkgname, id);
7192 ret = LB_STATUS_ERROR_NOT_EXIST;
7193 else if (package_is_fault(instance_package(inst)))
7194 ret = LB_STATUS_ERROR_FAULT;
7196 ret = instance_set_period(inst, period);
7199 DbgPrint("Change the update period: %s(%s), %lf : %d\n", pkgname, id, period, ret);
7201 result = packet_create_reply(packet, "i", ret);
7203 ErrPrint("Failed to create a packet\n");
7208 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
7210 struct pkg_info *pkg;
7211 struct packet *result;
7212 const char *pkgname;
7214 const char *cluster;
7215 const char *category;
7219 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
7221 ErrPrint("Invalid Packet\n");
7222 ret = LB_STATUS_ERROR_INVALID;
7226 lb_pkgname = package_lb_pkgname(pkgname);
7228 ErrPrint("Invalid package %s\n", pkgname);
7229 ret = LB_STATUS_ERROR_INVALID;
7233 pkg = package_find(lb_pkgname);
7235 ret = LB_STATUS_ERROR_NOT_EXIST;
7236 DbgFree(lb_pkgname);
7240 if (package_is_fault(pkg)) {
7241 ret = LB_STATUS_ERROR_FAULT;
7242 DbgFree(lb_pkgname);
7248 * Validate the update requstor.
7250 slave_rpc_request_update(lb_pkgname, id, cluster, category);
7251 DbgFree(lb_pkgname);
7252 ret = LB_STATUS_SUCCESS;
7255 result = packet_create_reply(packet, "i", ret);
7257 ErrPrint("Failed to create a packet\n");
7262 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
7264 struct liveinfo *info;
7265 struct packet *result;
7267 const char *fifo_name;
7270 DbgPrint("Request arrived from %d\n", pid);
7272 if (packet_get(packet, "d", ×tamp) != 1) {
7273 ErrPrint("Invalid packet\n");
7275 ret = LB_STATUS_ERROR_INVALID;
7279 info = liveinfo_create(pid, handle);
7281 ErrPrint("Failed to create a liveinfo object\n");
7283 ret = LB_STATUS_ERROR_INVALID;
7288 fifo_name = liveinfo_filename(info);
7289 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
7292 result = packet_create_reply(packet, "si", fifo_name, ret);
7294 ErrPrint("Failed to create a result packet\n");
7299 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
7303 struct liveinfo *info;
7304 struct slave_node *slave;
7308 if (packet_get(packet, "d", ×tamp) != 1) {
7309 ErrPrint("Invalid argument\n");
7313 info = liveinfo_find_by_pid(pid);
7315 ErrPrint("Invalid request\n");
7319 liveinfo_open_fifo(info);
7320 fp = liveinfo_fifo(info);
7322 liveinfo_close_fifo(info);
7326 list = (Eina_List *)slave_list();
7327 EINA_LIST_FOREACH(list, l, slave) {
7328 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
7331 slave_pkgname(slave),
7333 slave_is_secured(slave),
7334 slave_refcnt(slave),
7335 slave_fault_count(slave),
7336 slave_state_string(slave),
7337 slave_loaded_instance(slave),
7338 slave_loaded_package(slave),
7343 fprintf(fp, "EOD\n");
7344 liveinfo_close_fifo(info);
7349 static inline const char *visible_state_string(enum livebox_visible_state state)
7356 case LB_HIDE_WITH_PAUSE:
7365 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
7367 const char *pkgname;
7368 struct liveinfo *info;
7369 struct pkg_info *pkg;
7371 Eina_List *inst_list;
7372 struct inst_info *inst;
7375 if (packet_get(packet, "s", &pkgname) != 1) {
7376 ErrPrint("Invalid argument\n");
7380 info = liveinfo_find_by_pid(pid);
7382 ErrPrint("Invalid request\n");
7386 liveinfo_open_fifo(info);
7387 fp = liveinfo_fifo(info);
7389 ErrPrint("Invalid fp\n");
7390 liveinfo_close_fifo(info);
7394 if (!package_is_lb_pkgname(pkgname)) {
7395 ErrPrint("Invalid package name\n");
7399 pkg = package_find(pkgname);
7401 ErrPrint("Package is not exists\n");
7405 inst_list = package_instance_list(pkg);
7406 EINA_LIST_FOREACH(inst_list, l, inst) {
7407 fprintf(fp, "%s %s %s %lf %s %d %d\n",
7409 instance_cluster(inst),
7410 instance_category(inst),
7411 instance_period(inst),
7412 visible_state_string(instance_visible_state(inst)),
7413 instance_lb_width(inst),
7414 instance_lb_height(inst));
7418 fprintf(fp, "EOD\n");
7419 liveinfo_close_fifo(info);
7425 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
7429 Eina_List *inst_list;
7430 struct liveinfo *info;
7431 struct pkg_info *pkg;
7432 struct slave_node *slave;
7434 const char *slavename;
7437 if (packet_get(packet, "d", ×tamp) != 1) {
7438 ErrPrint("Invalid argument\n");
7442 info = liveinfo_find_by_pid(pid);
7444 ErrPrint("Invalid request\n");
7448 liveinfo_open_fifo(info);
7449 fp = liveinfo_fifo(info);
7451 liveinfo_close_fifo(info);
7455 list = (Eina_List *)package_list();
7456 EINA_LIST_FOREACH(list, l, pkg) {
7457 slave = package_slave(pkg);
7460 slavename = slave_name(slave);
7461 pid = slave_pid(slave);
7467 inst_list = (Eina_List *)package_instance_list(pkg);
7468 fprintf(fp, "%d %s %s %s %d %d %d\n",
7470 strlen(slavename) ? slavename : "(none)",
7473 package_refcnt(pkg),
7474 package_fault_count(pkg),
7475 eina_list_count(inst_list)
7479 fprintf(fp, "EOD\n");
7480 liveinfo_close_fifo(info);
7485 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
7490 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
7492 struct liveinfo *info;
7498 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
7499 ErrPrint("Invalid argument\n");
7503 info = liveinfo_find_by_pid(pid);
7505 ErrPrint("Invalid request\n");
7509 liveinfo_open_fifo(info);
7510 fp = liveinfo_fifo(info);
7512 liveinfo_close_fifo(info);
7516 if (!strcmp(cmd, "rmpack")) {
7517 fprintf(fp, "%d\n", ENOSYS);
7518 } else if (!strcmp(cmd, "rminst")) {
7519 struct inst_info *inst;
7520 inst = package_find_instance_by_id(pkgname, id);
7522 fprintf(fp, "%d\n", ENOENT);
7524 instance_destroy(inst);
7525 fprintf(fp, "%d\n", 0);
7529 fprintf(fp, "EOD\n");
7530 liveinfo_close_fifo(info);
7536 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
7538 struct liveinfo *info;
7543 int ret = LB_STATUS_ERROR_INVALID;
7545 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
7546 ErrPrint("Invalid argument\n");
7550 info = liveinfo_find_by_pid(pid);
7552 ErrPrint("Invalid request\n");
7556 if (!strcasecmp(var, "debug")) {
7557 if (!strcasecmp(cmd, "set")) {
7558 g_conf.debug_mode = !strcasecmp(val, "on");
7559 } else if (!strcasecmp(cmd, "get")) {
7561 ret = g_conf.debug_mode;
7562 } else if (!strcasecmp(var, "slave_max_load")) {
7563 if (!strcasecmp(cmd, "set")) {
7564 g_conf.slave_max_load = atoi(val);
7565 } else if (!strcasecmp(cmd, "get")) {
7567 ret = g_conf.slave_max_load;
7570 liveinfo_open_fifo(info);
7571 fp = liveinfo_fifo(info);
7573 liveinfo_close_fifo(info);
7576 fprintf(fp, "%d\nEOD\n", ret);
7577 liveinfo_close_fifo(info);
7583 static struct method s_info_table[] = {
7585 .cmd = "liveinfo_hello",
7586 .handler = liveinfo_hello,
7589 .cmd = "slave_list",
7590 .handler = liveinfo_slave_list,
7594 .handler = liveinfo_pkg_list,
7598 .handler = liveinfo_inst_list,
7601 .cmd = "slave_ctrl",
7602 .handler = liveinfo_slave_ctrl,
7606 .handler = liveinfo_pkg_ctrl,
7609 .cmd = "master_ctrl",
7610 .handler = liveinfo_master_ctrl,
7618 static struct method s_client_table[] = {
7620 .cmd = "pd_mouse_move",
7621 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
7624 .cmd = "lb_mouse_move",
7625 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
7628 .cmd = "pd_mouse_down",
7629 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
7632 .cmd = "pd_mouse_up",
7633 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
7636 .cmd = "lb_mouse_down",
7637 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
7640 .cmd = "lb_mouse_up",
7641 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
7644 .cmd = "pd_mouse_enter",
7645 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
7648 .cmd = "pd_mouse_leave",
7649 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
7652 .cmd = "lb_mouse_enter",
7653 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
7656 .cmd = "lb_mouse_leave",
7657 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
7660 .cmd = "lb_mouse_set",
7661 .handler = client_lb_mouse_set,
7664 .cmd = "lb_mouse_unset",
7665 .handler = client_lb_mouse_unset,
7668 .cmd = "pd_mouse_set",
7669 .handler = client_pd_mouse_set,
7672 .cmd = "pd_mouse_unset",
7673 .handler = client_pd_mouse_unset,
7676 .cmd = "change,visibility",
7677 .handler = client_change_visibility,
7680 .cmd = "lb_acquire_pixmap",
7681 .handler = client_lb_acquire_pixmap,
7684 .cmd = "lb_release_pixmap",
7685 .handler = client_lb_release_pixmap,
7688 .cmd = "pd_acquire_pixmap",
7689 .handler = client_pd_acquire_pixmap,
7692 .cmd = "pd_release_pixmap",
7693 .handler = client_pd_release_pixmap,
7697 .handler = client_acquire, /*!< pid, ret */
7701 .handler = cilent_release, /*!< pid, ret */
7705 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
7708 .cmd = "text_signal",
7709 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
7713 .handler = client_delete, /* pid, pkgname, filename, ret */
7717 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
7721 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
7724 .cmd = "set_period",
7725 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
7728 .cmd = "change_group",
7729 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
7732 .cmd = "pinup_changed",
7733 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
7737 .handler = client_create_pd, /* pid, pkgname, filename, ret */
7741 .handler = client_pd_move, /* pkgname, id, x, y */
7744 .cmd = "destroy_pd",
7745 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
7748 .cmd = "activate_package",
7749 .handler = client_activate_package, /* pid, pkgname, ret */
7752 .cmd = "subscribe", /* pid, cluster, sub-cluster */
7753 .handler = client_subscribed,
7756 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
7757 .handler = client_unsubscribed,
7760 .cmd = "delete_cluster",
7761 .handler = client_delete_cluster,
7764 .cmd = "delete_category",
7765 .handler = client_delete_category,
7768 .cmd = "refresh_group",
7769 .handler = client_refresh_group,
7773 .handler = client_update,
7777 .cmd = "pd_access_hl",
7778 .handler = client_pd_access_hl,
7781 .cmd = "pd_access_hl_prev",
7782 .handler = client_pd_access_hl_prev,
7785 .cmd = "pd_access_hl_next",
7786 .handler = client_pd_access_hl_next,
7789 .cmd = "pd_access_activate",
7790 .handler = client_pd_access_activate,
7793 .cmd = "pd_access_action_up",
7794 .handler = client_pd_access_action_up,
7797 .cmd = "pd_access_action_down",
7798 .handler = client_pd_access_action_down,
7801 .cmd = "pd_access_unhighlight",
7802 .handler = client_pd_access_unhighlight,
7805 .cmd = "pd_access_scroll_down",
7806 .handler = client_pd_access_scroll_down,
7809 .cmd = "pd_access_scroll_move",
7810 .handler = client_pd_access_scroll_move,
7813 .cmd = "pd_access_scroll_up",
7814 .handler = client_pd_access_scroll_up,
7818 .cmd = "lb_access_hl",
7819 .handler = client_lb_access_hl,
7822 .cmd = "lb_access_hl_prev",
7823 .handler = client_lb_access_hl_prev,
7826 .cmd = "lb_access_hl_next",
7827 .handler = client_lb_access_hl_next,
7830 .cmd = "lb_access_activate",
7831 .handler = client_lb_access_activate,
7834 .cmd = "lb_access_action_up",
7835 .handler = client_lb_access_action_up,
7838 .cmd = "lb_access_action_down",
7839 .handler = client_lb_access_action_down,
7842 .cmd = "lb_access_unhighlight",
7843 .handler = client_lb_access_unhighlight,
7846 .cmd = "lb_access_scroll_down",
7847 .handler = client_lb_access_scroll_down,
7850 .cmd = "lb_access_scroll_move",
7851 .handler = client_lb_access_scroll_move,
7854 .cmd = "lb_access_scroll_up",
7855 .handler = client_lb_access_scroll_up,
7859 .cmd = "lb_key_down",
7860 .handler = client_lb_key_down,
7864 .handler = client_lb_key_up,
7868 .cmd = "pd_key_down",
7869 .handler = client_pd_key_down,
7873 .handler = client_pd_key_up,
7877 .cmd = "client_paused",
7878 .handler = client_pause_request,
7881 .cmd = "client_resumed",
7882 .handler = client_resume_request,
7886 .cmd = "update_mode",
7887 .handler = client_update_mode,
7896 static struct method s_service_table[] = {
7898 .cmd = "service_update",
7899 .handler = service_update,
7902 .cmd = "service_change_period",
7903 .handler = service_change_period,
7911 static struct method s_slave_table[] = {
7914 .handler = slave_hello, /* slave_name, ret */
7918 .handler = slave_ping, /* slave_name, ret */
7922 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
7926 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
7930 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
7933 .cmd = "desc_updated",
7934 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
7938 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
7941 .cmd = "acquire_buffer",
7942 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
7945 .cmd = "resize_buffer",
7946 .handler = slave_resize_buffer,
7949 .cmd = "release_buffer",
7950 .handler = slave_release_buffer, /* slave_name, id - ret */
7954 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
7958 .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
7962 .cmd = "lb_update_begin",
7963 .handler = slave_lb_update_begin,
7966 .cmd = "lb_update_end",
7967 .handler = slave_lb_update_end,
7970 .cmd = "pd_update_begin",
7971 .handler = slave_pd_update_begin,
7974 .cmd = "pd_update_end",
7975 .handler = slave_pd_update_end,
7979 .cmd = "access_status",
7980 .handler = slave_access_status,
7989 HAPI int server_init(void)
7991 com_core_packet_use_thread(COM_CORE_THREAD);
7993 if (unlink(INFO_SOCKET) < 0)
7994 ErrPrint("info socket: %s\n", strerror(errno));
7996 if (unlink(SLAVE_SOCKET) < 0)
7997 ErrPrint("slave socket: %s\n", strerror(errno));
7999 if (unlink(CLIENT_SOCKET) < 0)
8000 ErrPrint("client socket: %s\n", strerror(errno));
8002 if (unlink(SERVICE_SOCKET) < 0)
8003 ErrPrint("service socket: %s\n", strerror(errno));
8005 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
8006 if (s_info.info_fd < 0)
8007 ErrPrint("Failed to create a info socket\n");
8009 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
8010 if (s_info.slave_fd < 0)
8011 ErrPrint("Failed to create a slave socket\n");
8013 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
8014 if (s_info.client_fd < 0)
8015 ErrPrint("Failed to create a client socket\n");
8017 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
8018 if (s_info.service_fd < 0)
8019 ErrPrint("Faild to create a service socket\n");
8021 if (chmod(INFO_SOCKET, 0600) < 0)
8022 ErrPrint("info socket: %s\n", strerror(errno));
8024 if (chmod(SLAVE_SOCKET, 0666) < 0)
8025 ErrPrint("slave socket: %s\n", strerror(errno));
8027 if (chmod(CLIENT_SOCKET, 0666) < 0)
8028 ErrPrint("client socket: %s\n", strerror(errno));
8030 if (chmod(SERVICE_SOCKET, 0666) < 0)
8031 ErrPrint("service socket: %s\n", strerror(errno));
8036 HAPI int server_fini(void)
8038 if (s_info.info_fd > 0) {
8039 com_core_packet_server_fini(s_info.info_fd);
8040 s_info.info_fd = -1;
8043 if (s_info.slave_fd > 0) {
8044 com_core_packet_server_fini(s_info.slave_fd);
8045 s_info.slave_fd = -1;
8048 if (s_info.client_fd > 0) {
8049 com_core_packet_server_fini(s_info.client_fd);
8050 s_info.client_fd = -1;
8053 if (s_info.service_fd > 0) {
8054 com_core_packet_server_fini(s_info.service_fd);
8055 s_info.service_fd = -1;