2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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 * If instance_unref returns NULL,
90 * The instance is destroyed. it means, we don't need to send event to the viewer
93 return ECORE_CALLBACK_CANCEL;
96 static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
98 struct inst_info *inst = data;
99 const struct pkg_info *pkg;
100 struct slave_node *slave;
101 struct packet *packet;
104 pkg = instance_package(inst);
106 return LB_STATUS_ERROR_INVALID;
108 slave = package_slave(pkg);
110 return LB_STATUS_ERROR_INVALID;
113 case EVENT_STATE_ACTIVATE:
114 cmdstr = "lb_mouse_down";
116 case EVENT_STATE_ACTIVATED:
117 cmdstr = "lb_mouse_move";
119 case EVENT_STATE_DEACTIVATE:
120 cmdstr = "lb_mouse_up";
123 return LB_STATUS_ERROR_INVALID;
126 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
128 return LB_STATUS_ERROR_FAULT;
130 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
133 static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
135 struct script_info *script;
136 struct inst_info *inst = data;
137 const struct pkg_info *pkg;
141 pkg = instance_package(inst);
145 script = instance_lb_script(inst);
147 return LB_STATUS_ERROR_FAULT;
149 e = script_handler_evas(script);
151 return LB_STATUS_ERROR_FAULT;
153 timestamp = util_timestamp();
156 case EVENT_STATE_ACTIVATE:
157 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
158 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
160 case EVENT_STATE_ACTIVATED:
161 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
162 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
164 case EVENT_STATE_DEACTIVATE:
165 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
166 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
175 static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
177 struct inst_info *inst = data;
178 const struct pkg_info *pkg;
179 struct slave_node *slave;
180 struct packet *packet;
183 pkg = instance_package(inst);
185 return LB_STATUS_ERROR_INVALID;
187 slave = package_slave(pkg);
189 return LB_STATUS_ERROR_INVALID;
191 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
193 case EVENT_STATE_ACTIVATE:
194 cmdstr = "pd_mouse_down";
196 case EVENT_STATE_ACTIVATED:
197 cmdstr = "pd_mouse_move";
199 case EVENT_STATE_DEACTIVATE:
200 cmdstr = "pd_mouse_up";
203 return LB_STATUS_ERROR_INVALID;
206 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
208 return LB_STATUS_ERROR_FAULT;
210 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
213 static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
215 struct script_info *script;
216 struct inst_info *inst = data;
217 const struct pkg_info *pkg;
221 pkg = instance_package(inst);
225 script = instance_pd_script(inst);
227 return LB_STATUS_ERROR_FAULT;
229 e = script_handler_evas(script);
231 return LB_STATUS_ERROR_FAULT;
233 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
234 timestamp = util_timestamp();
237 case EVENT_STATE_ACTIVATE:
238 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
239 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
241 case EVENT_STATE_ACTIVATED:
242 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
243 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
245 case EVENT_STATE_DEACTIVATE:
246 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
247 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
255 static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
257 struct client_node *client;
258 struct packet *result;
262 client = client_find_by_pid(pid);
264 ErrPrint("Client is already exists %d\n", pid);
265 ret = LB_STATUS_ERROR_EXIST;
269 if (packet_get(packet, "d", ×tamp) != 1) {
270 ErrPrint("Invalid arguemnt\n");
271 ret = LB_STATUS_ERROR_INVALID;
278 * client_create will invoke the client created callback
280 client = client_create(pid, handle);
282 ErrPrint("Failed to create a new client for %d\n", pid);
283 ret = LB_STATUS_ERROR_FAULT;
287 result = packet_create_reply(packet, "i", ret);
289 ErrPrint("Failed to create a packet\n");
294 static struct packet *cilent_release(pid_t pid, int handle, const struct packet *packet) /*!< pid, ret */
296 struct client_node *client;
297 struct packet *result;
300 client = client_find_by_pid(pid);
302 ErrPrint("Client %d is not exists\n", pid);
303 ret = LB_STATUS_ERROR_NOT_EXIST;
307 client_destroy(client);
311 result = packet_create_reply(packet, "i", ret);
313 ErrPrint("Failed to create a packet\n");
318 /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
319 static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
321 struct client_node *client;
329 struct inst_info *inst;
331 client = client_find_by_pid(pid);
333 ErrPrint("Client %d is not exists\n", pid);
337 ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
339 ErrPrint("Parameter is not matched\n");
343 DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%lf] y[%lf]\n", pid, pkgname, id, event, timestamp, x, y);
347 * Trust the package name which are sent by the client.
348 * The package has to be a livebox package name.
350 inst = package_find_instance_by_id(pkgname, id);
352 ErrPrint("Instance is not exists\n");
353 else if (package_is_fault(instance_package(inst)))
354 ErrPrint("Fault package\n");
356 (void)instance_clicked(inst, event, timestamp, x, y);
359 /*! \note No reply packet */
363 static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet)
365 struct packet *result;
366 struct client_node *client;
371 struct inst_info *inst;
373 client = client_find_by_pid(pid);
375 ErrPrint("Client %d is not exists\n", pid);
376 ret = LB_STATUS_ERROR_INVALID;
380 ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
382 ErrPrint("Invalid argument\n");
383 ret = LB_STATUS_ERROR_INVALID;
387 inst = package_find_instance_by_id(pkgname, id);
389 ErrPrint("Instance is not exists\n");
390 ret = LB_STATUS_ERROR_NOT_EXIST;
391 } else if (package_is_fault(instance_package(inst))) {
392 ErrPrint("Fault package\n");
393 ret = LB_STATUS_ERROR_FAULT;
397 * Send change update mode request to a slave
399 ret = instance_set_update_mode(inst, active_update);
403 result = packet_create_reply(packet, "i", ret);
405 ErrPrint("Failed to create a packet\n");
410 /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
411 static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
413 struct client_node *client;
414 struct packet *result;
417 const char *emission;
423 struct inst_info *inst;
426 client = client_find_by_pid(pid);
428 ErrPrint("Client %d is not exists\n", pid);
429 ret = LB_STATUS_ERROR_NOT_EXIST;
433 ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
435 ErrPrint("Parameter is not matched\n");
436 ret = LB_STATUS_ERROR_INVALID;
440 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);
444 * Trust the package name which are sent by the client.
445 * The package has to be a livebox package name.
447 inst = package_find_instance_by_id(pkgname, id);
449 ret = LB_STATUS_ERROR_NOT_EXIST;
450 else if (package_is_fault(instance_package(inst)))
451 ret = LB_STATUS_ERROR_FAULT;
453 ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
456 result = packet_create_reply(packet, "i", ret);
458 ErrPrint("Failed to create a packet\n");
463 static Eina_Bool lazy_delete_cb(void *data)
465 struct deleted_item *item = data;
467 DbgPrint("Send delete event to the client\n");
470 * Before invoke this callback, the instance is able to already remove this client
473 if (instance_has_client(item->inst, item->client)) {
474 instance_unicast_deleted_event(item->inst, item->client);
475 instance_del_client(item->inst, item->client);
478 client_unref(item->client);
479 instance_unref(item->inst);
481 return ECORE_CALLBACK_CANCEL;
484 static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
486 struct client_node *client;
487 struct packet *result;
490 struct inst_info *inst;
493 client = client_find_by_pid(pid);
495 ErrPrint("Client %d is not exists\n", pid);
496 ret = LB_STATUS_ERROR_NOT_EXIST;
500 ret = packet_get(packet, "ss", &pkgname, &id);
502 ErrPrint("Parameter is not matched\n");
503 ret = LB_STATUS_ERROR_INVALID;
507 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
511 * Trust the package name which are sent by the client.
512 * The package has to be a livebox package name.
514 inst = package_find_instance_by_id(pkgname, id);
516 ret = LB_STATUS_ERROR_NOT_EXIST;
517 } else if (package_is_fault(instance_package(inst))) {
518 ret = LB_STATUS_ERROR_FAULT;
519 } else if (instance_client(inst) != client) {
520 if (instance_has_client(inst, client)) {
521 struct deleted_item *item;
523 item = malloc(sizeof(*item));
525 ErrPrint("Heap: %s\n", strerror(errno));
526 ret = LB_STATUS_ERROR_MEMORY;
530 * Send DELETED EVENT to the client.
531 * after return from this function.
533 * Client will prepare the deleted event after get this function's return value.
534 * So We have to make a delay to send a deleted event.
537 item->client = client_ref(client);
538 item->inst = instance_ref(inst);
540 if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
541 ErrPrint("Failed to add a delayzed delete callback\n");
542 client_unref(client);
543 instance_unref(inst);
545 ret = LB_STATUS_ERROR_FAULT;
547 ret = LB_STATUS_SUCCESS;
551 ret = LB_STATUS_ERROR_PERMISSION;
554 ret = instance_destroy(inst);
558 result = packet_create_reply(packet, "i", ret);
560 ErrPrint("Failed to create a packet\n");
565 static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
567 struct client_node *client;
568 struct packet *result;
573 struct inst_info *inst;
576 client = client_find_by_pid(pid);
578 ErrPrint("Client %d is not exists\n", pid);
579 ret = LB_STATUS_ERROR_NOT_EXIST;
583 ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
585 ErrPrint("Parameter is not matched\n");
586 ret = LB_STATUS_ERROR_INVALID;
590 DbgPrint("pid[%d] pkgname[%s] id[%s] w[%d] h[%d]\n", pid, pkgname, id, w, h);
591 DbgPrint("RESIZE: INSTANCE[%s] Client request resize to %dx%d\n", id, w, h);
595 * Trust the package name which are sent by the client.
596 * The package has to be a livebox package name.
598 inst = package_find_instance_by_id(pkgname, id);
600 ret = LB_STATUS_ERROR_NOT_EXIST;
601 } else if (package_is_fault(instance_package(inst))) {
602 ret = LB_STATUS_ERROR_FAULT;
603 } else if (instance_client(inst) != client) {
604 ret = LB_STATUS_ERROR_PERMISSION;
606 ret = instance_resize(inst, w, h);
610 result = packet_create_reply(packet, "i", ret);
612 ErrPrint("Failed to create a packet\n");
617 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
619 struct client_node *client;
620 struct packet *result;
624 const char *category;
628 struct pkg_info *info;
633 client = client_find_by_pid(pid);
635 ErrPrint("Client %d is not exists\n", pid);
636 ret = LB_STATUS_ERROR_NOT_EXIST;
640 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
642 ErrPrint("Parameter is not matched\n");
643 ret = LB_STATUS_ERROR_INVALID;
647 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
648 pid, timestamp, pkgname, content, cluster, category, period);
650 lb_pkgname = package_lb_pkgname(pkgname);
652 ErrPrint("This %s has no livebox package\n", pkgname);
653 ret = LB_STATUS_ERROR_INVALID;
657 info = package_find(lb_pkgname);
659 info = package_create(lb_pkgname);
662 ret = LB_STATUS_ERROR_FAULT;
663 } else if (package_is_fault(info)) {
664 ret = LB_STATUS_ERROR_FAULT;
665 } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
666 ErrPrint("Not enough space\n");
667 ret = LB_STATUS_ERROR_NO_SPACE;
669 struct inst_info *inst;
671 if (period > 0.0f && period < MINIMUM_PERIOD)
672 period = MINIMUM_PERIOD;
674 if (!strlen(content))
675 content = DEFAULT_CONTENT;
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)
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_value_change(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, -1);
2346 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, 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_scroll(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_SCROLL, 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_hl(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_HIGHLIGHT, 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_hl_prev(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_HIGHLIGHT_PREV, 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_hl_next(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, -1);
2882 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, 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_activate(pid_t pid, int handle, const struct packet *packet)
2917 struct packet *result;
2918 struct client_node *client;
2919 const char *pkgname;
2925 struct inst_info *inst;
2926 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;
2944 * Trust the package name which are sent by the client.
2945 * The package has to be a livebox package name.
2947 inst = package_find_instance_by_id(pkgname, id);
2949 ErrPrint("Instance[%s] is not exists\n", id);
2950 ret = LB_STATUS_ERROR_NOT_EXIST;
2954 pkg = instance_package(inst);
2956 ErrPrint("Package[%s] info is not found\n", pkgname);
2957 ret = LB_STATUS_ERROR_FAULT;
2961 if (package_is_fault(pkg)) {
2964 * If the package is registered as fault module,
2965 * slave has not load it, so we don't need to do anything at here!
2967 DbgPrint("Package[%s] is faulted\n", pkgname);
2968 ret = LB_STATUS_ERROR_FAULT;
2969 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2970 struct buffer_info *buffer;
2971 struct slave_node *slave;
2972 // struct packet *packet;
2974 buffer = instance_pd_buffer(inst);
2976 ErrPrint("Instance[%s] has no buffer\n", id);
2977 ret = LB_STATUS_ERROR_FAULT;
2981 slave = package_slave(pkg);
2983 ErrPrint("Package[%s] has no slave\n", pkgname);
2984 ret = LB_STATUS_ERROR_INVALID;
2989 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2991 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2992 ret = LB_STATUS_ERROR_FAULT;
2997 packet_ref((struct packet *)packet);
2998 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2999 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3000 struct script_info *script;
3003 script = instance_pd_script(inst);
3005 ret = LB_STATUS_ERROR_FAULT;
3009 e = script_handler_evas(script);
3011 ret = LB_STATUS_ERROR_FAULT;
3015 script_handler_update_pointer(script, x, y, -1);
3016 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
3018 struct access_cbdata *cbdata;
3020 cbdata = malloc(sizeof(*cbdata));
3022 ret = LB_STATUS_ERROR_MEMORY;
3024 cbdata->inst = instance_ref(inst);
3025 cbdata->status = ret;
3027 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3028 instance_unref(cbdata->inst);
3030 ret = LB_STATUS_ERROR_FAULT;
3032 ret = LB_STATUS_SUCCESS;
3037 ErrPrint("Unsupported package\n");
3038 ret = LB_STATUS_ERROR_INVALID;
3042 result = packet_create_reply(packet, "i", ret);
3044 ErrPrint("Failed to create a reply packet\n");
3049 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
3051 struct client_node *client;
3052 const char *pkgname;
3058 struct inst_info *inst;
3059 const struct pkg_info *pkg;
3061 client = client_find_by_pid(pid);
3063 ErrPrint("Client %d is not exists\n", pid);
3064 ret = LB_STATUS_ERROR_NOT_EXIST;
3068 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3070 ErrPrint("Invalid parameter\n");
3071 ret = LB_STATUS_ERROR_INVALID;
3077 * Trust the package name which are sent by the client.
3078 * The package has to be a livebox package name.
3080 inst = package_find_instance_by_id(pkgname, id);
3082 ErrPrint("Instance[%s] is not exists\n", id);
3083 ret = LB_STATUS_ERROR_NOT_EXIST;
3087 pkg = instance_package(inst);
3089 ErrPrint("Package[%s] info is not found\n", pkgname);
3090 ret = LB_STATUS_ERROR_FAULT;
3094 if (package_is_fault(pkg)) {
3097 * If the package is registered as fault module,
3098 * slave has not load it, so we don't need to do anything at here!
3100 DbgPrint("Package[%s] is faulted\n", pkgname);
3101 ret = LB_STATUS_ERROR_FAULT;
3102 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3103 struct buffer_info *buffer;
3104 struct slave_node *slave;
3105 // struct packet *packet;
3107 buffer = instance_pd_buffer(inst);
3109 ErrPrint("Instance[%s] has no buffer\n", id);
3110 ret = LB_STATUS_ERROR_FAULT;
3114 slave = package_slave(pkg);
3116 ErrPrint("Package[%s] has no slave\n", pkgname);
3117 ret = LB_STATUS_ERROR_INVALID;
3122 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3124 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3125 ret = LB_STATUS_ERROR_FAULT;
3130 packet_ref((struct packet *)packet);
3131 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3132 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3133 struct script_info *script;
3136 script = instance_pd_script(inst);
3138 ret = LB_STATUS_ERROR_FAULT;
3142 e = script_handler_evas(script);
3144 ret = LB_STATUS_ERROR_FAULT;
3148 script_handler_update_pointer(script, x, y, -1);
3150 * \TODO: Push up the KEY_DOWN event
3154 ErrPrint("Unsupported package\n");
3155 ret = LB_STATUS_ERROR_INVALID;
3159 /*! \note No reply packet */
3163 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
3165 struct client_node *client;
3169 client = client_find_by_pid(pid);
3171 ErrPrint("Client %d is paused - manually reported\n", pid);
3172 ret = LB_STATUS_ERROR_NOT_EXIST;
3176 ret = packet_get(packet, "d", ×tamp);
3178 ErrPrint("Invalid parameter\n");
3179 ret = LB_STATUS_ERROR_INVALID;
3184 DbgPrint("XMONITOR enabled. ignore client paused request\n");
3186 xmonitor_pause(client);
3192 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
3194 struct client_node *client;
3198 client = client_find_by_pid(pid);
3200 ErrPrint("Client %d is not exists\n", pid);
3204 ret = packet_get(packet, "d", ×tamp);
3206 ErrPrint("Invalid parameter\n");
3211 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
3213 xmonitor_resume(client);
3219 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
3221 struct client_node *client;
3222 const char *pkgname;
3228 struct inst_info *inst;
3229 const struct pkg_info *pkg;
3231 client = client_find_by_pid(pid);
3233 ErrPrint("Client %d is not exists\n", pid);
3234 ret = LB_STATUS_ERROR_NOT_EXIST;
3238 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3240 ErrPrint("Invalid parameter\n");
3241 ret = LB_STATUS_ERROR_INVALID;
3247 * Trust the package name which are sent by the client.
3248 * The package has to be a livebox package name.
3250 inst = package_find_instance_by_id(pkgname, id);
3252 ErrPrint("Instance[%s] is not exists\n", id);
3253 ret = LB_STATUS_ERROR_NOT_EXIST;
3257 pkg = instance_package(inst);
3259 ErrPrint("Package[%s] info is not found\n", pkgname);
3260 ret = LB_STATUS_ERROR_FAULT;
3264 if (package_is_fault(pkg)) {
3267 * If the package is registered as fault module,
3268 * slave has not load it, so we don't need to do anything at here!
3270 DbgPrint("Package[%s] is faulted\n", pkgname);
3271 ret = LB_STATUS_ERROR_FAULT;
3272 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3273 struct buffer_info *buffer;
3274 struct slave_node *slave;
3275 // struct packet *packet;
3277 buffer = instance_pd_buffer(inst);
3279 ErrPrint("Instance[%s] has no buffer\n", id);
3280 ret = LB_STATUS_ERROR_FAULT;
3284 slave = package_slave(pkg);
3286 ErrPrint("Package[%s] has no slave\n", pkgname);
3287 ret = LB_STATUS_ERROR_INVALID;
3292 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3294 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3295 ret = LB_STATUS_ERROR_FAULT;
3300 packet_ref((struct packet *)packet);
3301 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3302 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3303 struct script_info *script;
3306 script = instance_pd_script(inst);
3308 ret = LB_STATUS_ERROR_FAULT;
3312 e = script_handler_evas(script);
3314 ret = LB_STATUS_ERROR_FAULT;
3318 script_handler_update_pointer(script, x, y, -1);
3320 * \TODO: Push up the KEY_UP event
3324 ErrPrint("Unsupported package\n");
3325 ret = LB_STATUS_ERROR_INVALID;
3329 /*! \note No reply packet */
3333 static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
3335 struct packet *result;
3336 struct client_node *client;
3337 const char *pkgname;
3343 struct inst_info *inst;
3344 const struct pkg_info *pkg;
3346 client = client_find_by_pid(pid);
3348 ErrPrint("Client %d is not exists\n", pid);
3349 ret = LB_STATUS_ERROR_NOT_EXIST;
3353 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3355 ErrPrint("Parameter is not matched\n");
3356 ret = LB_STATUS_ERROR_INVALID;
3362 * Trust the package name which are sent by the client.
3363 * The package has to be a livebox package name.
3365 inst = package_find_instance_by_id(pkgname, id);
3367 ErrPrint("Instance[%s] is not exists\n", id);
3368 ret = LB_STATUS_ERROR_NOT_EXIST;
3372 pkg = instance_package(inst);
3374 ErrPrint("Package[%s] info is not exists\n", pkgname);
3375 ret = LB_STATUS_ERROR_FAULT;
3379 if (package_is_fault(pkg)) {
3382 * If the package is registered as fault module,
3383 * slave has not load it, so we don't need to do anything at here!
3385 DbgPrint("Package[%s] is faulted\n", pkgname);
3386 ret = LB_STATUS_ERROR_FAULT;
3387 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3388 struct buffer_info *buffer;
3389 struct slave_node *slave;
3390 //struct packet *packet;
3392 buffer = instance_lb_buffer(inst);
3394 ErrPrint("Instance[%s] has no buffer\n", id);
3395 ret = LB_STATUS_ERROR_FAULT;
3399 slave = package_slave(pkg);
3401 ErrPrint("Package[%s] has no slave\n", pkgname);
3402 ret = LB_STATUS_ERROR_INVALID;
3407 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3409 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3410 ret = LB_STATUS_ERROR_FAULT;
3415 packet_ref((struct packet *)packet);
3416 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3417 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3418 struct script_info *script;
3421 script = instance_lb_script(inst);
3423 ret = LB_STATUS_ERROR_FAULT;
3427 e = script_handler_evas(script);
3429 ret = LB_STATUS_ERROR_FAULT;
3433 script_handler_update_pointer(script, x, y, -1);
3434 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
3436 struct access_cbdata *cbdata;
3438 cbdata = malloc(sizeof(*cbdata));
3440 ret = LB_STATUS_ERROR_MEMORY;
3442 cbdata->inst = instance_ref(inst);
3443 cbdata->status = ret;
3445 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3446 instance_unref(cbdata->inst);
3448 ret = LB_STATUS_ERROR_FAULT;
3450 ret = LB_STATUS_SUCCESS;
3455 ErrPrint("Unsupported package\n");
3456 ret = LB_STATUS_ERROR_INVALID;
3460 result = packet_create_reply(packet, "i", ret);
3462 ErrPrint("Failed to create a reply packet\n");
3467 static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
3469 struct packet *result;
3470 struct client_node *client;
3471 const char *pkgname;
3477 struct inst_info *inst;
3478 const struct pkg_info *pkg;
3480 client = client_find_by_pid(pid);
3482 ErrPrint("Client %d is not exists\n", pid);
3483 ret = LB_STATUS_ERROR_NOT_EXIST;
3487 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3489 ErrPrint("Parameter is not matched\n");
3490 ret = LB_STATUS_ERROR_INVALID;
3496 * Trust the package name which are sent by the client.
3497 * The package has to be a livebox package name.
3499 inst = package_find_instance_by_id(pkgname, id);
3501 ErrPrint("Instance[%s] is not exists\n", id);
3502 ret = LB_STATUS_ERROR_NOT_EXIST;
3506 pkg = instance_package(inst);
3508 ErrPrint("Package[%s] info is not exists\n", pkgname);
3509 ret = LB_STATUS_ERROR_FAULT;
3513 if (package_is_fault(pkg)) {
3516 * If the package is registered as fault module,
3517 * slave has not load it, so we don't need to do anything at here!
3519 DbgPrint("Package[%s] is faulted\n", pkgname);
3520 ret = LB_STATUS_ERROR_FAULT;
3521 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3522 struct buffer_info *buffer;
3523 struct slave_node *slave;
3524 //struct packet *packet;
3526 buffer = instance_lb_buffer(inst);
3528 ErrPrint("Instance[%s] has no buffer\n", id);
3529 ret = LB_STATUS_ERROR_FAULT;
3533 slave = package_slave(pkg);
3535 ErrPrint("Package[%s] has no slave\n", pkgname);
3536 ret = LB_STATUS_ERROR_INVALID;
3541 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3543 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3544 ret = LB_STATUS_ERROR_FAULT;
3549 packet_ref((struct packet *)packet);
3550 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3551 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3552 struct script_info *script;
3555 script = instance_lb_script(inst);
3557 ret = LB_STATUS_ERROR_FAULT;
3561 e = script_handler_evas(script);
3563 ret = LB_STATUS_ERROR_FAULT;
3567 script_handler_update_pointer(script, x, y, -1);
3568 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
3570 struct access_cbdata *cbdata;
3572 cbdata = malloc(sizeof(*cbdata));
3574 ret = LB_STATUS_ERROR_MEMORY;
3576 cbdata->inst = instance_ref(inst);
3577 cbdata->status = ret;
3579 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3580 instance_unref(cbdata->inst);
3582 ret = LB_STATUS_ERROR_FAULT;
3584 ret = LB_STATUS_SUCCESS;
3589 ErrPrint("Unsupported package\n");
3590 ret = LB_STATUS_ERROR_INVALID;
3594 result = packet_create_reply(packet, "i", ret);
3596 ErrPrint("Failed to create a reply packet\n");
3601 static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet)
3603 struct packet *result;
3604 struct client_node *client;
3605 const char *pkgname;
3611 struct inst_info *inst;
3612 const struct pkg_info *pkg;
3614 client = client_find_by_pid(pid);
3616 ErrPrint("Client %d is not exists\n", pid);
3617 ret = LB_STATUS_ERROR_NOT_EXIST;
3621 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3623 ErrPrint("Parameter is not matched\n");
3624 ret = LB_STATUS_ERROR_INVALID;
3630 * Trust the package name which are sent by the client.
3631 * The package has to be a livebox package name.
3633 inst = package_find_instance_by_id(pkgname, id);
3635 ErrPrint("Instance[%s] is not exists\n", id);
3636 ret = LB_STATUS_ERROR_NOT_EXIST;
3640 pkg = instance_package(inst);
3642 ErrPrint("Package[%s] info is not exists\n", pkgname);
3643 ret = LB_STATUS_ERROR_FAULT;
3647 if (package_is_fault(pkg)) {
3650 * If the package is registered as fault module,
3651 * slave has not load it, so we don't need to do anything at here!
3653 DbgPrint("Package[%s] is faulted\n", pkgname);
3654 ret = LB_STATUS_ERROR_FAULT;
3655 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3656 struct buffer_info *buffer;
3657 struct slave_node *slave;
3658 //struct packet *packet;
3660 buffer = instance_lb_buffer(inst);
3662 ErrPrint("Instance[%s] has no buffer\n", id);
3663 ret = LB_STATUS_ERROR_FAULT;
3667 slave = package_slave(pkg);
3669 ErrPrint("Package[%s] has no slave\n", pkgname);
3670 ret = LB_STATUS_ERROR_INVALID;
3675 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3677 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3678 ret = LB_STATUS_ERROR_FAULT;
3683 packet_ref((struct packet *)packet);
3684 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3685 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3686 struct script_info *script;
3689 script = instance_lb_script(inst);
3691 ret = LB_STATUS_ERROR_FAULT;
3695 e = script_handler_evas(script);
3697 ret = LB_STATUS_ERROR_FAULT;
3701 script_handler_update_pointer(script, x, y, -1);
3702 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
3704 struct access_cbdata *cbdata;
3706 cbdata = malloc(sizeof(*cbdata));
3708 ret = LB_STATUS_ERROR_MEMORY;
3710 cbdata->inst = instance_ref(inst);
3711 cbdata->status = ret;
3713 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3714 instance_unref(cbdata->inst);
3716 ret = LB_STATUS_ERROR_FAULT;
3718 ret = LB_STATUS_SUCCESS;
3723 ErrPrint("Unsupported package\n");
3724 ret = LB_STATUS_ERROR_INVALID;
3728 result = packet_create_reply(packet, "i", ret);
3730 ErrPrint("Failed to create a reply packet\n");
3735 static struct packet *client_lb_access_value_change(pid_t pid, int handle, const struct packet *packet)
3737 struct packet *result;
3738 struct client_node *client;
3739 const char *pkgname;
3743 struct inst_info *inst;
3744 const struct pkg_info *pkg;
3748 client = client_find_by_pid(pid);
3750 ErrPrint("Client %d is not exist\n", pid);
3754 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3756 ErrPrint("Invalid argument\n");
3760 inst = package_find_instance_by_id(pkgname, id);
3762 ErrPrint("Instance[%s] is not exists\n", id);
3766 pkg = instance_package(inst);
3768 ErrPrint("Package[%s] info is not exists\n", pkgname);
3772 if (package_is_fault(pkg)) {
3773 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3774 struct buffer_info *buffer;
3775 struct slave_node *slave;
3777 buffer = instance_lb_buffer(inst);
3779 ErrPrint("Instance[%s] has no buffer\n", id);
3783 slave = package_slave(pkg);
3785 ErrPrint("Slave is not exists\n");
3789 packet_ref((struct packet *)packet);
3790 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3792 * Enen if it fails to send packet,
3793 * The packet will be unref'd
3794 * So we don't need to check the ret value.
3796 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3797 struct script_info *script;
3800 script = instance_lb_script(inst);
3802 ErrPrint("Instance has no script\n");
3806 e = script_handler_evas(script);
3808 ErrPrint("Script has no evas\n");
3812 script_handler_update_pointer(script, x, y, -1);
3813 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, timestamp);
3815 struct access_cbdata *cbdata;
3817 cbdata = malloc(sizeof(*cbdata));
3819 ret = LB_STATUS_ERROR_MEMORY;
3821 cbdata->inst = instance_ref(inst);
3822 cbdata->status = ret;
3824 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3825 instance_unref(cbdata->inst);
3827 ret = LB_STATUS_ERROR_FAULT;
3829 ret = LB_STATUS_SUCCESS;
3834 ErrPrint("Unsupported package\n");
3838 result = packet_create_reply(packet, "i", ret);
3840 ErrPrint("Failed to create a reply packet\n");
3845 static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struct packet *packet)
3847 struct packet *result;
3848 struct client_node *client;
3849 const char *pkgname;
3853 struct inst_info *inst;
3854 const struct pkg_info *pkg;
3858 client = client_find_by_pid(pid);
3860 ErrPrint("Client %d is not exist\n", pid);
3864 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3866 ErrPrint("Invalid argument\n");
3870 inst = package_find_instance_by_id(pkgname, id);
3872 ErrPrint("Instance[%s] is not exists\n", id);
3876 pkg = instance_package(inst);
3878 ErrPrint("Package[%s] info is not exists\n", pkgname);
3882 if (package_is_fault(pkg)) {
3883 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3884 struct buffer_info *buffer;
3885 struct slave_node *slave;
3887 buffer = instance_lb_buffer(inst);
3889 ErrPrint("Instance[%s] has no buffer\n", id);
3893 slave = package_slave(pkg);
3895 ErrPrint("Slave is not exists\n");
3899 packet_ref((struct packet *)packet);
3900 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3902 * Enen if it fails to send packet,
3903 * The packet will be unref'd
3904 * So we don't need to check the ret value.
3906 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3907 struct script_info *script;
3910 script = instance_lb_script(inst);
3912 ErrPrint("Instance has no script\n");
3916 e = script_handler_evas(script);
3918 ErrPrint("Instance has no evas\n");
3922 script_handler_update_pointer(script, x, y, -1);
3923 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
3925 struct access_cbdata *cbdata;
3927 cbdata = malloc(sizeof(*cbdata));
3929 ret = LB_STATUS_ERROR_MEMORY;
3931 cbdata->inst = instance_ref(inst);
3932 cbdata->status = ret;
3934 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3935 instance_unref(cbdata->inst);
3937 ret = LB_STATUS_ERROR_FAULT;
3939 ret = LB_STATUS_SUCCESS;
3944 ErrPrint("Unsupported package\n");
3948 result = packet_create_reply(packet, "i", ret);
3950 ErrPrint("Failed to create a reply packet\n");
3955 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
3957 struct packet *result;
3958 struct client_node *client;
3959 const char *pkgname;
3965 struct inst_info *inst;
3966 const struct pkg_info *pkg;
3968 client = client_find_by_pid(pid);
3970 ErrPrint("Client %d is not exists\n", pid);
3971 ret = LB_STATUS_ERROR_NOT_EXIST;
3975 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3977 ErrPrint("Parameter is not matched\n");
3983 * Trust the package name which are sent by the client.
3984 * The package has to be a livebox package name.
3986 inst = package_find_instance_by_id(pkgname, id);
3988 ErrPrint("Instance[%s] is not exists\n", id);
3992 pkg = instance_package(inst);
3994 ErrPrint("Package[%s] info is not exists\n", pkgname);
3998 if (package_is_fault(pkg)) {
4001 * If the package is registered as fault module,
4002 * slave has not load it, so we don't need to do anything at here!
4004 DbgPrint("Package[%s] is faulted\n", pkgname);
4005 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4006 struct buffer_info *buffer;
4007 struct slave_node *slave;
4008 //struct packet *packet;
4010 buffer = instance_lb_buffer(inst);
4012 ErrPrint("Instance[%s] has no buffer\n", id);
4016 slave = package_slave(pkg);
4018 ErrPrint("Package[%s] has no slave\n", pkgname);
4023 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4025 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4026 ret = LB_STATUS_ERROR_FAULT;
4031 packet_ref((struct packet *)packet);
4032 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4033 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4034 struct script_info *script;
4037 script = instance_lb_script(inst);
4039 ErrPrint("Instance has no script\n");
4043 e = script_handler_evas(script);
4045 ErrPrint("Script has no Evas\n");
4049 script_handler_update_pointer(script, x, y, -1);
4050 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
4052 struct access_cbdata *cbdata;
4054 cbdata = malloc(sizeof(*cbdata));
4056 ret = LB_STATUS_ERROR_MEMORY;
4058 cbdata->inst = instance_ref(inst);
4059 cbdata->status = ret;
4061 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4062 instance_unref(cbdata->inst);
4064 ret = LB_STATUS_ERROR_FAULT;
4066 ret = LB_STATUS_SUCCESS;
4071 ErrPrint("Unsupported package\n");
4075 result = packet_create_reply(packet, "i", ret);
4077 ErrPrint("Failed to create a reply packet\n");
4082 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
4084 struct client_node *client;
4085 const char *pkgname;
4091 struct inst_info *inst;
4092 const struct pkg_info *pkg;
4094 client = client_find_by_pid(pid);
4096 ErrPrint("Client %d is not exists\n", pid);
4097 ret = LB_STATUS_ERROR_NOT_EXIST;
4101 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4103 ErrPrint("Parameter is not matched\n");
4104 ret = LB_STATUS_ERROR_INVALID;
4110 * Trust the package name which are sent by the client.
4111 * The package has to be a livebox package name.
4113 inst = package_find_instance_by_id(pkgname, id);
4115 ErrPrint("Instance[%s] is not exists\n", id);
4116 ret = LB_STATUS_ERROR_NOT_EXIST;
4120 pkg = instance_package(inst);
4122 ErrPrint("Package[%s] info is not exists\n", pkgname);
4123 ret = LB_STATUS_ERROR_FAULT;
4127 if (package_is_fault(pkg)) {
4130 * If the package is registered as fault module,
4131 * slave has not load it, so we don't need to do anything at here!
4133 DbgPrint("Package[%s] is faulted\n", pkgname);
4134 ret = LB_STATUS_ERROR_FAULT;
4135 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4136 struct buffer_info *buffer;
4137 struct slave_node *slave;
4138 //struct packet *packet;
4140 buffer = instance_lb_buffer(inst);
4142 ErrPrint("Instance[%s] has no buffer\n", id);
4143 ret = LB_STATUS_ERROR_FAULT;
4147 slave = package_slave(pkg);
4149 ErrPrint("Package[%s] has no slave\n", pkgname);
4150 ret = LB_STATUS_ERROR_INVALID;
4155 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4157 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4158 ret = LB_STATUS_ERROR_FAULT;
4163 packet_ref((struct packet *)packet);
4164 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4165 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4166 struct script_info *script;
4169 script = instance_lb_script(inst);
4171 ret = LB_STATUS_ERROR_FAULT;
4175 e = script_handler_evas(script);
4177 ret = LB_STATUS_ERROR_FAULT;
4181 script_handler_update_pointer(script, x, y, -1);
4184 * \TODO: Feed up this KEY_DOWN event
4188 ErrPrint("Unsupported package\n");
4189 ret = LB_STATUS_ERROR_INVALID;
4193 /*! \note No reply packet */
4197 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
4199 struct client_node *client;
4200 const char *pkgname;
4206 struct inst_info *inst;
4207 const struct pkg_info *pkg;
4209 client = client_find_by_pid(pid);
4211 ErrPrint("Client %d is not exists\n", pid);
4212 ret = LB_STATUS_ERROR_NOT_EXIST;
4216 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4218 ErrPrint("Parameter is not matched\n");
4219 ret = LB_STATUS_ERROR_INVALID;
4225 * Trust the package name which are sent by the client.
4226 * The package has to be a livebox package name.
4228 inst = package_find_instance_by_id(pkgname, id);
4230 ErrPrint("Instance[%s] is not exists\n", id);
4231 ret = LB_STATUS_ERROR_NOT_EXIST;
4235 pkg = instance_package(inst);
4237 ErrPrint("Package[%s] info is not exists\n", pkgname);
4238 ret = LB_STATUS_ERROR_FAULT;
4242 if (package_is_fault(pkg)) {
4245 * If the package is registered as fault module,
4246 * slave has not load it, so we don't need to do anything at here!
4248 DbgPrint("Package[%s] is faulted\n", pkgname);
4249 ret = LB_STATUS_ERROR_FAULT;
4250 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4251 struct buffer_info *buffer;
4252 struct slave_node *slave;
4253 //struct packet *packet;
4255 buffer = instance_lb_buffer(inst);
4257 ErrPrint("Instance[%s] has no buffer\n", id);
4258 ret = LB_STATUS_ERROR_FAULT;
4262 slave = package_slave(pkg);
4264 ErrPrint("Package[%s] has no slave\n", pkgname);
4265 ret = LB_STATUS_ERROR_INVALID;
4270 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4272 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4273 ret = LB_STATUS_ERROR_FAULT;
4278 packet_ref((struct packet *)packet);
4279 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4280 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4281 struct script_info *script;
4284 script = instance_lb_script(inst);
4286 ret = LB_STATUS_ERROR_FAULT;
4290 e = script_handler_evas(script);
4292 ret = LB_STATUS_ERROR_FAULT;
4296 script_handler_update_pointer(script, x, y, -1);
4299 * \TODO: Feed up this KEY_UP event
4303 ErrPrint("Unsupported package\n");
4304 ret = LB_STATUS_ERROR_INVALID;
4308 /*! \note No reply packet */
4312 static int release_pixmap_cb(struct client_node *client, void *canvas)
4314 DbgPrint("Forcely unref the \"buffer\"\n");
4315 buffer_handler_pixmap_unref(canvas);
4316 return -1; /* Delete this callback */
4319 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 */
4321 struct packet *result;
4322 const char *pkgname;
4324 struct client_node *client;
4325 struct inst_info *inst;
4330 client = client_find_by_pid(pid);
4332 ErrPrint("Client %d is not exists\n", pid);
4336 ret = packet_get(packet, "ss", &pkgname, &id);
4338 ErrPrint("Parameter is not matched\n");
4344 * Trust the package name which are sent by the client.
4345 * The package has to be a livebox package name.
4347 inst = package_find_instance_by_id(pkgname, id);
4349 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4353 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4355 buf_ptr = buffer_handler_pixmap_ref(instance_lb_buffer(inst));
4357 ErrPrint("Failed to ref pixmap\n");
4361 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
4363 ErrPrint("Failed to add a new client deactivate callback\n");
4364 buffer_handler_pixmap_unref(buf_ptr);
4367 pixmap = buffer_handler_pixmap(instance_lb_buffer(inst));
4371 result = packet_create_reply(packet, "i", pixmap);
4373 ErrPrint("Failed to create a reply packet\n");
4378 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
4380 const char *pkgname;
4382 struct client_node *client;
4383 struct inst_info *inst;
4388 client = client_find_by_pid(pid);
4390 ErrPrint("Client %d is not exists\n", pid);
4394 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
4396 ErrPrint("Parameter is not matched\n");
4399 DbgPrint("pid[%d] pkgname[%s] id[%s] Pixmap[0x%X]\n", pid, pkgname, id, pixmap);
4403 * Trust the package name which are sent by the client.
4404 * The package has to be a livebox package name.
4406 inst = package_find_instance_by_id(pkgname, id);
4408 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4412 buf_ptr = buffer_handler_pixmap_find(pixmap);
4414 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
4418 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
4419 buffer_handler_pixmap_unref(buf_ptr);
4422 /*! \note No reply packet */
4426 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 */
4428 struct packet *result;
4429 const char *pkgname;
4431 struct client_node *client;
4432 struct inst_info *inst;
4437 client = client_find_by_pid(pid);
4439 ErrPrint("Client %d is not exists\n", pid);
4443 ret = packet_get(packet, "ss", &pkgname, &id);
4445 ErrPrint("Parameter is not matched\n");
4451 * Trust the package name which are sent by the client.
4452 * The package has to be a livebox package name.
4454 inst = package_find_instance_by_id(pkgname, id);
4456 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4460 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4462 buf_ptr = buffer_handler_pixmap_ref(instance_pd_buffer(inst));
4464 ErrPrint("Failed to ref pixmap\n");
4468 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
4470 buffer_handler_pixmap_unref(buf_ptr);
4472 pixmap = buffer_handler_pixmap(instance_pd_buffer(inst));
4474 result = packet_create_reply(packet, "i", pixmap);
4476 ErrPrint("Failed to create a reply packet\n");
4481 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
4483 const char *pkgname;
4485 struct client_node *client;
4486 struct inst_info *inst;
4491 client = client_find_by_pid(pid);
4493 ErrPrint("Client %d is not exists\n", pid);
4497 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
4499 ErrPrint("Parameter is not matched\n");
4502 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4506 * Trust the package name which are sent by the client.
4507 * The package has to be a livebox package name.
4509 inst = package_find_instance_by_id(pkgname, id);
4511 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4515 buf_ptr = buffer_handler_pixmap_find(pixmap);
4517 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
4521 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
4522 buffer_handler_pixmap_unref(buf_ptr);
4525 /*! \note No reply packet */
4529 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
4531 struct client_node *client;
4532 struct packet *result;
4533 const char *pkgname;
4537 struct inst_info *inst;
4539 client = client_find_by_pid(pid);
4541 ErrPrint("Client %d is not exists\n", pid);
4542 ret = LB_STATUS_ERROR_NOT_EXIST;
4547 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
4549 ErrPrint("Parameter is not matched\n");
4550 ret = LB_STATUS_ERROR_INVALID;
4555 DbgPrint("pid[%d] pkgname[%s] id[%s] pinup[%d]\n", pid, pkgname, id, pinup);
4559 * Trust the package name which are sent by the client.
4560 * The package has to be a livebox package name.
4562 inst = package_find_instance_by_id(pkgname, id);
4564 ret = LB_STATUS_ERROR_NOT_EXIST;
4565 else if (package_is_fault(instance_package(inst)))
4566 ret = LB_STATUS_ERROR_FAULT;
4568 ret = instance_set_pinup(inst, pinup);
4571 result = packet_create_reply(packet, "i", ret);
4573 ErrPrint("Failed to create a packet\n");
4578 static Eina_Bool lazy_pd_created_cb(void *data)
4580 if (instance_unref(data)) {
4582 ret = instance_client_pd_created(data, LB_STATUS_SUCCESS);
4583 DbgPrint("Send PD Create event (%d)\n", ret);
4586 return ECORE_CALLBACK_CANCEL;
4589 static Eina_Bool lazy_pd_destroyed_cb(void *data)
4591 if (instance_unref(data)) {
4592 DbgPrint("Send PD Destroy event\n");
4593 instance_client_pd_destroyed(data, LB_STATUS_SUCCESS);
4596 return ECORE_CALLBACK_CANCEL;
4599 static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
4601 struct client_node *client;
4602 struct inst_info *inst;
4603 const char *pkgname;
4609 client = client_find_by_pid(pid);
4611 ErrPrint("Client %d is not exists\n", pid);
4612 ret = LB_STATUS_ERROR_NOT_EXIST;
4616 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
4618 ErrPrint("Parameter is not correct\n");
4619 ret = LB_STATUS_ERROR_INVALID;
4623 DbgPrint("pid[%d] pkgname[%s] id[%s] %lfx%lf\n", pid, pkgname, id, x, y);
4625 inst = package_find_instance_by_id(pkgname, id);
4627 ret = LB_STATUS_ERROR_NOT_EXIST;
4628 else if (package_is_fault(instance_package(inst)))
4629 ret = LB_STATUS_ERROR_FAULT;
4630 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4631 instance_slave_set_pd_pos(inst, x, y);
4632 ret = instance_signal_emit(inst,
4633 "pd,move", util_uri_to_path(instance_id(inst)),
4634 0.0, 0.0, 0.0, 0.0, x, y, 0);
4635 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4639 instance_slave_set_pd_pos(inst, x, y);
4640 ix = x * instance_pd_width(inst);
4641 iy = y * instance_pd_height(inst);
4642 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
4643 ret = instance_signal_emit(inst,
4644 "pd,move", util_uri_to_path(instance_id(inst)),
4645 0.0, 0.0, 0.0, 0.0, x, y, 0);
4647 ErrPrint("Invalid PD type\n");
4648 ret = LB_STATUS_ERROR_INVALID;
4651 DbgPrint("Update PD position: %lfx%lf (%d)\n", x, y, ret);
4655 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
4657 struct client_node *client;
4658 struct packet *result;
4659 const char *pkgname;
4662 struct inst_info *inst;
4666 client = client_find_by_pid(pid);
4668 ErrPrint("Client %d is not exists\n", pid);
4669 ret = LB_STATUS_ERROR_NOT_EXIST;
4673 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
4675 ErrPrint("Parameter is not matched\n");
4676 ret = LB_STATUS_ERROR_INVALID;
4680 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4684 * Trust the package name which are sent by the client.
4685 * The package has to be a livebox package name.
4687 inst = package_find_instance_by_id(pkgname, id);
4689 ret = LB_STATUS_ERROR_NOT_EXIST;
4690 else if (package_is_fault(instance_package(inst)))
4691 ret = LB_STATUS_ERROR_FAULT;
4692 else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
4693 ret = LB_STATUS_ERROR_NO_SPACE;
4694 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4695 instance_slave_set_pd_pos(inst, x, y);
4696 ret = instance_slave_open_pd(inst, client);
4697 ret = instance_signal_emit(inst,
4698 "pd,show", util_uri_to_path(instance_id(inst)),
4699 0.0, 0.0, 0.0, 0.0, x, y, 0);
4702 * PD craeted event will be send by the acquire_buffer function.
4703 * Because the slave will make request the acquire_buffer to
4706 * instance_client_pd_created(inst);
4708 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4713 * ret value should be cared but in this case,
4714 * we ignore this for this moment, so we have to handle this error later.
4716 * if ret is less than 0, the slave has some problem.
4717 * but the script mode doesn't need slave for rendering default view of PD
4718 * so we can hanle it later.
4720 instance_slave_set_pd_pos(inst, x, y);
4721 ix = x * instance_pd_width(inst);
4722 iy = y * instance_pd_height(inst);
4724 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
4726 ret = instance_slave_open_pd(inst, client);
4727 if (ret == LB_STATUS_SUCCESS) {
4728 ret = script_handler_load(instance_pd_script(inst), 1);
4732 * Send the PD created event to the clients,
4734 if (ret == LB_STATUS_SUCCESS) {
4737 * But the created event has to be send afte return
4738 * from this function or the viewer couldn't care
4739 * the event correctly.
4741 inst = instance_ref(inst); /* To guarantee the inst */
4742 if (!ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst)) {
4743 instance_unref(inst);
4744 script_handler_unload(instance_pd_script(inst), 1);
4745 instance_slave_close_pd(inst, client);
4747 ErrPrint("Failed to add delayed timer\n");
4748 ret = LB_STATUS_ERROR_FAULT;
4751 instance_slave_close_pd(inst, client);
4754 ErrPrint("Failed to request open PD to the slave\n");
4757 ErrPrint("Invalid PD TYPE\n");
4758 ret = LB_STATUS_ERROR_INVALID;
4762 result = packet_create_reply(packet, "i", ret);
4764 ErrPrint("Failed to create a packet\n");
4769 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
4771 struct client_node *client;
4772 struct packet *result;
4773 const char *pkgname;
4776 struct inst_info *inst;
4778 client = client_find_by_pid(pid);
4780 ErrPrint("Client %d is not exists\n", pid);
4781 ret = LB_STATUS_ERROR_NOT_EXIST;
4785 ret = packet_get(packet, "ss", &pkgname, &id);
4787 ErrPrint("Parameter is not matched\n");
4788 ret = LB_STATUS_ERROR_INVALID;
4792 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4796 * Trust the package name which are sent by the client.
4797 * The package has to be a livebox package name.
4799 inst = package_find_instance_by_id(pkgname, id);
4801 ret = LB_STATUS_ERROR_NOT_EXIST;
4802 else if (package_is_fault(instance_package(inst)))
4803 ret = LB_STATUS_ERROR_FAULT;
4804 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4805 ret = instance_signal_emit(inst,
4806 "pd,hide", util_uri_to_path(instance_id(inst)),
4807 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
4808 ret = instance_slave_close_pd(inst, client);
4812 * release_buffer will be called by the slave after this.
4813 * Then it will send the "pd_destroyed" event to the client
4815 * instance_client_pd_destroyed(inst);
4818 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4819 ret = script_handler_unload(instance_pd_script(inst), 1);
4820 ret = instance_slave_close_pd(inst, client);
4824 * Send the destroyed PD event to the client
4826 if (ret == LB_STATUS_SUCCESS) {
4827 inst = instance_ref(inst);
4828 if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst)) {
4829 instance_unref(inst);
4831 * How can we handle this?
4833 ret = LB_STATUS_ERROR_FAULT;
4837 ErrPrint("Invalid PD TYPE\n");
4838 ret = LB_STATUS_ERROR_INVALID;
4842 result = packet_create_reply(packet, "i", ret);
4844 ErrPrint("Failed to create a packet\n");
4849 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
4851 struct client_node *client;
4852 struct packet *result;
4853 const char *pkgname;
4855 struct pkg_info *info;
4857 client = client_find_by_pid(pid);
4859 ErrPrint("Client %d is not exists\n", pid);
4860 ret = LB_STATUS_ERROR_NOT_EXIST;
4865 ret = packet_get(packet, "s", &pkgname);
4867 ErrPrint("Parameter is not matched\n");
4868 ret = LB_STATUS_ERROR_INVALID;
4873 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
4877 * Validate the livebox package name.
4879 if (!package_is_lb_pkgname(pkgname)) {
4880 ErrPrint("%s is not a valid livebox package\n", pkgname);
4882 ret = LB_STATUS_ERROR_INVALID;
4886 info = package_find(pkgname);
4888 ret = LB_STATUS_ERROR_NOT_EXIST;
4890 ret = package_clear_fault(info);
4893 result = packet_create_reply(packet, "is", ret, pkgname);
4895 ErrPrint("Failed to create a packet\n");
4900 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
4902 const char *cluster;
4903 const char *category;
4904 struct client_node *client;
4907 client = client_find_by_pid(pid);
4909 ErrPrint("Client %d is not exists\n", pid);
4910 ret = LB_STATUS_ERROR_NOT_EXIST;
4914 ret = packet_get(packet, "ss", &cluster, &category);
4916 ErrPrint("Invalid argument\n");
4917 ret = LB_STATUS_ERROR_INVALID;
4921 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
4922 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4923 ErrPrint("Invalid cluster name\n");
4929 * SUBSCRIBE cluster & sub-cluster for a client.
4931 ret = client_subscribe(client, cluster, category);
4933 package_alter_instances_to_client(client, ALTER_CREATE);
4936 /*! \note No reply packet */
4940 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
4942 const char *cluster;
4943 struct client_node *client;
4944 struct packet *result;
4947 client = client_find_by_pid(pid);
4949 ErrPrint("Client %d is not exists\n", pid);
4950 ret = LB_STATUS_ERROR_NOT_EXIST;
4954 ret = packet_get(packet, "s", &cluster);
4956 ErrPrint("Invalid parameters\n");
4957 ret = LB_STATUS_ERROR_INVALID;
4961 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
4963 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4964 ErrPrint("Invalid cluster: %s\n", cluster);
4965 ret = LB_STATUS_ERROR_INVALID;
4972 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
4975 result = packet_create_reply(packet, "i", ret);
4977 ErrPrint("Failed to create a packet\n");
4981 static inline int update_pkg_cb(struct category *category, const char *pkgname)
4986 c_name = group_cluster_name_by_category(category);
4987 s_name = group_category_name(category);
4989 if (!c_name || !s_name || !pkgname) {
4990 ErrPrint("Name is not valid\n");
4991 return EXIT_FAILURE;
4994 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
4995 slave_rpc_request_update(pkgname, "", c_name, s_name);
4997 /* Just try to create a new package */
4998 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
5000 struct inst_info *inst;
5002 timestamp = util_timestamp();
5005 * Don't need to check the subscribed clients.
5006 * Because this callback is called by the requests of clients.
5007 * It means. some clients wants to handle this instances ;)
5009 inst = instance_create(NULL, timestamp, pkgname, DEFAULT_CONTENT, c_name, s_name, DEFAULT_PERIOD, 0, 0);
5011 ErrPrint("Failed to create a new instance\n");
5013 ErrPrint("Not enough space\n");
5015 return EXIT_SUCCESS;
5018 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
5020 struct inst_info *inst;
5021 struct client_node *client;
5022 const char *pkgname;
5026 client = client_find_by_pid(pid);
5028 ErrPrint("Cilent %d is not exists\n", pid);
5032 ret = packet_get(packet, "ss", &pkgname, &id);
5034 ErrPrint("Invalid argument\n");
5038 inst = package_find_instance_by_id(pkgname, id);
5040 } else if (package_is_fault(instance_package(inst))) {
5041 } else if (instance_client(inst) != client) {
5043 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
5047 /*! \note No reply packet */
5051 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
5053 const char *cluster_id;
5054 const char *category_id;
5055 struct client_node *client;
5057 struct cluster *cluster;
5058 struct category *category;
5059 struct context_info *info;
5060 Eina_List *info_list;
5063 client = client_find_by_pid(pid);
5065 ErrPrint("Cilent %d is not exists\n", pid);
5069 ret = packet_get(packet, "ss", &cluster_id, &category_id);
5071 ErrPrint("Invalid parameter\n");
5075 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
5077 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
5078 ErrPrint("Invalid cluster name: %s\n", cluster_id);
5082 cluster = group_find_cluster(cluster_id);
5084 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
5088 category = group_find_category(cluster, category_id);
5090 ErrPrint("Category [%s] is not registered\n", category_id);
5094 info_list = group_context_info_list(category);
5095 EINA_LIST_FOREACH(info_list, l, info) {
5096 update_pkg_cb(category, group_pkgname_from_context_info(info));
5100 /*! \note No reply packet */
5104 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
5106 const char *cluster;
5107 const char *category;
5108 struct client_node *client;
5109 struct packet *result;
5112 client = client_find_by_pid(pid);
5114 ErrPrint("Client %d is not exists\n", pid);
5115 ret = LB_STATUS_ERROR_NOT_EXIST;
5119 ret = packet_get(packet, "ss", &cluster, &category);
5121 ErrPrint("Invalid paramenters\n");
5122 ret = LB_STATUS_ERROR_INVALID;
5126 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5127 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5128 ErrPrint("Invalid cluster: %s\n", cluster);
5129 ret = LB_STATUS_ERROR_INVALID;
5136 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
5139 result = packet_create_reply(packet, "i", ret);
5141 ErrPrint("Failed to create a packet\n");
5145 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
5147 const char *cluster;
5148 const char *category;
5149 struct client_node *client;
5152 client = client_find_by_pid(pid);
5154 ErrPrint("Client %d is not exists\n", pid);
5155 ret = LB_STATUS_ERROR_NOT_EXIST;
5159 ret = packet_get(packet, "ss", &cluster, &category);
5161 ErrPrint("Invalid argument\n");
5162 ret = LB_STATUS_ERROR_INVALID;
5166 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5168 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5169 ErrPrint("Invalid cluster name: %s\n", cluster);
5175 * UNSUBSCRIBE cluster & sub-cluster for a client.
5177 ret = client_unsubscribe(client, cluster, category);
5179 package_alter_instances_to_client(client, ALTER_DESTROY);
5182 /*! \note No reply packet */
5186 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
5188 struct slave_node *slave;
5189 const char *slavename;
5192 ret = packet_get(packet, "s", &slavename);
5194 ErrPrint("Parameter is not matched\n");
5198 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
5200 slave = slave_find_by_pid(pid);
5203 char pkgname[pathconf("/", _PC_PATH_MAX)];
5206 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
5207 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
5208 slave = slave_find_by_name(slavename);
5209 pkgname[0] = '\0'; /* Reset the pkgname */
5211 slave = slave_find_by_pkgname(pkgname);
5215 abi = abi_find_by_pkgname(pkgname);
5218 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
5221 slave = slave_create(slavename, 1, abi, pkgname, 0);
5223 ErrPrint("Failed to create a new slave for %s\n", slavename);
5227 DbgPrint("New slave is created (net: 0)\n");
5229 DbgPrint("Registered slave is replaced with this new one\n");
5230 abi = slave_abi(slave);
5233 slave_set_pid(slave, pid);
5234 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
5236 ErrPrint("Slave[%d] is not exists\n", pid);
5243 * After updating handle,
5244 * slave activated callback will be called.
5246 slave_rpc_update_handle(slave, handle);
5252 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
5254 struct slave_node *slave;
5255 const char *slavename;
5258 slave = slave_find_by_pid(pid);
5260 ErrPrint("Slave %d is not exists\n", pid);
5264 ret = packet_get(packet, "s", &slavename);
5266 ErrPrint("Parameter is not matched\n");
5268 slave_rpc_ping(slave);
5274 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
5276 struct slave_node *slave;
5277 struct inst_info *inst;
5278 const char *pkgname;
5283 slave = slave_find_by_pid(pid);
5285 ErrPrint("Slave %d is not exists\n", pid);
5289 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5291 ErrPrint("Parameter is not matched\n");
5295 ret = fault_info_set(slave, pkgname, id, func);
5296 DbgPrint("Slave Faulted: %s (%d)\n", slave_name(slave), ret);
5298 inst = package_find_instance_by_id(pkgname, id);
5300 DbgPrint("There is a no such instance(%s)\n", id);
5301 } else if (instance_state(inst) == INST_DESTROYED) {
5302 ErrPrint("Instance(%s) is already destroyed\n", id);
5304 ret = instance_destroy(inst);
5305 DbgPrint("Destroy instance(%s) %d\n", id, ret);
5312 static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
5314 struct slave_node *slave;
5315 struct inst_info *inst;
5316 struct pkg_info *pkg;
5317 const char *pkgname;
5320 const char *content;
5324 slave = slave_find_by_pid(pid);
5326 ErrPrint("Slave %d is not exists\n", pid);
5330 ret = packet_get(packet, "ssdss", &pkgname, &id, &priority, &content, &title);
5332 ErrPrint("Invalid parameters\n");
5336 inst = package_find_instance_by_id(pkgname, id);
5338 ErrPrint("Instance(%s) is not exists\n", id);
5340 } else if (instance_state(inst) == INST_DESTROYED) {
5341 ErrPrint("Instance(%s) is already destroyed\n", id);
5345 pkg = instance_package(inst);
5347 ErrPrint("Invalid instance\n");
5348 } else if (package_is_fault(pkg)) {
5349 ErrPrint("Faulted instance %s.\n", id);
5350 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5351 ret = instance_lb_update_begin(inst, priority, content, title);
5352 if (ret == LB_STATUS_SUCCESS)
5353 slave_freeze_ttl(slave);
5355 ErrPrint("Invalid request[%s]\n", id);
5362 static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct packet *packet)
5364 struct slave_node *slave;
5365 struct inst_info *inst;
5366 struct pkg_info *pkg;
5367 const char *pkgname;
5371 slave = slave_find_by_pid(pid);
5373 ErrPrint("Slave %d is not exists\n", pid);
5377 ret = packet_get(packet, "ss", &pkgname, &id);
5379 ErrPrint("Invalid parameters\n");
5383 inst = package_find_instance_by_id(pkgname, id);
5385 ErrPrint("Instance[%s] is not exists\n", id);
5387 } else if (instance_state(inst) == INST_DESTROYED) {
5388 ErrPrint("Instance[%s] is already destroyed\n", id);
5392 pkg = instance_package(inst);
5394 ErrPrint("Invalid instance\n");
5395 } else if (package_is_fault(pkg)) {
5396 ErrPrint("Faulted instance %s\n", id);
5397 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5398 ret = instance_lb_update_end(inst);
5399 if (ret == LB_STATUS_SUCCESS)
5400 slave_thaw_ttl(slave);
5402 ErrPrint("Invalid request[%s]\n", id);
5409 static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
5411 struct slave_node *slave;
5412 struct pkg_info *pkg;
5413 struct inst_info *inst;
5414 const char *pkgname;
5418 slave = slave_find_by_pid(pid);
5420 ErrPrint("Slave %d is not exists\n", pid);
5424 ret = packet_get(packet, "ss", &pkgname, &id);
5426 ErrPrint("Invalid parameters\n");
5430 inst = package_find_instance_by_id(pkgname, id);
5432 ErrPrint("Instance[%s] is not exists\n", id);
5436 pkg = instance_package(inst);
5438 ErrPrint("Invalid package\n");
5439 } else if (package_is_fault(pkg)) {
5440 ErrPrint("Faulted instance %s\n", id);
5441 } else if (instance_state(inst) == INST_DESTROYED) {
5442 ErrPrint("Instance[%s] is already destroyed\n", id);
5443 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5444 (void)instance_pd_update_begin(inst);
5446 ErrPrint("Invalid request[%s]\n", id);
5453 static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
5455 struct slave_node *slave;
5456 struct pkg_info *pkg;
5457 struct inst_info *inst;
5458 const char *pkgname;
5463 slave = slave_find_by_pid(pid);
5465 ErrPrint("Slave %d is not exists\n", pid);
5469 ret = packet_get(packet, "ssi", &pkgname, &id, &status);
5471 ErrPrint("Invalid parameters\n");
5475 inst = package_find_instance_by_id(pkgname, id);
5477 ErrPrint("Instance[%s] is not exists\n", id);
5481 pkg = instance_package(inst);
5483 ErrPrint("Invalid package\n");
5484 } else if (package_is_fault(pkg)) {
5485 ErrPrint("Faulted instance %s\n", id);
5486 } else if (instance_state(inst) == INST_DESTROYED) {
5487 ErrPrint("Instance[%s] is already destroyed\n", id);
5491 * Forward packet to client
5493 (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
5500 static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
5502 struct slave_node *slave;
5503 struct pkg_info *pkg;
5504 struct inst_info *inst;
5505 const char *pkgname;
5509 slave = slave_find_by_pid(pid);
5511 ErrPrint("Slave %d is not exists\n", pid);
5515 ret = packet_get(packet, "ss", &pkgname, &id);
5517 ErrPrint("Invalid parameters\n");
5521 inst = package_find_instance_by_id(pkgname, id);
5523 ErrPrint("Instance[%s] is not exists\n", id);
5527 pkg = instance_package(inst);
5529 ErrPrint("Invalid package\n");
5530 } else if (package_is_fault(pkg)) {
5531 ErrPrint("Faulted instance %s\n", id);
5532 } else if (instance_state(inst) == INST_DESTROYED) {
5533 ErrPrint("Instance[%s] is already destroyed\n", id);
5534 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5535 (void)instance_pd_update_end(inst);
5537 ErrPrint("Invalid request[%s]\n", id);
5544 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
5546 struct slave_node *slave;
5547 const char *pkgname;
5552 slave = slave_find_by_pid(pid);
5554 ErrPrint("Slave %d is not exists\n", pid);
5558 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5560 ErrPrint("Parameter is not matched\n");
5564 ret = fault_func_call(slave, pkgname, id, func);
5565 slave_give_more_ttl(slave);
5571 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
5573 struct slave_node *slave;
5574 const char *pkgname;
5579 slave = slave_find_by_pid(pid);
5581 ErrPrint("Slave %d is not exists\n", pid);
5585 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5587 ErrPrint("Parameter is not matched\n");
5591 ret = fault_func_ret(slave, pkgname, id, func);
5592 slave_give_more_ttl(slave);
5598 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
5600 struct slave_node *slave;
5601 const char *pkgname;
5603 const char *content_info;
5609 struct inst_info *inst;
5611 slave = slave_find_by_pid(pid);
5613 ErrPrint("Slave %d is not exists\n", pid);
5617 ret = packet_get(packet, "ssiidss", &pkgname, &id,
5619 &content_info, &title);
5621 ErrPrint("Parameter is not matched\n");
5625 inst = package_find_instance_by_id(pkgname, id);
5627 } else if (package_is_fault(instance_package(inst))) {
5628 ErrPrint("Faulted instance cannot make any event.\n");
5629 } else if (instance_state(inst) == INST_DESTROYED) {
5630 ErrPrint("Instance is already destroyed\n");
5634 switch (package_lb_type(instance_package(inst))) {
5635 case LB_TYPE_SCRIPT:
5636 script_handler_resize(instance_lb_script(inst), w, h);
5637 filename = util_get_file_kept_in_safe(id);
5639 (void)script_handler_parse_desc(pkgname, id,
5643 (void)script_handler_parse_desc(pkgname, id,
5644 util_uri_to_path(id), 0);
5647 case LB_TYPE_BUFFER:
5651 * text format (inst)
5653 instance_set_lb_info(inst, w, h, priority, content_info, title);
5654 instance_lb_updated_by_instance(inst);
5658 slave_give_more_ttl(slave);
5665 static struct packet *slave_hold_scroll(pid_t pid, int handle, const struct packet *packet)
5667 struct slave_node *slave;
5668 struct inst_info *inst;
5669 const char *pkgname;
5674 slave = slave_find_by_pid(pid);
5676 ErrPrint("Slave %d is not exists\n", pid);
5680 ret = packet_get(packet, "ssi", &pkgname, &id, &seize);
5682 ErrPrint("Parameter is not matched\n");
5686 inst = package_find_instance_by_id(pkgname, id);
5688 ErrPrint("No such instance(%s)\n", id);
5689 } else if (package_is_fault(instance_package(inst))) {
5690 ErrPrint("Faulted instance cannot seize the screen\n");
5691 } else if (instance_state(inst) == INST_DESTROYED) {
5692 ErrPrint("Instance(%s) is already destroyed\n", id);
5694 (void)instance_hold_scroll(inst, seize);
5701 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
5703 struct slave_node *slave;
5704 const char *pkgname;
5706 const char *descfile;
5708 struct inst_info *inst;
5710 slave = slave_find_by_pid(pid);
5712 ErrPrint("Slave %d is not exists\n", pid);
5716 ret = packet_get(packet, "sss", &pkgname, &id, &descfile);
5718 ErrPrint("Parameter is not matched\n");
5722 inst = package_find_instance_by_id(pkgname, id);
5724 } else if (package_is_fault(instance_package(inst))) {
5725 ErrPrint("Faulted package cannot make event\n");
5726 } else if (instance_state(inst) == INST_DESTROYED) {
5727 ErrPrint("Instance is already destroyed\n");
5729 switch (package_pd_type(instance_package(inst))) {
5730 case PD_TYPE_SCRIPT:
5731 DbgPrint("Script (%s)\n", id);
5732 if (script_handler_is_loaded(instance_pd_script(inst))) {
5733 (void)script_handler_parse_desc(pkgname, id,
5738 instance_set_pd_info(inst, 0, 0);
5739 case PD_TYPE_BUFFER:
5740 instance_pd_updated(pkgname, id, descfile);
5743 DbgPrint("Ignore updated DESC(%s - %s - %s)\n",
5744 pkgname, id, descfile);
5753 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
5755 struct slave_node *slave;
5756 const char *pkgname;
5759 struct inst_info *inst;
5761 slave = slave_find_by_pid(pid);
5763 ErrPrint("Slave %d is not exists\n", pid);
5767 ret = packet_get(packet, "ss", &pkgname, &id);
5769 ErrPrint("Parameter is not matched\n");
5773 inst = package_find_instance_by_id(pkgname, id);
5775 } else if (package_is_fault(instance_package(inst))) {
5777 ret = instance_destroyed(inst);
5778 DbgPrint("Destroy instance %d\n", ret);
5786 * \note for the BUFFER Type slave
5788 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
5790 enum target_type target;
5791 const char *pkgname;
5796 struct packet *result;
5797 struct slave_node *slave;
5798 struct inst_info *inst;
5799 const struct pkg_info *pkg;
5802 slave = slave_find_by_pid(pid);
5804 ErrPrint("Failed to find a slave\n");
5806 ret = LB_STATUS_ERROR_NOT_EXIST;
5810 ret = packet_get(packet, "issiii", &target, &pkgname, &id, &w, &h, &pixel_size);
5812 ErrPrint("Invalid argument\n");
5814 ret = LB_STATUS_ERROR_INVALID;
5818 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
5819 DbgPrint("No space\n");
5820 ret = LB_STATUS_ERROR_NO_SPACE;
5826 inst = package_find_instance_by_id(pkgname, id);
5828 DbgPrint("Package[%s] Id[%s] is not found\n", pkgname, id);
5829 ret = LB_STATUS_ERROR_INVALID;
5834 pkg = instance_package(inst);
5836 ret = LB_STATUS_ERROR_INVALID;
5837 if (target == TYPE_LB) {
5838 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5839 struct buffer_info *info;
5841 info = instance_lb_buffer(inst);
5843 if (!instance_create_lb_buffer(inst)) {
5844 ErrPrint("Failed to create a LB buffer\n");
5846 info = instance_lb_buffer(inst);
5848 ErrPrint("LB buffer is not valid\n");
5849 ret = LB_STATUS_ERROR_INVALID;
5856 ret = buffer_handler_resize(info, w, h);
5857 DbgPrint("Buffer resize returns %d\n", ret);
5859 ret = buffer_handler_load(info);
5861 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
5862 id = buffer_handler_id(info);
5863 DbgPrint("Buffer handler ID: %s\n", id);
5865 DbgPrint("Failed to load a buffer(%d)\n", ret);
5868 } else if (target == TYPE_PD) {
5869 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5870 struct buffer_info *info;
5872 DbgPrint("Slave acquire buffer for PD\n");
5874 info = instance_pd_buffer(inst);
5876 if (!instance_create_pd_buffer(inst)) {
5877 ErrPrint("Failed to create a PD buffer\n");
5879 info = instance_pd_buffer(inst);
5881 ErrPrint("PD buffer is not valid\n");
5882 ret = LB_STATUS_ERROR_INVALID;
5884 instance_client_pd_created(inst, ret);
5890 ret = buffer_handler_resize(info, w, h);
5891 DbgPrint("Buffer resize returns %d\n", ret);
5893 ret = buffer_handler_load(info);
5895 instance_set_pd_info(inst, w, h);
5896 id = buffer_handler_id(info);
5897 DbgPrint("Buffer handler ID: %s\n", id);
5899 DbgPrint("Failed to load a buffer (%d)\n", ret);
5903 * Send the PD created event to the client
5905 instance_client_pd_created(inst, ret);
5910 result = packet_create_reply(packet, "is", ret, id);
5912 ErrPrint("Failed to create a packet\n");
5917 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
5919 struct slave_node *slave;
5920 struct packet *result;
5921 enum target_type type;
5922 const char *pkgname;
5926 struct inst_info *inst;
5927 const struct pkg_info *pkg;
5930 slave = slave_find_by_pid(pid);
5932 ErrPrint("Failed to find a slave\n");
5933 ret = LB_STATUS_ERROR_NOT_EXIST;
5938 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
5939 ErrPrint("Not enough space\n");
5940 ret = LB_STATUS_ERROR_NO_SPACE;
5945 ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
5947 ErrPrint("Invalid argument\n");
5948 ret = LB_STATUS_ERROR_INVALID;
5953 inst = package_find_instance_by_id(pkgname, id);
5955 DbgPrint("Instance is not found[%s] [%s]\n", pkgname, id);
5956 ret = LB_STATUS_ERROR_NOT_EXIST;
5961 pkg = instance_package(inst);
5965 * THIS statement should not be entered.
5967 ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
5968 ret = LB_STATUS_ERROR_FAULT;
5973 ret = LB_STATUS_ERROR_INVALID;
5976 * Reset "id", It will be re-used from here
5979 if (type == TYPE_LB) {
5980 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5981 struct buffer_info *info;
5983 info = instance_lb_buffer(inst);
5985 ret = buffer_handler_resize(info, w, h);
5988 * id is resued for newly assigned ID
5991 id = buffer_handler_id(info);
5992 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
5996 } else if (type == TYPE_PD) {
5997 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5998 struct buffer_info *info;
6000 info = instance_pd_buffer(inst);
6002 ret = buffer_handler_resize(info, w, h);
6005 * id is resued for newly assigned ID
6008 id = buffer_handler_id(info);
6009 instance_set_pd_info(inst, w, h);
6016 result = packet_create_reply(packet, "is", ret, id);
6018 ErrPrint("Failed to create a packet\n");
6023 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
6025 enum target_type type;
6026 const char *pkgname;
6028 struct packet *result;
6029 struct slave_node *slave;
6030 struct inst_info *inst;
6033 slave = slave_find_by_pid(pid);
6035 ErrPrint("Failed to find a slave\n");
6036 ret = LB_STATUS_ERROR_NOT_EXIST;
6040 if (packet_get(packet, "iss", &type, &pkgname, &id) != 3) {
6041 ErrPrint("Inavlid argument\n");
6042 ret = LB_STATUS_ERROR_INVALID;
6046 inst = package_find_instance_by_id(pkgname, id);
6048 ErrPrint("Instance is not found [%s - %s]\n", pkgname, id);
6049 ret = LB_STATUS_ERROR_NOT_EXIST;
6053 ret = LB_STATUS_ERROR_INVALID;
6054 if (type == TYPE_LB) {
6055 struct buffer_info *info;
6057 info = instance_lb_buffer(inst);
6058 ret = buffer_handler_unload(info);
6059 } else if (type == TYPE_PD) {
6060 struct buffer_info *info;
6062 DbgPrint("Slave release buffer for PD\n");
6064 info = instance_pd_buffer(inst);
6065 ret = buffer_handler_unload(info);
6069 * Send the PD destroyed event to the client
6071 instance_client_pd_destroyed(inst, ret);
6075 result = packet_create_reply(packet, "i", ret);
6077 ErrPrint("Failed to create a packet\n");
6082 static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
6084 struct inst_info *inst;
6085 struct packet *result;
6086 const char *pkgname;
6091 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
6093 ErrPrint("Invalid packet\n");
6094 ret = LB_STATUS_ERROR_INVALID;
6099 struct pkg_info *pkg;
6101 pkg = package_find(pkgname);
6103 ret = LB_STATUS_ERROR_NOT_EXIST;
6104 } else if (package_is_fault(pkg)) {
6105 ret = LB_STATUS_ERROR_FAULT;
6107 Eina_List *inst_list;
6110 inst_list = package_instance_list(pkg);
6111 EINA_LIST_FOREACH(inst_list, l, inst) {
6112 ret = instance_set_period(inst, period);
6114 DbgPrint("Failed to change the period of %s to (%lf)\n", instance_id(inst), period);
6118 inst = package_find_instance_by_id(pkgname, id);
6120 ret = LB_STATUS_ERROR_NOT_EXIST;
6121 else if (package_is_fault(instance_package(inst)))
6122 ret = LB_STATUS_ERROR_FAULT;
6124 ret = instance_set_period(inst, period);
6127 DbgPrint("Change the update period: %s(%s), %lf : %d\n", pkgname, id, period, ret);
6129 result = packet_create_reply(packet, "i", ret);
6131 ErrPrint("Failed to create a packet\n");
6136 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
6138 struct pkg_info *pkg;
6139 struct packet *result;
6140 const char *pkgname;
6142 const char *cluster;
6143 const char *category;
6147 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
6149 ErrPrint("Invalid Packet\n");
6150 ret = LB_STATUS_ERROR_INVALID;
6154 lb_pkgname = package_lb_pkgname(pkgname);
6156 ErrPrint("Invalid package %s\n", pkgname);
6157 ret = LB_STATUS_ERROR_INVALID;
6161 pkg = package_find(lb_pkgname);
6163 ret = LB_STATUS_ERROR_NOT_EXIST;
6167 if (package_is_fault(pkg)) {
6168 ret = LB_STATUS_ERROR_FAULT;
6174 * Validate the update requstor.
6176 slave_rpc_request_update(lb_pkgname, id, cluster, category);
6177 DbgFree(lb_pkgname);
6181 result = packet_create_reply(packet, "i", ret);
6183 ErrPrint("Failed to create a packet\n");
6188 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
6190 struct liveinfo *info;
6191 struct packet *result;
6193 const char *fifo_name;
6196 DbgPrint("Request arrived from %d\n", pid);
6198 if (packet_get(packet, "d", ×tamp) != 1) {
6199 ErrPrint("Invalid packet\n");
6201 ret = LB_STATUS_ERROR_INVALID;
6205 info = liveinfo_create(pid, handle);
6207 ErrPrint("Failed to create a liveinfo object\n");
6209 ret = LB_STATUS_ERROR_INVALID;
6214 fifo_name = liveinfo_filename(info);
6215 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
6218 result = packet_create_reply(packet, "si", fifo_name, ret);
6220 ErrPrint("Failed to create a result packet\n");
6225 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
6229 struct liveinfo *info;
6230 struct slave_node *slave;
6234 if (packet_get(packet, "d", ×tamp) != 1) {
6235 ErrPrint("Invalid argument\n");
6239 info = liveinfo_find_by_pid(pid);
6241 ErrPrint("Invalid request\n");
6245 liveinfo_open_fifo(info);
6246 fp = liveinfo_fifo(info);
6248 liveinfo_close_fifo(info);
6252 list = (Eina_List *)slave_list();
6253 EINA_LIST_FOREACH(list, l, slave) {
6254 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
6257 slave_pkgname(slave),
6259 slave_is_secured(slave),
6260 slave_refcnt(slave),
6261 slave_fault_count(slave),
6262 slave_state_string(slave),
6263 slave_loaded_instance(slave),
6264 slave_loaded_package(slave),
6269 fprintf(fp, "EOD\n");
6270 liveinfo_close_fifo(info);
6275 static inline const char *visible_state_string(enum livebox_visible_state state)
6282 case LB_HIDE_WITH_PAUSE:
6291 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
6293 const char *pkgname;
6294 struct liveinfo *info;
6295 struct pkg_info *pkg;
6297 Eina_List *inst_list;
6298 struct inst_info *inst;
6301 if (packet_get(packet, "s", &pkgname) != 1) {
6302 ErrPrint("Invalid argument\n");
6306 info = liveinfo_find_by_pid(pid);
6308 ErrPrint("Invalid request\n");
6312 liveinfo_open_fifo(info);
6313 fp = liveinfo_fifo(info);
6315 ErrPrint("Invalid fp\n");
6316 liveinfo_close_fifo(info);
6320 if (!package_is_lb_pkgname(pkgname)) {
6321 ErrPrint("Invalid package name\n");
6325 pkg = package_find(pkgname);
6327 ErrPrint("Package is not exists\n");
6331 inst_list = package_instance_list(pkg);
6332 EINA_LIST_FOREACH(inst_list, l, inst) {
6333 fprintf(fp, "%s %s %s %lf %s %d %d\n",
6335 instance_cluster(inst),
6336 instance_category(inst),
6337 instance_period(inst),
6338 visible_state_string(instance_visible_state(inst)),
6339 instance_lb_width(inst),
6340 instance_lb_height(inst));
6344 fprintf(fp, "EOD\n");
6345 liveinfo_close_fifo(info);
6351 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
6355 Eina_List *inst_list;
6356 struct liveinfo *info;
6357 struct pkg_info *pkg;
6358 struct slave_node *slave;
6360 const char *slavename;
6363 if (packet_get(packet, "d", ×tamp) != 1) {
6364 ErrPrint("Invalid argument\n");
6368 info = liveinfo_find_by_pid(pid);
6370 ErrPrint("Invalid request\n");
6374 liveinfo_open_fifo(info);
6375 fp = liveinfo_fifo(info);
6377 liveinfo_close_fifo(info);
6381 list = (Eina_List *)package_list();
6382 EINA_LIST_FOREACH(list, l, pkg) {
6383 slave = package_slave(pkg);
6386 slavename = slave_name(slave);
6387 pid = slave_pid(slave);
6393 inst_list = (Eina_List *)package_instance_list(pkg);
6394 fprintf(fp, "%d %s %s %s %d %d %d\n",
6396 strlen(slavename) ? slavename : "(none)",
6399 package_refcnt(pkg),
6400 package_fault_count(pkg),
6401 eina_list_count(inst_list)
6405 fprintf(fp, "EOD\n");
6406 liveinfo_close_fifo(info);
6411 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
6416 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
6418 struct liveinfo *info;
6424 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
6425 ErrPrint("Invalid argument\n");
6429 info = liveinfo_find_by_pid(pid);
6431 ErrPrint("Invalid request\n");
6435 liveinfo_open_fifo(info);
6436 fp = liveinfo_fifo(info);
6438 liveinfo_close_fifo(info);
6442 if (!strcmp(cmd, "rmpack")) {
6443 fprintf(fp, "%d\n", ENOSYS);
6444 } else if (!strcmp(cmd, "rminst")) {
6445 struct inst_info *inst;
6446 inst = package_find_instance_by_id(pkgname, id);
6448 fprintf(fp, "%d\n", ENOENT);
6450 instance_destroy(inst);
6451 fprintf(fp, "%d\n", 0);
6455 fprintf(fp, "EOD\n");
6456 liveinfo_close_fifo(info);
6462 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
6464 struct liveinfo *info;
6469 int ret = LB_STATUS_ERROR_INVALID;
6471 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
6472 ErrPrint("Invalid argument\n");
6476 info = liveinfo_find_by_pid(pid);
6478 ErrPrint("Invalid request\n");
6482 if (!strcasecmp(var, "debug")) {
6483 if (!strcasecmp(cmd, "set")) {
6484 g_conf.debug_mode = !strcasecmp(val, "on");
6485 } else if (!strcasecmp(cmd, "get")) {
6487 ret = g_conf.debug_mode;
6488 } else if (!strcasecmp(var, "slave_max_load")) {
6489 if (!strcasecmp(cmd, "set")) {
6490 g_conf.slave_max_load = atoi(val);
6491 } else if (!strcasecmp(cmd, "get")) {
6493 ret = g_conf.slave_max_load;
6496 liveinfo_open_fifo(info);
6497 fp = liveinfo_fifo(info);
6499 liveinfo_close_fifo(info);
6502 fprintf(fp, "%d\nEOD\n", ret);
6503 liveinfo_close_fifo(info);
6509 static struct method s_info_table[] = {
6511 .cmd = "liveinfo_hello",
6512 .handler = liveinfo_hello,
6515 .cmd = "slave_list",
6516 .handler = liveinfo_slave_list,
6520 .handler = liveinfo_pkg_list,
6524 .handler = liveinfo_inst_list,
6527 .cmd = "slave_ctrl",
6528 .handler = liveinfo_slave_ctrl,
6532 .handler = liveinfo_pkg_ctrl,
6535 .cmd = "master_ctrl",
6536 .handler = liveinfo_master_ctrl,
6544 static struct method s_client_table[] = {
6546 .cmd = "pd_mouse_move",
6547 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6550 .cmd = "lb_mouse_move",
6551 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6554 .cmd = "pd_mouse_down",
6555 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6558 .cmd = "pd_mouse_up",
6559 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6562 .cmd = "lb_mouse_down",
6563 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6566 .cmd = "lb_mouse_up",
6567 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6570 .cmd = "pd_mouse_enter",
6571 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6574 .cmd = "pd_mouse_leave",
6575 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6578 .cmd = "lb_mouse_enter",
6579 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6582 .cmd = "lb_mouse_leave",
6583 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6586 .cmd = "lb_mouse_set",
6587 .handler = client_lb_mouse_set,
6590 .cmd = "lb_mouse_unset",
6591 .handler = client_lb_mouse_unset,
6594 .cmd = "pd_mouse_set",
6595 .handler = client_pd_mouse_set,
6598 .cmd = "pd_mouse_unset",
6599 .handler = client_pd_mouse_unset,
6602 .cmd = "change,visibility",
6603 .handler = client_change_visibility,
6606 .cmd = "lb_acquire_pixmap",
6607 .handler = client_lb_acquire_pixmap,
6610 .cmd = "lb_release_pixmap",
6611 .handler = client_lb_release_pixmap,
6614 .cmd = "pd_acquire_pixmap",
6615 .handler = client_pd_acquire_pixmap,
6618 .cmd = "pd_release_pixmap",
6619 .handler = client_pd_release_pixmap,
6623 .handler = client_acquire, /*!< pid, ret */
6627 .handler = cilent_release, /*!< pid, ret */
6631 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
6634 .cmd = "text_signal",
6635 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
6639 .handler = client_delete, /* pid, pkgname, filename, ret */
6643 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
6647 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
6650 .cmd = "set_period",
6651 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
6654 .cmd = "change_group",
6655 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
6658 .cmd = "pinup_changed",
6659 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
6663 .handler = client_create_pd, /* pid, pkgname, filename, ret */
6667 .handler = client_pd_move, /* pkgname, id, x, y */
6670 .cmd = "destroy_pd",
6671 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
6674 .cmd = "activate_package",
6675 .handler = client_activate_package, /* pid, pkgname, ret */
6678 .cmd = "subscribe", /* pid, cluster, sub-cluster */
6679 .handler = client_subscribed,
6682 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
6683 .handler = client_unsubscribed,
6686 .cmd = "delete_cluster",
6687 .handler = client_delete_cluster,
6690 .cmd = "delete_category",
6691 .handler = client_delete_category,
6694 .cmd = "refresh_group",
6695 .handler = client_refresh_group,
6699 .handler = client_update,
6703 .cmd = "pd_access_hl",
6704 .handler = client_pd_access_hl,
6707 .cmd = "pd_access_hl_prev",
6708 .handler = client_pd_access_hl_prev,
6711 .cmd = "pd_access_hl_next",
6712 .handler = client_pd_access_hl_next,
6715 .cmd = "pd_access_activate",
6716 .handler = client_pd_access_activate,
6719 .cmd = "pd_access_value_change",
6720 .handler = client_pd_access_value_change,
6723 .cmd = "pd_access_scroll",
6724 .handler = client_pd_access_scroll,
6728 .cmd = "lb_access_hl",
6729 .handler = client_lb_access_hl,
6732 .cmd = "lb_access_hl_prev",
6733 .handler = client_lb_access_hl_prev,
6736 .cmd = "lb_access_hl_next",
6737 .handler = client_lb_access_hl_next,
6740 .cmd = "lb_access_activate",
6741 .handler = client_lb_access_activate,
6744 .cmd = "lb_access_value_change",
6745 .handler = client_lb_access_value_change,
6748 .cmd = "lb_access_scroll",
6749 .handler = client_lb_access_scroll,
6753 .cmd = "lb_key_down",
6754 .handler = client_lb_key_down,
6758 .handler = client_lb_key_up,
6762 .cmd = "pd_key_down",
6763 .handler = client_pd_key_down,
6767 .handler = client_pd_key_up,
6771 .cmd = "client_paused",
6772 .handler = client_pause_request,
6775 .cmd = "client_resumed",
6776 .handler = client_resume_request,
6780 .cmd = "update_mode",
6781 .handler = client_update_mode,
6790 static struct method s_service_table[] = {
6792 .cmd = "service_update",
6793 .handler = service_update,
6796 .cmd = "service_change_period",
6797 .handler = service_change_period,
6805 static struct method s_slave_table[] = {
6808 .handler = slave_hello, /* slave_name, ret */
6812 .handler = slave_ping, /* slave_name, ret */
6816 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
6820 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
6824 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
6827 .cmd = "desc_updated",
6828 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
6832 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
6835 .cmd = "acquire_buffer",
6836 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
6839 .cmd = "resize_buffer",
6840 .handler = slave_resize_buffer,
6843 .cmd = "release_buffer",
6844 .handler = slave_release_buffer, /* slave_name, id - ret */
6848 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
6852 .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
6856 .cmd = "lb_update_begin",
6857 .handler = slave_lb_update_begin,
6860 .cmd = "lb_update_end",
6861 .handler = slave_lb_update_end,
6864 .cmd = "pd_update_begin",
6865 .handler = slave_pd_update_begin,
6868 .cmd = "pd_update_end",
6869 .handler = slave_pd_update_end,
6873 .cmd = "access_status",
6874 .handler = slave_access_status,
6883 HAPI int server_init(void)
6885 com_core_packet_use_thread(COM_CORE_THREAD);
6887 if (unlink(INFO_SOCKET) < 0)
6888 ErrPrint("info socket: %s\n", strerror(errno));
6890 if (unlink(SLAVE_SOCKET) < 0)
6891 ErrPrint("slave socket: %s\n", strerror(errno));
6893 if (unlink(CLIENT_SOCKET) < 0)
6894 ErrPrint("client socket: %s\n", strerror(errno));
6896 if (unlink(SERVICE_SOCKET) < 0)
6897 ErrPrint("service socket: %s\n", strerror(errno));
6899 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
6900 if (s_info.info_fd < 0)
6901 ErrPrint("Failed to create a info socket\n");
6903 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
6904 if (s_info.slave_fd < 0)
6905 ErrPrint("Failed to create a slave socket\n");
6907 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
6908 if (s_info.client_fd < 0)
6909 ErrPrint("Failed to create a client socket\n");
6911 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
6912 if (s_info.service_fd < 0)
6913 ErrPrint("Faild to create a service socket\n");
6915 if (chmod(INFO_SOCKET, 0600) < 0)
6916 ErrPrint("info socket: %s\n", strerror(errno));
6918 if (chmod(SLAVE_SOCKET, 0666) < 0)
6919 ErrPrint("slave socket: %s\n", strerror(errno));
6921 if (chmod(CLIENT_SOCKET, 0666) < 0)
6922 ErrPrint("client socket: %s\n", strerror(errno));
6924 if (chmod(SERVICE_SOCKET, 0666) < 0)
6925 ErrPrint("service socket: %s\n", strerror(errno));
6930 HAPI int server_fini(void)
6932 if (s_info.info_fd > 0) {
6933 com_core_packet_server_fini(s_info.info_fd);
6934 s_info.info_fd = -1;
6937 if (s_info.slave_fd > 0) {
6938 com_core_packet_server_fini(s_info.slave_fd);
6939 s_info.slave_fd = -1;
6942 if (s_info.client_fd > 0) {
6943 com_core_packet_server_fini(s_info.client_fd);
6944 s_info.client_fd = -1;
6947 if (s_info.service_fd > 0) {
6948 com_core_packet_server_fini(s_info.service_fd);
6949 s_info.service_fd = -1;