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 DbgPrint("Skip sending access status (%d)\n", cbdata->status);
92 * If instance_unref returns NULL,
93 * The instance is destroyed. it means, we don't need to send event to the viewer
96 return ECORE_CALLBACK_CANCEL;
99 static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
101 struct inst_info *inst = data;
102 const struct pkg_info *pkg;
103 struct slave_node *slave;
104 struct packet *packet;
107 pkg = instance_package(inst);
109 return LB_STATUS_ERROR_INVALID;
111 slave = package_slave(pkg);
113 return LB_STATUS_ERROR_INVALID;
116 case EVENT_STATE_ACTIVATE:
117 cmdstr = "lb_mouse_down";
119 case EVENT_STATE_ACTIVATED:
120 cmdstr = "lb_mouse_move";
122 case EVENT_STATE_DEACTIVATE:
123 cmdstr = "lb_mouse_up";
126 return LB_STATUS_ERROR_INVALID;
129 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
131 return LB_STATUS_ERROR_FAULT;
133 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
136 static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
138 struct script_info *script;
139 struct inst_info *inst = data;
140 const struct pkg_info *pkg;
144 pkg = instance_package(inst);
148 script = instance_lb_script(inst);
150 return LB_STATUS_ERROR_FAULT;
152 e = script_handler_evas(script);
154 return LB_STATUS_ERROR_FAULT;
156 timestamp = util_timestamp();
159 case EVENT_STATE_ACTIVATE:
160 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
161 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
163 case EVENT_STATE_ACTIVATED:
164 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
165 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
167 case EVENT_STATE_DEACTIVATE:
168 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
169 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
178 static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
180 struct inst_info *inst = data;
181 const struct pkg_info *pkg;
182 struct slave_node *slave;
183 struct packet *packet;
186 pkg = instance_package(inst);
188 return LB_STATUS_ERROR_INVALID;
190 slave = package_slave(pkg);
192 return LB_STATUS_ERROR_INVALID;
194 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
196 case EVENT_STATE_ACTIVATE:
197 cmdstr = "pd_mouse_down";
199 case EVENT_STATE_ACTIVATED:
200 cmdstr = "pd_mouse_move";
202 case EVENT_STATE_DEACTIVATE:
203 cmdstr = "pd_mouse_up";
206 return LB_STATUS_ERROR_INVALID;
209 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
211 return LB_STATUS_ERROR_FAULT;
213 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
216 static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
218 struct script_info *script;
219 struct inst_info *inst = data;
220 const struct pkg_info *pkg;
224 pkg = instance_package(inst);
228 script = instance_pd_script(inst);
230 return LB_STATUS_ERROR_FAULT;
232 e = script_handler_evas(script);
234 return LB_STATUS_ERROR_FAULT;
236 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
237 timestamp = util_timestamp();
240 case EVENT_STATE_ACTIVATE:
241 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
242 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
244 case EVENT_STATE_ACTIVATED:
245 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
246 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
248 case EVENT_STATE_DEACTIVATE:
249 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
250 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
258 static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
260 struct client_node *client;
261 struct packet *result;
265 client = client_find_by_pid(pid);
267 ErrPrint("Client is already exists %d\n", pid);
268 ret = LB_STATUS_ERROR_EXIST;
272 if (packet_get(packet, "d", ×tamp) != 1) {
273 ErrPrint("Invalid arguemnt\n");
274 ret = LB_STATUS_ERROR_INVALID;
281 * client_create will invoke the client created callback
283 client = client_create(pid, handle);
285 ErrPrint("Failed to create a new client for %d\n", pid);
286 ret = LB_STATUS_ERROR_FAULT;
290 result = packet_create_reply(packet, "i", ret);
292 ErrPrint("Failed to create a packet\n");
297 static struct packet *cilent_release(pid_t pid, int handle, const struct packet *packet) /*!< pid, ret */
299 struct client_node *client;
300 struct packet *result;
303 client = client_find_by_pid(pid);
305 ErrPrint("Client %d is not exists\n", pid);
306 ret = LB_STATUS_ERROR_NOT_EXIST;
310 client_destroy(client);
314 result = packet_create_reply(packet, "i", ret);
316 ErrPrint("Failed to create a packet\n");
321 /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
322 static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
324 struct client_node *client;
332 struct inst_info *inst;
334 client = client_find_by_pid(pid);
336 ErrPrint("Client %d is not exists\n", pid);
340 ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
342 ErrPrint("Parameter is not matched\n");
346 DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%lf] y[%lf]\n", pid, pkgname, id, event, timestamp, x, y);
350 * Trust the package name which are sent by the client.
351 * The package has to be a livebox package name.
353 inst = package_find_instance_by_id(pkgname, id);
355 ErrPrint("Instance is not exists\n");
356 else if (package_is_fault(instance_package(inst)))
357 ErrPrint("Fault package\n");
359 (void)instance_clicked(inst, event, timestamp, x, y);
362 /*! \note No reply packet */
366 static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet)
368 struct packet *result;
369 struct client_node *client;
374 struct inst_info *inst;
376 client = client_find_by_pid(pid);
378 ErrPrint("Client %d is not exists\n", pid);
379 ret = LB_STATUS_ERROR_INVALID;
383 ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
385 ErrPrint("Invalid argument\n");
386 ret = LB_STATUS_ERROR_INVALID;
390 inst = package_find_instance_by_id(pkgname, id);
392 ErrPrint("Instance is not exists\n");
393 ret = LB_STATUS_ERROR_NOT_EXIST;
394 } else if (package_is_fault(instance_package(inst))) {
395 ErrPrint("Fault package\n");
396 ret = LB_STATUS_ERROR_FAULT;
400 * Send change update mode request to a slave
402 ret = instance_set_update_mode(inst, active_update);
406 result = packet_create_reply(packet, "i", ret);
408 ErrPrint("Failed to create a packet\n");
413 /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
414 static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
416 struct client_node *client;
417 struct packet *result;
420 const char *emission;
426 struct inst_info *inst;
429 client = client_find_by_pid(pid);
431 ErrPrint("Client %d is not exists\n", pid);
432 ret = LB_STATUS_ERROR_NOT_EXIST;
436 ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
438 ErrPrint("Parameter is not matched\n");
439 ret = LB_STATUS_ERROR_INVALID;
443 DbgPrint("pid[%d] pkgname[%s] id[%s] emission[%s] source[%s] sx[%lf] sy[%lf] ex[%lf] ey[%lf]\n", pid, pkgname, id, emission, source, sx, sy, ex, ey);
447 * Trust the package name which are sent by the client.
448 * The package has to be a livebox package name.
450 inst = package_find_instance_by_id(pkgname, id);
452 ret = LB_STATUS_ERROR_NOT_EXIST;
453 else if (package_is_fault(instance_package(inst)))
454 ret = LB_STATUS_ERROR_FAULT;
456 ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
459 result = packet_create_reply(packet, "i", ret);
461 ErrPrint("Failed to create a packet\n");
466 static Eina_Bool lazy_delete_cb(void *data)
468 struct deleted_item *item = data;
470 DbgPrint("Send delete event to the client\n");
473 * Before invoke this callback, the instance is able to already remove this client
476 if (instance_has_client(item->inst, item->client)) {
477 instance_unicast_deleted_event(item->inst, item->client);
478 instance_del_client(item->inst, item->client);
481 client_unref(item->client);
482 instance_unref(item->inst);
484 return ECORE_CALLBACK_CANCEL;
487 static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
489 struct client_node *client;
490 struct packet *result;
493 struct inst_info *inst;
496 client = client_find_by_pid(pid);
498 ErrPrint("Client %d is not exists\n", pid);
499 ret = LB_STATUS_ERROR_NOT_EXIST;
503 ret = packet_get(packet, "ss", &pkgname, &id);
505 ErrPrint("Parameter is not matched\n");
506 ret = LB_STATUS_ERROR_INVALID;
510 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
514 * Trust the package name which are sent by the client.
515 * The package has to be a livebox package name.
517 inst = package_find_instance_by_id(pkgname, id);
519 ret = LB_STATUS_ERROR_NOT_EXIST;
520 } else if (package_is_fault(instance_package(inst))) {
521 ret = LB_STATUS_ERROR_FAULT;
522 } else if (instance_client(inst) != client) {
523 if (instance_has_client(inst, client)) {
524 struct deleted_item *item;
526 item = malloc(sizeof(*item));
528 ErrPrint("Heap: %s\n", strerror(errno));
529 ret = LB_STATUS_ERROR_MEMORY;
533 * Send DELETED EVENT to the client.
534 * after return from this function.
536 * Client will prepare the deleted event after get this function's return value.
537 * So We have to make a delay to send a deleted event.
540 item->client = client_ref(client);
541 item->inst = instance_ref(inst);
543 if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
544 ErrPrint("Failed to add a delayzed delete callback\n");
545 client_unref(client);
546 instance_unref(inst);
548 ret = LB_STATUS_ERROR_FAULT;
550 ret = LB_STATUS_SUCCESS;
554 ret = LB_STATUS_ERROR_PERMISSION;
557 ret = instance_destroy(inst);
561 result = packet_create_reply(packet, "i", ret);
563 ErrPrint("Failed to create a packet\n");
568 static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
570 struct client_node *client;
571 struct packet *result;
576 struct inst_info *inst;
579 client = client_find_by_pid(pid);
581 ErrPrint("Client %d is not exists\n", pid);
582 ret = LB_STATUS_ERROR_NOT_EXIST;
586 ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
588 ErrPrint("Parameter is not matched\n");
589 ret = LB_STATUS_ERROR_INVALID;
593 DbgPrint("pid[%d] pkgname[%s] id[%s] w[%d] h[%d]\n", pid, pkgname, id, w, h);
594 DbgPrint("RESIZE: INSTANCE[%s] Client request resize to %dx%d\n", id, w, h);
598 * Trust the package name which are sent by the client.
599 * The package has to be a livebox package name.
601 inst = package_find_instance_by_id(pkgname, id);
603 ret = LB_STATUS_ERROR_NOT_EXIST;
604 } else if (package_is_fault(instance_package(inst))) {
605 ret = LB_STATUS_ERROR_FAULT;
606 } else if (instance_client(inst) != client) {
607 ret = LB_STATUS_ERROR_PERMISSION;
609 ret = instance_resize(inst, w, h);
613 result = packet_create_reply(packet, "i", ret);
615 ErrPrint("Failed to create a packet\n");
620 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
622 struct client_node *client;
623 struct packet *result;
627 const char *category;
631 struct pkg_info *info;
636 client = client_find_by_pid(pid);
638 ErrPrint("Client %d is not exists\n", pid);
639 ret = LB_STATUS_ERROR_NOT_EXIST;
643 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
645 ErrPrint("Parameter is not matched\n");
646 ret = LB_STATUS_ERROR_INVALID;
650 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
651 pid, timestamp, pkgname, content, cluster, category, period);
653 lb_pkgname = package_lb_pkgname(pkgname);
655 ErrPrint("This %s has no livebox package\n", pkgname);
656 ret = LB_STATUS_ERROR_INVALID;
660 info = package_find(lb_pkgname);
662 info = package_create(lb_pkgname);
665 ret = LB_STATUS_ERROR_FAULT;
666 } else if (package_is_fault(info)) {
667 ret = LB_STATUS_ERROR_FAULT;
668 } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
669 ErrPrint("Not enough space\n");
670 ret = LB_STATUS_ERROR_NO_SPACE;
672 struct inst_info *inst;
674 if (period > 0.0f && period < MINIMUM_PERIOD)
675 period = MINIMUM_PERIOD;
677 if (!strlen(content))
678 content = DEFAULT_CONTENT;
680 inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
683 * Using the "inst" without validate its value is at my disposal. ;)
685 ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
691 result = packet_create_reply(packet, "i", ret);
693 ErrPrint("Failed to create a packet\n");
698 static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
700 struct client_node *client;
703 enum livebox_visible_state state;
705 struct inst_info *inst;
707 client = client_find_by_pid(pid);
709 ErrPrint("Client %d is not exists\n", pid);
710 ret = LB_STATUS_ERROR_NOT_EXIST;
714 ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
716 ErrPrint("Parameter is not matched\n");
717 ret = LB_STATUS_ERROR_INVALID;
721 DbgPrint("pid[%d] pkgname[%s] id[%s] state[%d]\n", pid, pkgname, id, state);
725 * Trust the package name which are sent by the client.
726 * The package has to be a livebox package name.
728 inst = package_find_instance_by_id(pkgname, id);
730 ret = LB_STATUS_ERROR_NOT_EXIST;
731 } else if (package_is_fault(instance_package(inst))) {
732 ret = LB_STATUS_ERROR_FAULT;
733 } else if (instance_client(inst) != client) {
734 ret = LB_STATUS_ERROR_PERMISSION;
736 ret = instance_set_visible_state(inst, state);
740 /*! \note No reply packet */
744 static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
746 struct client_node *client;
747 struct packet *result;
752 struct inst_info *inst;
754 client = client_find_by_pid(pid);
756 ErrPrint("Client %d is not exists\n", pid);
757 ret = LB_STATUS_ERROR_NOT_EXIST;
761 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
763 ErrPrint("Parameter is not matched\n");
764 ret = LB_STATUS_ERROR_INVALID;
768 DbgPrint("pid[%d] pkgname[%s] id[%s] period[%lf]\n", pid, pkgname, id, period);
772 * Trust the package name which are sent by the client.
773 * The package has to be a livebox package name.
775 inst = package_find_instance_by_id(pkgname, id);
777 ret = LB_STATUS_ERROR_NOT_EXIST;
778 } else if (package_is_fault(instance_package(inst))) {
779 ret = LB_STATUS_ERROR_FAULT;
780 } else if (instance_client(inst) != client) {
781 ret = LB_STATUS_ERROR_PERMISSION;
783 ret = instance_set_period(inst, period);
787 result = packet_create_reply(packet, "i", ret);
789 ErrPrint("Failed to create a packet\n");
794 static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
796 struct client_node *client;
797 struct packet *result;
801 const char *category;
802 struct inst_info *inst;
805 client = client_find_by_pid(pid);
807 ErrPrint("Client %d is not exists\n", pid);
808 ret = LB_STATUS_ERROR_NOT_EXIST;
812 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
814 ErrPrint("Parameter is not matched\n");
815 ret = LB_STATUS_ERROR_INVALID;
819 DbgPrint("pid[%d] pkgname[%s] id[%s] cluster[%s] category[%s]\n", pid, pkgname, id, cluster, category);
823 * Trust the package name which are sent by the client.
824 * The package has to be a livebox package name.
826 inst = package_find_instance_by_id(pkgname, id);
828 ret = LB_STATUS_ERROR_NOT_EXIST;
829 } else if (package_is_fault(instance_package(inst))) {
830 ret = LB_STATUS_ERROR_FAULT;
831 } else if (instance_client(inst) != client) {
832 ret = LB_STATUS_ERROR_PERMISSION;
834 ret = instance_change_group(inst, cluster, category);
838 result = packet_create_reply(packet, "i", ret);
840 ErrPrint("Failed to create a packet\n");
845 static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
847 struct client_node *client;
854 struct inst_info *inst;
855 const struct pkg_info *pkg;
857 client = client_find_by_pid(pid);
859 ErrPrint("Client %d is not exists\n", pid);
860 ret = LB_STATUS_ERROR_NOT_EXIST;
864 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
866 ErrPrint("Invalid parameter\n");
867 ret = LB_STATUS_ERROR_INVALID;
873 * Trust the package name which are sent by the client.
874 * The package has to be a livebox package name.
876 inst = package_find_instance_by_id(pkgname, id);
878 ErrPrint("Instance[%s] is not exists\n", id);
879 ret = LB_STATUS_ERROR_NOT_EXIST;
883 pkg = instance_package(inst);
885 ErrPrint("Package[%s] info is not found\n", pkgname);
886 ret = LB_STATUS_ERROR_FAULT;
890 if (package_is_fault(pkg)) {
893 * If the package is registered as fault module,
894 * slave has not load it, so we don't need to do anything at here!
896 DbgPrint("Package[%s] is faulted\n", pkgname);
897 ret = LB_STATUS_ERROR_FAULT;
898 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
899 struct buffer_info *buffer;
900 struct slave_node *slave;
901 // struct packet *packet;
903 buffer = instance_pd_buffer(inst);
905 ErrPrint("Instance[%s] has no buffer\n", id);
906 ret = LB_STATUS_ERROR_FAULT;
910 slave = package_slave(pkg);
912 ErrPrint("Package[%s] has no slave\n", pkgname);
913 ret = LB_STATUS_ERROR_INVALID;
918 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
920 ErrPrint("Failed to create a packet[%s]\n", pkgname);
921 ret = LB_STATUS_ERROR_FAULT;
926 packet_ref((struct packet *)packet);
927 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
928 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
929 struct script_info *script;
932 script = instance_pd_script(inst);
934 ret = LB_STATUS_ERROR_FAULT;
938 e = script_handler_evas(script);
940 ret = LB_STATUS_ERROR_FAULT;
944 script_handler_update_pointer(script, x, y, -1);
945 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
948 ErrPrint("Unsupported package\n");
949 ret = LB_STATUS_ERROR_INVALID;
953 /*! \note No reply packet */
957 static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
959 struct client_node *client;
966 struct inst_info *inst;
967 const struct pkg_info *pkg;
969 client = client_find_by_pid(pid);
971 ErrPrint("Client %d is not exists\n", pid);
972 ret = LB_STATUS_ERROR_NOT_EXIST;
976 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
978 ErrPrint("Parameter is not matched\n");
979 ret = LB_STATUS_ERROR_INVALID;
985 * Trust the package name which are sent by the client.
986 * The package has to be a livebox package name.
988 inst = package_find_instance_by_id(pkgname, id);
990 ErrPrint("Instance[%s] is not exists\n", id);
991 ret = LB_STATUS_ERROR_NOT_EXIST;
995 pkg = instance_package(inst);
997 ErrPrint("Package[%s] info is not found\n", pkgname);
998 ret = LB_STATUS_ERROR_FAULT;
1002 if (package_is_fault(pkg)) {
1005 * If the package is registered as fault module,
1006 * slave has not load it, so we don't need to do anything at here!
1008 DbgPrint("Package[%s] is faulted\n", pkgname);
1009 ret = LB_STATUS_ERROR_FAULT;
1010 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1011 struct buffer_info *buffer;
1012 struct slave_node *slave;
1013 // struct packet *packet;
1015 buffer = instance_pd_buffer(inst);
1017 ErrPrint("Instance[%s] has no buffer\n", id);
1018 ret = LB_STATUS_ERROR_FAULT;
1022 slave = package_slave(pkg);
1024 ErrPrint("Package[%s] has no slave\n", pkgname);
1025 ret = LB_STATUS_ERROR_INVALID;
1030 packet = packet_create_noack("pd_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1032 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1033 ret = LB_STATUS_ERROR_FAULT;
1038 packet_ref((struct packet *)packet);
1039 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1040 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1041 struct script_info *script;
1044 script = instance_pd_script(inst);
1046 ret = LB_STATUS_ERROR_FAULT;
1050 e = script_handler_evas(script);
1052 ret = LB_STATUS_ERROR_FAULT;
1056 script_handler_update_pointer(script, x, y, -1);
1057 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
1060 ErrPrint("Unsupported package\n");
1061 ret = LB_STATUS_ERROR_INVALID;
1065 /*! \note No reply packet */
1069 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 */
1071 struct client_node *client;
1072 const char *pkgname;
1078 struct inst_info *inst;
1079 const struct pkg_info *pkg;
1081 client = client_find_by_pid(pid);
1083 ErrPrint("Client %d is not exists\n", pid);
1084 ret = LB_STATUS_ERROR_NOT_EXIST;
1088 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1090 ErrPrint("Parameter is not matched\n");
1091 ret = LB_STATUS_ERROR_INVALID;
1095 DbgPrint("(%dx%d)\n", x, y);
1099 * Trust the package name which are sent by the client.
1100 * The package has to be a livebox package name.
1102 inst = package_find_instance_by_id(pkgname, id);
1104 ErrPrint("Instance[%s] is not exists\n", id);
1105 ret = LB_STATUS_ERROR_NOT_EXIST;
1109 pkg = instance_package(inst);
1111 ErrPrint("Package[%s] info is not found\n", pkgname);
1112 ret = LB_STATUS_ERROR_FAULT;
1116 if (package_is_fault(pkg)) {
1119 * If the package is registered as fault module,
1120 * slave has not load it, so we don't need to do anything at here!
1122 DbgPrint("Package[%s] is faulted\n", pkgname);
1123 ret = LB_STATUS_ERROR_FAULT;
1124 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1125 struct buffer_info *buffer;
1126 struct slave_node *slave;
1127 // struct packet *packet;
1129 buffer = instance_pd_buffer(inst);
1131 ErrPrint("Instance[%s] has no buffer\n", id);
1132 ret = LB_STATUS_ERROR_FAULT;
1136 slave = package_slave(pkg);
1138 ErrPrint("Package[%s] has no slave\n", pkgname);
1139 ret = LB_STATUS_ERROR_INVALID;
1144 packet = packet_create_noack("pd_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1146 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1147 ret = LB_STATUS_ERROR_FAULT;
1152 packet_ref((struct packet *)packet);
1153 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1154 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1155 struct script_info *script;
1158 script = instance_pd_script(inst);
1160 ret = LB_STATUS_ERROR_FAULT;
1164 e = script_handler_evas(script);
1166 ret = LB_STATUS_ERROR_FAULT;
1170 script_handler_update_pointer(script, x, y, 1);
1171 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
1174 ErrPrint("Unsupported package\n");
1175 ret = LB_STATUS_ERROR_INVALID;
1179 /*! \note No reply packet */
1183 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 */
1185 struct client_node *client;
1186 const char *pkgname;
1192 struct inst_info *inst;
1193 const struct pkg_info *pkg;
1195 client = client_find_by_pid(pid);
1197 ErrPrint("Client %d is not exists\n", pid);
1198 ret = LB_STATUS_ERROR_NOT_EXIST;
1202 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1204 ErrPrint("Parameter is not matched\n");
1205 ret = LB_STATUS_ERROR_INVALID;
1209 DbgPrint("(%dx%d)\n", x, y);
1212 * Trust the package name which are sent by the client.
1213 * The package has to be a livebox package name.
1215 inst = package_find_instance_by_id(pkgname, id);
1217 ErrPrint("Instance[%s] is not exists\n", id);
1218 ret = LB_STATUS_ERROR_NOT_EXIST;
1222 pkg = instance_package(inst);
1224 ErrPrint("Package[%s] info is not exists\n", pkgname);
1225 ret = LB_STATUS_ERROR_FAULT;
1229 if (package_is_fault(pkg)) {
1232 * If the package is registered as fault module,
1233 * slave has not load it, so we don't need to do anything at here!
1235 DbgPrint("Package[%s] is faulted\n", pkgname);
1236 ret = LB_STATUS_ERROR_FAULT;
1237 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1238 struct buffer_info *buffer;
1239 struct slave_node *slave;
1240 //struct packet *packet;
1242 buffer = instance_pd_buffer(inst);
1244 ErrPrint("Instance[%s] has no buffer\n", id);
1245 ret = LB_STATUS_ERROR_FAULT;
1249 slave = package_slave(pkg);
1251 ErrPrint("Package[%s] has no slave\n", pkgname);
1252 ret = LB_STATUS_ERROR_INVALID;
1257 packet = packet_create_noack("pd_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1259 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1260 ret = LB_STATUS_ERROR_FAULT;
1265 packet_ref((struct packet *)packet);
1266 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1267 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1268 struct script_info *script;
1271 script = instance_pd_script(inst);
1273 ret = LB_STATUS_ERROR_FAULT;
1277 e = script_handler_evas(script);
1279 ret = LB_STATUS_ERROR_FAULT;
1283 script_handler_update_pointer(script, x, y, 0);
1284 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
1287 ErrPrint("Unsupported package\n");
1288 ret = LB_STATUS_ERROR_INVALID;
1292 /*! \note No reply packet */
1296 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 */
1298 struct client_node *client;
1299 const char *pkgname;
1305 struct inst_info *inst;
1306 const struct pkg_info *pkg;
1308 client = client_find_by_pid(pid);
1310 ErrPrint("Client %d is not exists\n", pid);
1311 ret = LB_STATUS_ERROR_NOT_EXIST;
1315 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1317 ErrPrint("Parameter is not matched\n");
1318 ret = LB_STATUS_ERROR_INVALID;
1322 DbgPrint("(%dx%d)\n", x, y);
1325 * Trust the package name which are sent by the client.
1326 * The package has to be a livebox package name.
1328 inst = package_find_instance_by_id(pkgname, id);
1330 ErrPrint("Instance[%s] is not exists\n", id);
1331 ret = LB_STATUS_ERROR_NOT_EXIST;
1335 pkg = instance_package(inst);
1337 ErrPrint("Package[%s] info is not exists\n", pkgname);
1338 ret = LB_STATUS_ERROR_FAULT;
1342 if (package_is_fault(pkg)) {
1345 * If the package is registered as fault module,
1346 * slave has not load it, so we don't need to do anything at here!
1348 DbgPrint("Package[%s] is faulted\n", pkgname);
1349 ret = LB_STATUS_ERROR_FAULT;
1350 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1351 struct buffer_info *buffer;
1352 struct slave_node *slave;
1353 //struct packet *packet;
1355 buffer = instance_pd_buffer(inst);
1357 ErrPrint("Instance[%s] has no buffer\n", id);
1358 ret = LB_STATUS_ERROR_FAULT;
1362 slave = package_slave(pkg);
1364 ErrPrint("Package[%s] has no slave\n", pkgname);
1365 ret = LB_STATUS_ERROR_INVALID;
1371 packet = packet_create_noack("pd_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1373 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1374 ret = LB_STATUS_ERROR_FAULT;
1378 packet_ref((struct packet *)packet);
1379 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1380 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1381 struct script_info *script;
1384 script = instance_pd_script(inst);
1386 ret = LB_STATUS_ERROR_FAULT;
1390 e = script_handler_evas(script);
1392 ret = LB_STATUS_ERROR_FAULT;
1396 script_handler_update_pointer(script, x, y, -1);
1397 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1400 ErrPrint("Unsupported package\n");
1401 ret = LB_STATUS_ERROR_INVALID;
1405 /*! \note No reply packet */
1409 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 */
1411 struct client_node *client;
1412 const char *pkgname;
1418 struct inst_info *inst;
1419 const struct pkg_info *pkg;
1421 client = client_find_by_pid(pid);
1423 ErrPrint("Client %d is not exists\n", pid);
1424 ret = LB_STATUS_ERROR_NOT_EXIST;
1428 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1430 ErrPrint("Parameter is not matched\n");
1431 ret = LB_STATUS_ERROR_INVALID;
1437 * Trust the package name which are sent by the client.
1438 * The package has to be a livebox package name.
1440 inst = package_find_instance_by_id(pkgname, id);
1442 ErrPrint("Instance[%s] is not exists\n", id);
1443 ret = LB_STATUS_ERROR_NOT_EXIST;
1447 pkg = instance_package(inst);
1449 ErrPrint("Package[%s] info is not exists\n", pkgname);
1450 ret = LB_STATUS_ERROR_FAULT;
1454 if (package_is_fault(pkg)) {
1457 * If the package is registered as fault module,
1458 * slave has not load it, so we don't need to do anything at here!
1460 DbgPrint("Package[%s] is faulted\n", pkgname);
1461 ret = LB_STATUS_ERROR_FAULT;
1462 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1463 struct buffer_info *buffer;
1464 struct slave_node *slave;
1465 //struct packet *packet;
1467 buffer = instance_lb_buffer(inst);
1469 ErrPrint("Instance[%s] has no buffer\n", id);
1470 ret = LB_STATUS_ERROR_FAULT;
1474 slave = package_slave(pkg);
1476 ErrPrint("Package[%s] has no slave\n", pkgname);
1477 ret = LB_STATUS_ERROR_INVALID;
1482 packet = packet_create_noack("lb_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1484 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1485 ret = LB_STATUS_ERROR_FAULT;
1489 packet_ref((struct packet *)packet);
1490 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1491 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1492 struct script_info *script;
1495 script = instance_lb_script(inst);
1497 ret = LB_STATUS_ERROR_FAULT;
1501 e = script_handler_evas(script);
1503 ret = LB_STATUS_ERROR_FAULT;
1507 script_handler_update_pointer(script, x, y, -1);
1508 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1511 ErrPrint("Unsupported package\n");
1512 ret = LB_STATUS_ERROR_INVALID;
1516 /*! \note No reply packet */
1520 static int inst_del_cb(struct inst_info *inst, void *data)
1522 (void)event_deactivate();
1523 return -1; /* Delete this callback */
1526 static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
1528 struct client_node *client;
1529 const char *pkgname;
1535 struct inst_info *inst;
1536 const struct pkg_info *pkg;
1538 client = client_find_by_pid(pid);
1540 ErrPrint("Client %d is not exists\n", pid);
1541 ret = LB_STATUS_ERROR_NOT_EXIST;
1545 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1547 ErrPrint("Parameter is not matched\n");
1548 ret = LB_STATUS_ERROR_INVALID;
1552 inst = package_find_instance_by_id(pkgname, id);
1554 ErrPrint("Instance[%s] is not exists\n", id);
1555 ret = LB_STATUS_ERROR_NOT_EXIST;
1559 pkg = instance_package(inst);
1561 ErrPrint("Package[%s] info is not exists\n", pkgname);
1562 ret = LB_STATUS_ERROR_FAULT;
1566 if (package_is_fault(pkg)) {
1569 * If the package is registered as fault module,
1570 * slave has not load it, so we don't need to do anything at here!
1572 DbgPrint("Package[%s] is faulted\n", pkgname);
1573 ret = LB_STATUS_ERROR_FAULT;
1574 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1575 if (event_is_activated()) {
1576 if (event_deactivate() == 0)
1577 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1580 ret = event_activate(x, y, event_lb_route_cb, inst);
1582 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1583 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1584 if (event_is_activated()) {
1585 if (event_deactivate() == 0)
1586 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1589 ret = event_activate(x, y, event_lb_consume_cb, inst);
1591 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1593 ErrPrint("Unsupported package\n");
1594 ret = LB_STATUS_ERROR_INVALID;
1600 static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1602 struct client_node *client;
1603 const char *pkgname;
1609 struct inst_info *inst;
1610 const struct pkg_info *pkg;
1611 client = client_find_by_pid(pid);
1613 ErrPrint("Client %d is not exists\n", pid);
1614 ret = LB_STATUS_ERROR_NOT_EXIST;
1617 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1619 ErrPrint("Parameter is not matched\n");
1620 ret = LB_STATUS_ERROR_INVALID;
1624 inst = package_find_instance_by_id(pkgname, id);
1626 ErrPrint("Instance[%s] is not exists\n", id);
1627 ret = LB_STATUS_ERROR_NOT_EXIST;
1631 pkg = instance_package(inst);
1633 ErrPrint("Package[%s] info is not exists\n", pkgname);
1634 ret = LB_STATUS_ERROR_FAULT;
1638 if (package_is_fault(pkg)) {
1641 * If the package is registered as fault module,
1642 * slave has not load it, so we don't need to do anything at here!
1644 DbgPrint("Package[%s] is faulted\n", pkgname);
1645 ret = LB_STATUS_ERROR_FAULT;
1646 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1647 ret = event_deactivate();
1649 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1650 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1651 ret = event_deactivate();
1653 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1655 ErrPrint("Unsupported package\n");
1656 ret = LB_STATUS_ERROR_INVALID;
1662 static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
1664 struct client_node *client;
1665 const char *pkgname;
1671 struct inst_info *inst;
1672 const struct pkg_info *pkg;
1674 client = client_find_by_pid(pid);
1676 ErrPrint("Client %d is not exists\n", pid);
1677 ret = LB_STATUS_ERROR_NOT_EXIST;
1681 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1683 ErrPrint("Parameter is not matched\n");
1684 ret = LB_STATUS_ERROR_INVALID;
1688 inst = package_find_instance_by_id(pkgname, id);
1690 ErrPrint("Instance[%s] is not exists\n", id);
1691 ret = LB_STATUS_ERROR_NOT_EXIST;
1695 pkg = instance_package(inst);
1697 ErrPrint("Package[%s] info is not exists\n", pkgname);
1698 ret = LB_STATUS_ERROR_FAULT;
1702 if (package_is_fault(pkg)) {
1705 * If the package is registered as fault module,
1706 * slave has not load it, so we don't need to do anything at here!
1708 DbgPrint("Package[%s] is faulted\n", pkgname);
1709 ret = LB_STATUS_ERROR_FAULT;
1710 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1711 if (event_is_activated()) {
1712 if (event_deactivate() == 0)
1713 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1716 ret = event_activate(x, y, event_pd_route_cb, inst);
1718 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1719 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1720 if (event_is_activated()) {
1721 if (event_deactivate() == 0)
1722 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1725 ret = event_activate(x, y, event_pd_consume_cb, inst);
1727 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1729 ErrPrint("Unsupported package\n");
1730 ret = LB_STATUS_ERROR_INVALID;
1737 static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1739 struct client_node *client;
1740 const char *pkgname;
1746 struct inst_info *inst;
1747 const struct pkg_info *pkg;
1749 client = client_find_by_pid(pid);
1751 ErrPrint("Client %d is not exists\n", pid);
1752 ret = LB_STATUS_ERROR_NOT_EXIST;
1756 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1758 ErrPrint("Parameter is not matched\n");
1759 ret = LB_STATUS_ERROR_INVALID;
1763 inst = package_find_instance_by_id(pkgname, id);
1765 ErrPrint("Instance[%s] is not exists\n", id);
1766 ret = LB_STATUS_ERROR_NOT_EXIST;
1770 pkg = instance_package(inst);
1772 ErrPrint("Package[%s] info is not exists\n", pkgname);
1773 ret = LB_STATUS_ERROR_FAULT;
1777 if (package_is_fault(pkg)) {
1780 * If the package is registered as fault module,
1781 * slave has not load it, so we don't need to do anything at here!
1783 DbgPrint("Package[%s] is faulted\n", pkgname);
1784 ret = LB_STATUS_ERROR_FAULT;
1785 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1786 ret = event_deactivate();
1788 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1789 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1790 ret = event_deactivate();
1792 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1794 ErrPrint("Unsupported package\n");
1795 ret = LB_STATUS_ERROR_INVALID;
1801 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 */
1803 struct client_node *client;
1804 const char *pkgname;
1810 struct inst_info *inst;
1811 const struct pkg_info *pkg;
1813 client = client_find_by_pid(pid);
1815 ErrPrint("Client %d is not exists\n", pid);
1816 ret = LB_STATUS_ERROR_NOT_EXIST;
1820 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1822 ErrPrint("Parameter is not matched\n");
1823 ret = LB_STATUS_ERROR_INVALID;
1829 * Trust the package name which are sent by the client.
1830 * The package has to be a livebox package name.
1832 inst = package_find_instance_by_id(pkgname, id);
1834 ErrPrint("Instance[%s] is not exists\n", id);
1835 ret = LB_STATUS_ERROR_NOT_EXIST;
1839 pkg = instance_package(inst);
1841 ErrPrint("Package[%s] info is not exists\n", pkgname);
1842 ret = LB_STATUS_ERROR_FAULT;
1846 if (package_is_fault(pkg)) {
1849 * If the package is registered as fault module,
1850 * slave has not load it, so we don't need to do anything at here!
1852 DbgPrint("Package[%s] is faulted\n", pkgname);
1853 ret = LB_STATUS_ERROR_FAULT;
1854 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1855 struct buffer_info *buffer;
1856 struct slave_node *slave;
1857 //struct packet *packet;
1859 buffer = instance_lb_buffer(inst);
1861 ErrPrint("Instance[%s] has no buffer\n", id);
1862 ret = LB_STATUS_ERROR_FAULT;
1866 slave = package_slave(pkg);
1868 ErrPrint("Package[%s] has no slave\n", pkgname);
1869 ret = LB_STATUS_ERROR_INVALID;
1874 packet = packet_create_noack("lb_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1876 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1877 ret = LB_STATUS_ERROR_FAULT;
1881 packet_ref((struct packet *)packet);
1882 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1883 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1884 struct script_info *script;
1887 script = instance_lb_script(inst);
1889 ret = LB_STATUS_ERROR_FAULT;
1893 e = script_handler_evas(script);
1895 ret = LB_STATUS_ERROR_FAULT;
1899 script_handler_update_pointer(script, x, y, -1);
1900 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
1903 ErrPrint("Unsupported package\n");
1904 ret = LB_STATUS_ERROR_INVALID;
1908 /*! \note No reply packet */
1912 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 */
1914 struct client_node *client;
1915 const char *pkgname;
1921 struct inst_info *inst;
1922 const struct pkg_info *pkg;
1924 client = client_find_by_pid(pid);
1926 ErrPrint("Client %d is not exists\n", pid);
1927 ret = LB_STATUS_ERROR_NOT_EXIST;
1931 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1933 ErrPrint("Parameter is not matched\n");
1934 ret = LB_STATUS_ERROR_INVALID;
1940 * Trust the package name which are sent by the client.
1941 * The package has to be a livebox package name.
1943 inst = package_find_instance_by_id(pkgname, id);
1945 ErrPrint("Instance[%s] is not exists\n", id);
1946 ret = LB_STATUS_ERROR_NOT_EXIST;
1950 pkg = instance_package(inst);
1952 ErrPrint("Package[%s] info is not exists\n", pkgname);
1953 ret = LB_STATUS_ERROR_FAULT;
1957 if (package_is_fault(pkg)) {
1960 * If the package is registered as fault module,
1961 * slave has not load it, so we don't need to do anything at here!
1963 DbgPrint("Package[%s] is faulted\n", pkgname);
1964 ret = LB_STATUS_ERROR_FAULT;
1965 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1966 struct buffer_info *buffer;
1967 struct slave_node *slave;
1968 //struct packet *packet;
1970 buffer = instance_lb_buffer(inst);
1972 ErrPrint("Instance[%s] has no buffer\n", id);
1973 ret = LB_STATUS_ERROR_FAULT;
1977 slave = package_slave(pkg);
1979 ErrPrint("Package[%s] has no slave\n", pkgname);
1980 ret = LB_STATUS_ERROR_INVALID;
1985 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1987 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1988 ret = LB_STATUS_ERROR_FAULT;
1993 packet_ref((struct packet *)packet);
1994 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1995 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1996 struct script_info *script;
1999 script = instance_lb_script(inst);
2001 ret = LB_STATUS_ERROR_FAULT;
2005 e = script_handler_evas(script);
2007 ret = LB_STATUS_ERROR_FAULT;
2011 script_handler_update_pointer(script, x, y, -1);
2012 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
2015 ErrPrint("Unsupported package\n");
2016 ret = LB_STATUS_ERROR_INVALID;
2020 /*! \note No reply packet */
2024 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 */
2026 struct client_node *client;
2027 const char *pkgname;
2033 struct inst_info *inst;
2034 const struct pkg_info *pkg;
2036 client = client_find_by_pid(pid);
2038 ErrPrint("Client %d is not exists\n", pid);
2039 ret = LB_STATUS_ERROR_NOT_EXIST;
2043 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2045 ErrPrint("Parameter is not matched\n");
2046 ret = LB_STATUS_ERROR_INVALID;
2052 * Trust the package name which are sent by the client.
2053 * The package has to be a livebox package name.
2055 inst = package_find_instance_by_id(pkgname, id);
2057 ErrPrint("Instance[%s] is not exists\n", id);
2058 ret = LB_STATUS_ERROR_NOT_EXIST;
2062 pkg = instance_package(inst);
2064 ErrPrint("Package[%s] info is not exists\n", pkgname);
2065 ret = LB_STATUS_ERROR_FAULT;
2069 if (package_is_fault(pkg)) {
2072 * If the package is registered as fault module,
2073 * slave has not load it, so we don't need to do anything at here!
2075 DbgPrint("Package[%s] is faulted\n", pkgname);
2076 ret = LB_STATUS_ERROR_FAULT;
2077 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2078 struct buffer_info *buffer;
2079 struct slave_node *slave;
2080 // struct packet *packet;
2082 buffer = instance_lb_buffer(inst);
2084 ErrPrint("Instance[%s] has no buffer\n", id);
2085 ret = LB_STATUS_ERROR_FAULT;
2089 slave = package_slave(pkg);
2091 ErrPrint("Package[%s] has no slave\n", pkgname);
2092 ret = LB_STATUS_ERROR_INVALID;
2097 packet = packet_create_noack("lb_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2099 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2100 ret = LB_STATUS_ERROR_FAULT;
2105 packet_ref((struct packet *)packet);
2106 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2107 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2108 struct script_info *script;
2111 script = instance_lb_script(inst);
2113 ret = LB_STATUS_ERROR_FAULT;
2117 e = script_handler_evas(script);
2119 ret = LB_STATUS_ERROR_FAULT;
2123 script_handler_update_pointer(script, x, y, 1);
2124 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
2127 ErrPrint("Unsupported package\n");
2128 ret = LB_STATUS_ERROR_INVALID;
2132 /*! \note No reply packet */
2136 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 */
2138 struct client_node *client;
2139 const char *pkgname;
2145 struct inst_info *inst;
2146 const struct pkg_info *pkg;
2148 client = client_find_by_pid(pid);
2150 ErrPrint("Client %d is not exists\n", pid);
2151 ret = LB_STATUS_ERROR_NOT_EXIST;
2155 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2157 ErrPrint("Parameter is not matched\n");
2158 ret = LB_STATUS_ERROR_INVALID;
2164 * Trust the package name which are sent by the client.
2165 * The package has to be a livebox package name.
2167 inst = package_find_instance_by_id(pkgname, id);
2169 ErrPrint("Instance[%s] is not exists\n", id);
2170 ret = LB_STATUS_ERROR_NOT_EXIST;
2174 pkg = instance_package(inst);
2176 ErrPrint("Package[%s] info is not exists\n", pkgname);
2177 ret = LB_STATUS_ERROR_FAULT;
2181 if (package_is_fault(pkg)) {
2184 * If the package is registered as fault module,
2185 * slave has not load it, so we don't need to do anything at here!
2187 DbgPrint("Package[%s] is faulted\n", pkgname);
2188 ret = LB_STATUS_ERROR_FAULT;
2189 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2190 struct buffer_info *buffer;
2191 struct slave_node *slave;
2192 //struct packet *packet;
2194 buffer = instance_lb_buffer(inst);
2196 ErrPrint("Instance[%s] has no buffer\n", id);
2197 ret = LB_STATUS_ERROR_FAULT;
2201 slave = package_slave(pkg);
2203 ErrPrint("Package[%s] has no slave\n", pkgname);
2204 ret = LB_STATUS_ERROR_INVALID;
2209 packet = packet_create_noack("lb_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2211 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2212 ret = LB_STATUS_ERROR_FAULT;
2217 packet_ref((struct packet *)packet);
2218 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2219 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2220 struct script_info *script;
2223 script = instance_lb_script(inst);
2225 ret = LB_STATUS_ERROR_FAULT;
2229 e = script_handler_evas(script);
2231 ret = LB_STATUS_ERROR_FAULT;
2235 script_handler_update_pointer(script, x, y, 0);
2236 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
2239 ErrPrint("Unsupported package\n");
2240 ret = LB_STATUS_ERROR_INVALID;
2244 /*! \note No reply packet */
2248 static struct packet *client_pd_access_value_change(pid_t pid, int handle, const struct packet *packet)
2250 struct packet *result;
2251 struct client_node *client;
2252 const char *pkgname;
2258 struct inst_info *inst;
2259 const struct pkg_info *pkg;
2261 client = client_find_by_pid(pid);
2263 ErrPrint("Client %d is not exists\n", pid);
2264 ret = LB_STATUS_ERROR_NOT_EXIST;
2268 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2270 ErrPrint("Invalid parameter\n");
2271 ret = LB_STATUS_ERROR_INVALID;
2277 * Trust the package name which are sent by the client.
2278 * The package has to be a livebox package name.
2280 inst = package_find_instance_by_id(pkgname, id);
2282 ErrPrint("Instance[%s] is not exists\n", id);
2283 ret = LB_STATUS_ERROR_NOT_EXIST;
2287 pkg = instance_package(inst);
2289 ErrPrint("Package[%s] info is not found\n", pkgname);
2290 ret = LB_STATUS_ERROR_FAULT;
2294 if (package_is_fault(pkg)) {
2297 * If the package is registered as fault module,
2298 * slave has not load it, so we don't need to do anything at here!
2300 DbgPrint("Package[%s] is faulted\n", pkgname);
2301 ret = LB_STATUS_ERROR_FAULT;
2302 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2303 struct buffer_info *buffer;
2304 struct slave_node *slave;
2305 // struct packet *packet;
2307 buffer = instance_pd_buffer(inst);
2309 ErrPrint("Instance[%s] has no buffer\n", id);
2310 ret = LB_STATUS_ERROR_FAULT;
2314 slave = package_slave(pkg);
2316 ErrPrint("Package[%s] has no slave\n", pkgname);
2317 ret = LB_STATUS_ERROR_INVALID;
2322 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2324 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2325 ret = LB_STATUS_ERROR_FAULT;
2330 packet_ref((struct packet *)packet);
2331 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2332 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2333 struct script_info *script;
2336 script = instance_pd_script(inst);
2338 ret = LB_STATUS_ERROR_FAULT;
2342 e = script_handler_evas(script);
2344 ret = LB_STATUS_ERROR_FAULT;
2348 script_handler_update_pointer(script, x, y, -1);
2349 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, timestamp);
2351 struct access_cbdata *cbdata;
2353 cbdata = malloc(sizeof(*cbdata));
2355 ret = LB_STATUS_ERROR_MEMORY;
2357 cbdata->inst = instance_ref(inst);
2358 cbdata->status = ret;
2360 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2361 instance_unref(cbdata->inst);
2363 ret = LB_STATUS_ERROR_FAULT;
2365 ret = LB_STATUS_SUCCESS;
2370 ErrPrint("Unsupported package\n");
2371 ret = LB_STATUS_ERROR_INVALID;
2375 result = packet_create_reply(packet, "i", ret);
2377 ErrPrint("Failed to create a reply packet\n");
2382 static struct packet *client_pd_access_scroll(pid_t pid, int handle, const struct packet *packet)
2384 struct packet *result;
2385 struct client_node *client;
2386 const char *pkgname;
2392 struct inst_info *inst;
2393 const struct pkg_info *pkg;
2395 client = client_find_by_pid(pid);
2397 ErrPrint("Client %d is not exists\n", pid);
2398 ret = LB_STATUS_ERROR_NOT_EXIST;
2402 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2404 ErrPrint("Invalid parameter\n");
2405 ret = LB_STATUS_ERROR_INVALID;
2411 * Trust the package name which are sent by the client.
2412 * The package has to be a livebox package name.
2414 inst = package_find_instance_by_id(pkgname, id);
2416 ErrPrint("Instance[%s] is not exists\n", id);
2417 ret = LB_STATUS_ERROR_NOT_EXIST;
2421 pkg = instance_package(inst);
2423 ErrPrint("Package[%s] info is not found\n", pkgname);
2424 ret = LB_STATUS_ERROR_FAULT;
2428 if (package_is_fault(pkg)) {
2431 * If the package is registered as fault module,
2432 * slave has not load it, so we don't need to do anything at here!
2434 DbgPrint("Package[%s] is faulted\n", pkgname);
2435 ret = LB_STATUS_ERROR_FAULT;
2436 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2437 struct buffer_info *buffer;
2438 struct slave_node *slave;
2439 // struct packet *packet;
2441 buffer = instance_pd_buffer(inst);
2443 ErrPrint("Instance[%s] has no buffer\n", id);
2444 ret = LB_STATUS_ERROR_FAULT;
2448 slave = package_slave(pkg);
2450 ErrPrint("Package[%s] has no slave\n", pkgname);
2451 ret = LB_STATUS_ERROR_INVALID;
2456 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2458 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2459 ret = LB_STATUS_ERROR_FAULT;
2464 packet_ref((struct packet *)packet);
2465 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2466 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2467 struct script_info *script;
2470 script = instance_pd_script(inst);
2472 ret = LB_STATUS_ERROR_FAULT;
2476 e = script_handler_evas(script);
2478 ret = LB_STATUS_ERROR_FAULT;
2482 script_handler_update_pointer(script, x, y, -1);
2483 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2485 struct access_cbdata *cbdata;
2487 cbdata = malloc(sizeof(*cbdata));
2489 ret = LB_STATUS_ERROR_MEMORY;
2491 cbdata->inst = instance_ref(inst);
2492 cbdata->status = ret;
2494 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2495 instance_unref(cbdata->inst);
2497 ret = LB_STATUS_ERROR_FAULT;
2499 ret = LB_STATUS_SUCCESS;
2504 ErrPrint("Unsupported package\n");
2505 ret = LB_STATUS_ERROR_INVALID;
2509 result = packet_create_reply(packet, "i", ret);
2511 ErrPrint("Failed to create a reply packet\n");
2516 static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
2518 struct packet *result;
2519 struct client_node *client;
2520 const char *pkgname;
2524 struct inst_info *inst;
2525 const struct pkg_info *pkg;
2529 client = client_find_by_pid(pid);
2531 ErrPrint("Client %d is not exists\n", pid);
2532 ret = LB_STATUS_ERROR_NOT_EXIST;
2536 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2538 ErrPrint("Invalid parameter\n");
2539 ret = LB_STATUS_ERROR_INVALID;
2543 inst = package_find_instance_by_id(pkgname, id);
2545 ErrPrint("Instance[%s] is not exists\n", id);
2546 ret = LB_STATUS_ERROR_NOT_EXIST;
2550 pkg = instance_package(inst);
2552 ErrPrint("Package[%s] info is not found\n", pkgname);
2553 ret = LB_STATUS_ERROR_FAULT;
2557 if (package_is_fault(pkg)) {
2558 DbgPrint("Package[%s] is faulted\n", pkgname);
2559 ret = LB_STATUS_ERROR_FAULT;
2560 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2561 struct buffer_info *buffer;
2562 struct slave_node *slave;
2563 // struct packet *packet;
2565 buffer = instance_pd_buffer(inst);
2567 ErrPrint("Instance[%s] has no buffer\n", id);
2568 ret = LB_STATUS_ERROR_FAULT;
2572 slave = package_slave(pkg);
2574 ErrPrint("Package[%s] has no slave\n", pkgname);
2575 ret = LB_STATUS_ERROR_INVALID;
2580 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2582 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2583 ret = LB_STATUS_ERROR_FAULT;
2588 packet_ref((struct packet *)packet);
2589 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2590 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2591 struct script_info *script;
2594 script = instance_pd_script(inst);
2596 ret = LB_STATUS_ERROR_FAULT;
2600 e = script_handler_evas(script);
2602 ret = LB_STATUS_ERROR_FAULT;
2606 script_handler_update_pointer(script, x, y, -1);
2607 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
2609 struct access_cbdata *cbdata;
2611 cbdata = malloc(sizeof(*cbdata));
2613 ret = LB_STATUS_ERROR_MEMORY;
2615 cbdata->inst = instance_ref(inst);
2616 cbdata->status = ret;
2618 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2619 instance_unref(cbdata->inst);
2621 ret = LB_STATUS_ERROR_FAULT;
2623 ret = LB_STATUS_SUCCESS;
2628 ErrPrint("Unsupported package\n");
2629 ret = LB_STATUS_ERROR_INVALID;
2632 result = packet_create_reply(packet, "i", ret);
2634 ErrPrint("Failed to create a reply packet\n");
2639 static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct packet *packet)
2641 struct packet *result;
2642 struct client_node *client;
2643 const char *pkgname;
2649 struct inst_info *inst;
2650 const struct pkg_info *pkg;
2652 client = client_find_by_pid(pid);
2654 ErrPrint("Client %d is not exists\n", pid);
2655 ret = LB_STATUS_ERROR_NOT_EXIST;
2659 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2661 ErrPrint("Invalid parameter\n");
2662 ret = LB_STATUS_ERROR_INVALID;
2668 * Trust the package name which are sent by the client.
2669 * The package has to be a livebox package name.
2671 inst = package_find_instance_by_id(pkgname, id);
2673 ErrPrint("Instance[%s] is not exists\n", id);
2674 ret = LB_STATUS_ERROR_NOT_EXIST;
2678 pkg = instance_package(inst);
2680 ErrPrint("Package[%s] info is not found\n", pkgname);
2681 ret = LB_STATUS_ERROR_FAULT;
2685 if (package_is_fault(pkg)) {
2688 * If the package is registered as fault module,
2689 * slave has not load it, so we don't need to do anything at here!
2691 DbgPrint("Package[%s] is faulted\n", pkgname);
2692 ret = LB_STATUS_ERROR_FAULT;
2693 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2694 struct buffer_info *buffer;
2695 struct slave_node *slave;
2696 // struct packet *packet;
2698 buffer = instance_pd_buffer(inst);
2700 ErrPrint("Instance[%s] has no buffer\n", id);
2701 ret = LB_STATUS_ERROR_FAULT;
2705 slave = package_slave(pkg);
2707 ErrPrint("Package[%s] has no slave\n", pkgname);
2708 ret = LB_STATUS_ERROR_INVALID;
2713 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2715 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2716 ret = LB_STATUS_ERROR_FAULT;
2721 packet_ref((struct packet *)packet);
2722 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2723 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2724 struct script_info *script;
2727 script = instance_pd_script(inst);
2729 ret = LB_STATUS_ERROR_FAULT;
2733 e = script_handler_evas(script);
2735 ret = LB_STATUS_ERROR_FAULT;
2739 script_handler_update_pointer(script, x, y, -1);
2740 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
2742 struct access_cbdata *cbdata;
2744 cbdata = malloc(sizeof(*cbdata));
2746 ret = LB_STATUS_ERROR_MEMORY;
2748 cbdata->inst = instance_ref(inst);
2749 cbdata->status = ret;
2751 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2752 instance_unref(cbdata->inst);
2754 ret = LB_STATUS_ERROR_FAULT;
2756 ret = LB_STATUS_SUCCESS;
2761 ErrPrint("Unsupported package\n");
2762 ret = LB_STATUS_ERROR_INVALID;
2766 result = packet_create_reply(packet, "i", ret);
2768 ErrPrint("Failed to create a reply packet\n");
2773 static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
2775 struct packet *result;
2776 struct client_node *client;
2777 const char *pkgname;
2783 struct inst_info *inst;
2784 const struct pkg_info *pkg;
2786 client = client_find_by_pid(pid);
2788 ErrPrint("Client %d is not exists\n", pid);
2789 ret = LB_STATUS_ERROR_NOT_EXIST;
2793 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2795 ErrPrint("Invalid parameter\n");
2796 ret = LB_STATUS_ERROR_INVALID;
2802 * Trust the package name which are sent by the client.
2803 * The package has to be a livebox package name.
2805 inst = package_find_instance_by_id(pkgname, id);
2807 ErrPrint("Instance[%s] is not exists\n", id);
2808 ret = LB_STATUS_ERROR_NOT_EXIST;
2812 pkg = instance_package(inst);
2814 ErrPrint("Package[%s] info is not found\n", pkgname);
2815 ret = LB_STATUS_ERROR_FAULT;
2819 if (package_is_fault(pkg)) {
2822 * If the package is registered as fault module,
2823 * slave has not load it, so we don't need to do anything at here!
2825 DbgPrint("Package[%s] is faulted\n", pkgname);
2826 ret = LB_STATUS_ERROR_FAULT;
2827 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2828 struct buffer_info *buffer;
2829 struct slave_node *slave;
2830 // struct packet *packet;
2832 buffer = instance_pd_buffer(inst);
2834 ErrPrint("Instance[%s] has no buffer\n", id);
2835 ret = LB_STATUS_ERROR_FAULT;
2839 slave = package_slave(pkg);
2841 ErrPrint("Package[%s] has no slave\n", pkgname);
2842 ret = LB_STATUS_ERROR_INVALID;
2847 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2849 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2850 ret = LB_STATUS_ERROR_FAULT;
2855 packet_ref((struct packet *)packet);
2856 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2857 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2858 struct script_info *script;
2861 script = instance_pd_script(inst);
2863 ret = LB_STATUS_ERROR_FAULT;
2867 e = script_handler_evas(script);
2869 ret = LB_STATUS_ERROR_FAULT;
2873 script_handler_update_pointer(script, x, y, -1);
2874 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
2876 struct access_cbdata *cbdata;
2878 cbdata = malloc(sizeof(*cbdata));
2880 ret = LB_STATUS_ERROR_MEMORY;
2882 cbdata->inst = instance_ref(inst);
2883 cbdata->status = ret;
2885 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2886 instance_unref(cbdata->inst);
2888 ret = LB_STATUS_ERROR_FAULT;
2890 ret = LB_STATUS_SUCCESS;
2895 ErrPrint("Unsupported package\n");
2896 ret = LB_STATUS_ERROR_INVALID;
2900 result = packet_create_reply(packet, "i", ret);
2902 ErrPrint("Failed to create a reply packet\n");
2907 static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const struct packet *packet)
2909 struct packet *result;
2910 struct client_node *client;
2911 const char *pkgname;
2917 struct inst_info *inst;
2918 const struct pkg_info *pkg;
2920 client = client_find_by_pid(pid);
2922 ErrPrint("Client %d is not exists\n", pid);
2923 ret = LB_STATUS_ERROR_NOT_EXIST;
2927 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2929 ErrPrint("Invalid parameter\n");
2930 ret = LB_STATUS_ERROR_INVALID;
2934 DbgPrint("%s %s %lf %d %d\n", pkgname, id, timestamp, x, y);
2937 * Trust the package name which are sent by the client.
2938 * The package has to be a livebox package name.
2940 inst = package_find_instance_by_id(pkgname, id);
2942 ErrPrint("Instance[%s] is not exists\n", id);
2943 ret = LB_STATUS_ERROR_NOT_EXIST;
2947 pkg = instance_package(inst);
2949 ErrPrint("Package[%s] info is not found\n", pkgname);
2950 ret = LB_STATUS_ERROR_FAULT;
2954 if (package_is_fault(pkg)) {
2957 * If the package is registered as fault module,
2958 * slave has not load it, so we don't need to do anything at here!
2960 DbgPrint("Package[%s] is faulted\n", pkgname);
2961 ret = LB_STATUS_ERROR_FAULT;
2962 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2963 struct buffer_info *buffer;
2964 struct slave_node *slave;
2965 // struct packet *packet;
2967 buffer = instance_pd_buffer(inst);
2969 ErrPrint("Instance[%s] has no buffer\n", id);
2970 ret = LB_STATUS_ERROR_FAULT;
2974 slave = package_slave(pkg);
2976 ErrPrint("Package[%s] has no slave\n", pkgname);
2977 ret = LB_STATUS_ERROR_INVALID;
2982 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2984 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2985 ret = LB_STATUS_ERROR_FAULT;
2989 DbgPrint("Buffer type PD\n");
2991 packet_ref((struct packet *)packet);
2992 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2993 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2994 struct script_info *script;
2997 script = instance_pd_script(inst);
2999 DbgPrint("Script is not created yet\n");
3000 ret = LB_STATUS_ERROR_FAULT;
3004 e = script_handler_evas(script);
3006 DbgPrint("Evas is not exists\n");
3007 ret = LB_STATUS_ERROR_FAULT;
3011 script_handler_update_pointer(script, x, y, -1);
3012 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
3014 struct access_cbdata *cbdata;
3016 cbdata = malloc(sizeof(*cbdata));
3018 ErrPrint("Heap: %s\n", strerror(errno));
3019 ret = LB_STATUS_ERROR_MEMORY;
3021 cbdata->inst = instance_ref(inst);
3022 cbdata->status = ret;
3024 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3025 DbgPrint("Failed to add timer\n");
3026 instance_unref(cbdata->inst);
3028 ret = LB_STATUS_ERROR_FAULT;
3030 DbgPrint("Timer is added\n");
3031 ret = LB_STATUS_SUCCESS;
3035 DbgPrint("Returns: %d\n", ret);
3038 ErrPrint("Unsupported package\n");
3039 ret = LB_STATUS_ERROR_INVALID;
3043 result = packet_create_reply(packet, "i", ret);
3045 ErrPrint("Failed to create a reply packet\n");
3050 static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
3052 struct packet *result;
3053 struct client_node *client;
3054 const char *pkgname;
3060 struct inst_info *inst;
3061 const struct pkg_info *pkg;
3063 client = client_find_by_pid(pid);
3065 ErrPrint("Client %d is not exists\n", pid);
3066 ret = LB_STATUS_ERROR_NOT_EXIST;
3070 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3072 ErrPrint("Invalid parameter\n");
3073 ret = LB_STATUS_ERROR_INVALID;
3079 * Trust the package name which are sent by the client.
3080 * The package has to be a livebox package name.
3082 inst = package_find_instance_by_id(pkgname, id);
3084 ErrPrint("Instance[%s] is not exists\n", id);
3085 ret = LB_STATUS_ERROR_NOT_EXIST;
3089 pkg = instance_package(inst);
3091 ErrPrint("Package[%s] info is not found\n", pkgname);
3092 ret = LB_STATUS_ERROR_FAULT;
3096 if (package_is_fault(pkg)) {
3099 * If the package is registered as fault module,
3100 * slave has not load it, so we don't need to do anything at here!
3102 DbgPrint("Package[%s] is faulted\n", pkgname);
3103 ret = LB_STATUS_ERROR_FAULT;
3104 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3105 struct buffer_info *buffer;
3106 struct slave_node *slave;
3107 // struct packet *packet;
3109 buffer = instance_pd_buffer(inst);
3111 ErrPrint("Instance[%s] has no buffer\n", id);
3112 ret = LB_STATUS_ERROR_FAULT;
3116 slave = package_slave(pkg);
3118 ErrPrint("Package[%s] has no slave\n", pkgname);
3119 ret = LB_STATUS_ERROR_INVALID;
3124 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3126 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3127 ret = LB_STATUS_ERROR_FAULT;
3132 packet_ref((struct packet *)packet);
3133 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3134 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3135 struct script_info *script;
3138 script = instance_pd_script(inst);
3140 ret = LB_STATUS_ERROR_FAULT;
3144 e = script_handler_evas(script);
3146 ret = LB_STATUS_ERROR_FAULT;
3150 script_handler_update_pointer(script, x, y, -1);
3151 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
3153 struct access_cbdata *cbdata;
3155 cbdata = malloc(sizeof(*cbdata));
3157 ret = LB_STATUS_ERROR_MEMORY;
3159 cbdata->inst = instance_ref(inst);
3160 cbdata->status = ret;
3162 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3163 instance_unref(cbdata->inst);
3165 ret = LB_STATUS_ERROR_FAULT;
3167 ret = LB_STATUS_SUCCESS;
3172 ErrPrint("Unsupported package\n");
3173 ret = LB_STATUS_ERROR_INVALID;
3177 result = packet_create_reply(packet, "i", ret);
3179 ErrPrint("Failed to create a reply packet\n");
3184 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
3186 struct client_node *client;
3187 const char *pkgname;
3193 struct inst_info *inst;
3194 const struct pkg_info *pkg;
3196 client = client_find_by_pid(pid);
3198 ErrPrint("Client %d is not exists\n", pid);
3199 ret = LB_STATUS_ERROR_NOT_EXIST;
3203 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3205 ErrPrint("Invalid parameter\n");
3206 ret = LB_STATUS_ERROR_INVALID;
3212 * Trust the package name which are sent by the client.
3213 * The package has to be a livebox package name.
3215 inst = package_find_instance_by_id(pkgname, id);
3217 ErrPrint("Instance[%s] is not exists\n", id);
3218 ret = LB_STATUS_ERROR_NOT_EXIST;
3222 pkg = instance_package(inst);
3224 ErrPrint("Package[%s] info is not found\n", pkgname);
3225 ret = LB_STATUS_ERROR_FAULT;
3229 if (package_is_fault(pkg)) {
3232 * If the package is registered as fault module,
3233 * slave has not load it, so we don't need to do anything at here!
3235 DbgPrint("Package[%s] is faulted\n", pkgname);
3236 ret = LB_STATUS_ERROR_FAULT;
3237 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3238 struct buffer_info *buffer;
3239 struct slave_node *slave;
3240 // struct packet *packet;
3242 buffer = instance_pd_buffer(inst);
3244 ErrPrint("Instance[%s] has no buffer\n", id);
3245 ret = LB_STATUS_ERROR_FAULT;
3249 slave = package_slave(pkg);
3251 ErrPrint("Package[%s] has no slave\n", pkgname);
3252 ret = LB_STATUS_ERROR_INVALID;
3257 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3259 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3260 ret = LB_STATUS_ERROR_FAULT;
3265 packet_ref((struct packet *)packet);
3266 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3267 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3268 struct script_info *script;
3271 script = instance_pd_script(inst);
3273 ret = LB_STATUS_ERROR_FAULT;
3277 e = script_handler_evas(script);
3279 ret = LB_STATUS_ERROR_FAULT;
3283 script_handler_update_pointer(script, x, y, -1);
3285 * \TODO: Push up the KEY_DOWN event
3289 ErrPrint("Unsupported package\n");
3290 ret = LB_STATUS_ERROR_INVALID;
3294 /*! \note No reply packet */
3298 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
3300 struct client_node *client;
3304 client = client_find_by_pid(pid);
3306 ErrPrint("Client %d is paused - manually reported\n", pid);
3307 ret = LB_STATUS_ERROR_NOT_EXIST;
3311 ret = packet_get(packet, "d", ×tamp);
3313 ErrPrint("Invalid parameter\n");
3314 ret = LB_STATUS_ERROR_INVALID;
3319 DbgPrint("XMONITOR enabled. ignore client paused request\n");
3321 xmonitor_pause(client);
3327 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
3329 struct client_node *client;
3333 client = client_find_by_pid(pid);
3335 ErrPrint("Client %d is not exists\n", pid);
3339 ret = packet_get(packet, "d", ×tamp);
3341 ErrPrint("Invalid parameter\n");
3346 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
3348 xmonitor_resume(client);
3354 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
3356 struct client_node *client;
3357 const char *pkgname;
3363 struct inst_info *inst;
3364 const struct pkg_info *pkg;
3366 client = client_find_by_pid(pid);
3368 ErrPrint("Client %d is not exists\n", pid);
3369 ret = LB_STATUS_ERROR_NOT_EXIST;
3373 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3375 ErrPrint("Invalid parameter\n");
3376 ret = LB_STATUS_ERROR_INVALID;
3382 * Trust the package name which are sent by the client.
3383 * The package has to be a livebox package name.
3385 inst = package_find_instance_by_id(pkgname, id);
3387 ErrPrint("Instance[%s] is not exists\n", id);
3388 ret = LB_STATUS_ERROR_NOT_EXIST;
3392 pkg = instance_package(inst);
3394 ErrPrint("Package[%s] info is not found\n", pkgname);
3395 ret = LB_STATUS_ERROR_FAULT;
3399 if (package_is_fault(pkg)) {
3402 * If the package is registered as fault module,
3403 * slave has not load it, so we don't need to do anything at here!
3405 DbgPrint("Package[%s] is faulted\n", pkgname);
3406 ret = LB_STATUS_ERROR_FAULT;
3407 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3408 struct buffer_info *buffer;
3409 struct slave_node *slave;
3410 // struct packet *packet;
3412 buffer = instance_pd_buffer(inst);
3414 ErrPrint("Instance[%s] has no buffer\n", id);
3415 ret = LB_STATUS_ERROR_FAULT;
3419 slave = package_slave(pkg);
3421 ErrPrint("Package[%s] has no slave\n", pkgname);
3422 ret = LB_STATUS_ERROR_INVALID;
3427 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3429 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3430 ret = LB_STATUS_ERROR_FAULT;
3435 packet_ref((struct packet *)packet);
3436 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3437 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3438 struct script_info *script;
3441 script = instance_pd_script(inst);
3443 ret = LB_STATUS_ERROR_FAULT;
3447 e = script_handler_evas(script);
3449 ret = LB_STATUS_ERROR_FAULT;
3453 script_handler_update_pointer(script, x, y, -1);
3455 * \TODO: Push up the KEY_UP event
3459 ErrPrint("Unsupported package\n");
3460 ret = LB_STATUS_ERROR_INVALID;
3464 /*! \note No reply packet */
3468 static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
3470 struct packet *result;
3471 struct client_node *client;
3472 const char *pkgname;
3478 struct inst_info *inst;
3479 const struct pkg_info *pkg;
3481 client = client_find_by_pid(pid);
3483 ErrPrint("Client %d is not exists\n", pid);
3484 ret = LB_STATUS_ERROR_NOT_EXIST;
3488 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3490 ErrPrint("Parameter is not matched\n");
3491 ret = LB_STATUS_ERROR_INVALID;
3497 * Trust the package name which are sent by the client.
3498 * The package has to be a livebox package name.
3500 inst = package_find_instance_by_id(pkgname, id);
3502 ErrPrint("Instance[%s] is not exists\n", id);
3503 ret = LB_STATUS_ERROR_NOT_EXIST;
3507 pkg = instance_package(inst);
3509 ErrPrint("Package[%s] info is not exists\n", pkgname);
3510 ret = LB_STATUS_ERROR_FAULT;
3514 if (package_is_fault(pkg)) {
3517 * If the package is registered as fault module,
3518 * slave has not load it, so we don't need to do anything at here!
3520 DbgPrint("Package[%s] is faulted\n", pkgname);
3521 ret = LB_STATUS_ERROR_FAULT;
3522 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3523 struct buffer_info *buffer;
3524 struct slave_node *slave;
3525 //struct packet *packet;
3527 buffer = instance_lb_buffer(inst);
3529 ErrPrint("Instance[%s] has no buffer\n", id);
3530 ret = LB_STATUS_ERROR_FAULT;
3534 slave = package_slave(pkg);
3536 ErrPrint("Package[%s] has no slave\n", pkgname);
3537 ret = LB_STATUS_ERROR_INVALID;
3542 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3544 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3545 ret = LB_STATUS_ERROR_FAULT;
3550 packet_ref((struct packet *)packet);
3551 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3552 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3553 struct script_info *script;
3556 script = instance_lb_script(inst);
3558 ret = LB_STATUS_ERROR_FAULT;
3562 e = script_handler_evas(script);
3564 ret = LB_STATUS_ERROR_FAULT;
3568 script_handler_update_pointer(script, x, y, -1);
3569 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
3571 struct access_cbdata *cbdata;
3573 cbdata = malloc(sizeof(*cbdata));
3575 ret = LB_STATUS_ERROR_MEMORY;
3577 cbdata->inst = instance_ref(inst);
3578 cbdata->status = ret;
3580 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3581 instance_unref(cbdata->inst);
3583 ret = LB_STATUS_ERROR_FAULT;
3585 ret = LB_STATUS_SUCCESS;
3590 ErrPrint("Unsupported package\n");
3591 ret = LB_STATUS_ERROR_INVALID;
3595 result = packet_create_reply(packet, "i", ret);
3597 ErrPrint("Failed to create a reply packet\n");
3602 static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
3604 struct packet *result;
3605 struct client_node *client;
3606 const char *pkgname;
3612 struct inst_info *inst;
3613 const struct pkg_info *pkg;
3615 client = client_find_by_pid(pid);
3617 ErrPrint("Client %d is not exists\n", pid);
3618 ret = LB_STATUS_ERROR_NOT_EXIST;
3622 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3624 ErrPrint("Parameter is not matched\n");
3625 ret = LB_STATUS_ERROR_INVALID;
3631 * Trust the package name which are sent by the client.
3632 * The package has to be a livebox package name.
3634 inst = package_find_instance_by_id(pkgname, id);
3636 ErrPrint("Instance[%s] is not exists\n", id);
3637 ret = LB_STATUS_ERROR_NOT_EXIST;
3641 pkg = instance_package(inst);
3643 ErrPrint("Package[%s] info is not exists\n", pkgname);
3644 ret = LB_STATUS_ERROR_FAULT;
3648 if (package_is_fault(pkg)) {
3651 * If the package is registered as fault module,
3652 * slave has not load it, so we don't need to do anything at here!
3654 DbgPrint("Package[%s] is faulted\n", pkgname);
3655 ret = LB_STATUS_ERROR_FAULT;
3656 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3657 struct buffer_info *buffer;
3658 struct slave_node *slave;
3659 //struct packet *packet;
3661 buffer = instance_lb_buffer(inst);
3663 ErrPrint("Instance[%s] has no buffer\n", id);
3664 ret = LB_STATUS_ERROR_FAULT;
3668 slave = package_slave(pkg);
3670 ErrPrint("Package[%s] has no slave\n", pkgname);
3671 ret = LB_STATUS_ERROR_INVALID;
3676 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3678 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3679 ret = LB_STATUS_ERROR_FAULT;
3684 packet_ref((struct packet *)packet);
3685 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3686 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3687 struct script_info *script;
3690 script = instance_lb_script(inst);
3692 ret = LB_STATUS_ERROR_FAULT;
3696 e = script_handler_evas(script);
3698 ret = LB_STATUS_ERROR_FAULT;
3702 script_handler_update_pointer(script, x, y, -1);
3703 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
3705 struct access_cbdata *cbdata;
3707 cbdata = malloc(sizeof(*cbdata));
3709 ret = LB_STATUS_ERROR_MEMORY;
3711 cbdata->inst = instance_ref(inst);
3712 cbdata->status = ret;
3714 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3715 instance_unref(cbdata->inst);
3717 ret = LB_STATUS_ERROR_FAULT;
3719 ret = LB_STATUS_SUCCESS;
3724 ErrPrint("Unsupported package\n");
3725 ret = LB_STATUS_ERROR_INVALID;
3729 result = packet_create_reply(packet, "i", ret);
3731 ErrPrint("Failed to create a reply packet\n");
3736 static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet)
3738 struct packet *result;
3739 struct client_node *client;
3740 const char *pkgname;
3746 struct inst_info *inst;
3747 const struct pkg_info *pkg;
3749 client = client_find_by_pid(pid);
3751 ErrPrint("Client %d is not exists\n", pid);
3752 ret = LB_STATUS_ERROR_NOT_EXIST;
3756 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3758 ErrPrint("Parameter is not matched\n");
3759 ret = LB_STATUS_ERROR_INVALID;
3765 * Trust the package name which are sent by the client.
3766 * The package has to be a livebox package name.
3768 inst = package_find_instance_by_id(pkgname, id);
3770 ErrPrint("Instance[%s] is not exists\n", id);
3771 ret = LB_STATUS_ERROR_NOT_EXIST;
3775 pkg = instance_package(inst);
3777 ErrPrint("Package[%s] info is not exists\n", pkgname);
3778 ret = LB_STATUS_ERROR_FAULT;
3782 if (package_is_fault(pkg)) {
3785 * If the package is registered as fault module,
3786 * slave has not load it, so we don't need to do anything at here!
3788 DbgPrint("Package[%s] is faulted\n", pkgname);
3789 ret = LB_STATUS_ERROR_FAULT;
3790 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3791 struct buffer_info *buffer;
3792 struct slave_node *slave;
3793 //struct packet *packet;
3795 buffer = instance_lb_buffer(inst);
3797 ErrPrint("Instance[%s] has no buffer\n", id);
3798 ret = LB_STATUS_ERROR_FAULT;
3802 slave = package_slave(pkg);
3804 ErrPrint("Package[%s] has no slave\n", pkgname);
3805 ret = LB_STATUS_ERROR_INVALID;
3810 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3812 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3813 ret = LB_STATUS_ERROR_FAULT;
3818 packet_ref((struct packet *)packet);
3819 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3820 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3821 struct script_info *script;
3824 script = instance_lb_script(inst);
3826 ret = LB_STATUS_ERROR_FAULT;
3830 e = script_handler_evas(script);
3832 ret = LB_STATUS_ERROR_FAULT;
3836 script_handler_update_pointer(script, x, y, -1);
3837 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
3839 struct access_cbdata *cbdata;
3841 cbdata = malloc(sizeof(*cbdata));
3843 ret = LB_STATUS_ERROR_MEMORY;
3845 cbdata->inst = instance_ref(inst);
3846 cbdata->status = ret;
3848 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3849 instance_unref(cbdata->inst);
3851 ret = LB_STATUS_ERROR_FAULT;
3853 ret = LB_STATUS_SUCCESS;
3858 ErrPrint("Unsupported package\n");
3859 ret = LB_STATUS_ERROR_INVALID;
3863 result = packet_create_reply(packet, "i", ret);
3865 ErrPrint("Failed to create a reply packet\n");
3870 static struct packet *client_lb_access_value_change(pid_t pid, int handle, const struct packet *packet)
3872 struct packet *result;
3873 struct client_node *client;
3874 const char *pkgname;
3878 struct inst_info *inst;
3879 const struct pkg_info *pkg;
3883 client = client_find_by_pid(pid);
3885 ErrPrint("Client %d is not exist\n", pid);
3886 ret = LB_STATUS_ERROR_NOT_EXIST;
3890 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3892 ErrPrint("Parameter is not matched\n");
3893 ret = LB_STATUS_ERROR_INVALID;
3897 inst = package_find_instance_by_id(pkgname, id);
3899 ErrPrint("Instance[%s] is not exists\n", id);
3900 ret = LB_STATUS_ERROR_NOT_EXIST;
3904 pkg = instance_package(inst);
3906 ErrPrint("Package[%s] info is not exists\n", pkgname);
3907 ret = LB_STATUS_ERROR_FAULT;
3911 if (package_is_fault(pkg)) {
3912 ret = LB_STATUS_ERROR_FAULT;
3913 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3914 struct buffer_info *buffer;
3915 struct slave_node *slave;
3917 buffer = instance_lb_buffer(inst);
3919 ErrPrint("Instance[%s] has no buffer\n", id);
3920 ret = LB_STATUS_ERROR_FAULT;
3924 slave = package_slave(pkg);
3926 ErrPrint("Slave is not exists\n");
3927 ret = LB_STATUS_ERROR_INVALID;
3931 packet_ref((struct packet *)packet);
3932 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3934 * Enen if it fails to send packet,
3935 * The packet will be unref'd
3936 * So we don't need to check the ret value.
3938 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3939 struct script_info *script;
3942 script = instance_lb_script(inst);
3944 ErrPrint("Instance has no script\n");
3945 ret = LB_STATUS_ERROR_FAULT;
3949 e = script_handler_evas(script);
3951 ErrPrint("Script has no evas\n");
3952 ret = LB_STATUS_ERROR_INVALID;
3956 script_handler_update_pointer(script, x, y, -1);
3957 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, timestamp);
3959 struct access_cbdata *cbdata;
3961 cbdata = malloc(sizeof(*cbdata));
3963 ret = LB_STATUS_ERROR_MEMORY;
3965 cbdata->inst = instance_ref(inst);
3966 cbdata->status = ret;
3968 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3969 instance_unref(cbdata->inst);
3971 ret = LB_STATUS_ERROR_FAULT;
3973 ret = LB_STATUS_SUCCESS;
3978 ErrPrint("Unsupported package\n");
3979 ret = LB_STATUS_ERROR_INVALID;
3983 result = packet_create_reply(packet, "i", ret);
3985 ErrPrint("Failed to create a reply packet\n");
3990 static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
3992 struct packet *result;
3993 struct client_node *client;
3994 const char *pkgname;
4000 struct inst_info *inst;
4001 const struct pkg_info *pkg;
4003 client = client_find_by_pid(pid);
4005 ErrPrint("Client %d is not exists\n", pid);
4006 ret = LB_STATUS_ERROR_NOT_EXIST;
4010 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4012 ErrPrint("Parameter is not matched\n");
4013 ret = LB_STATUS_ERROR_INVALID;
4019 * Trust the package name which are sent by the client.
4020 * The package has to be a livebox package name.
4022 inst = package_find_instance_by_id(pkgname, id);
4024 ErrPrint("Instance[%s] is not exists\n", id);
4025 ret = LB_STATUS_ERROR_NOT_EXIST;
4029 pkg = instance_package(inst);
4031 ErrPrint("Package[%s] info is not exists\n", pkgname);
4032 ret = LB_STATUS_ERROR_FAULT;
4036 if (package_is_fault(pkg)) {
4039 * If the package is registered as fault module,
4040 * slave has not load it, so we don't need to do anything at here!
4042 DbgPrint("Package[%s] is faulted\n", pkgname);
4043 ret = LB_STATUS_ERROR_FAULT;
4044 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4045 struct buffer_info *buffer;
4046 struct slave_node *slave;
4047 //struct packet *packet;
4049 buffer = instance_lb_buffer(inst);
4051 ErrPrint("Instance[%s] has no buffer\n", id);
4052 ret = LB_STATUS_ERROR_FAULT;
4056 slave = package_slave(pkg);
4058 ErrPrint("Package[%s] has no slave\n", pkgname);
4059 ret = LB_STATUS_ERROR_INVALID;
4064 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4066 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4067 ret = LB_STATUS_ERROR_FAULT;
4072 packet_ref((struct packet *)packet);
4073 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4074 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4075 struct script_info *script;
4078 script = instance_lb_script(inst);
4080 ret = LB_STATUS_ERROR_FAULT;
4084 e = script_handler_evas(script);
4086 ret = LB_STATUS_ERROR_FAULT;
4090 script_handler_update_pointer(script, x, y, -1);
4091 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
4093 struct access_cbdata *cbdata;
4095 cbdata = malloc(sizeof(*cbdata));
4097 ret = LB_STATUS_ERROR_MEMORY;
4099 cbdata->inst = instance_ref(inst);
4100 cbdata->status = ret;
4102 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4103 instance_unref(cbdata->inst);
4105 ret = LB_STATUS_ERROR_FAULT;
4107 ret = LB_STATUS_SUCCESS;
4112 ErrPrint("Unsupported package\n");
4113 ret = LB_STATUS_ERROR_INVALID;
4117 result = packet_create_reply(packet, "i", ret);
4119 ErrPrint("Failed to create a reply packet\n");
4124 static struct packet *client_lb_access_scroll(pid_t pid, int handle, const struct packet *packet)
4126 struct packet *result;
4127 struct client_node *client;
4128 const char *pkgname;
4132 struct inst_info *inst;
4133 const struct pkg_info *pkg;
4137 client = client_find_by_pid(pid);
4139 ErrPrint("Client %d is not exist\n", pid);
4140 ret = LB_STATUS_ERROR_NOT_EXIST;
4144 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4146 ErrPrint("Parameter is not matched\n");
4147 ret = LB_STATUS_ERROR_INVALID;
4151 inst = package_find_instance_by_id(pkgname, id);
4153 ErrPrint("Instance[%s] is not exists\n", id);
4154 ret = LB_STATUS_ERROR_NOT_EXIST;
4158 pkg = instance_package(inst);
4160 ErrPrint("Package[%s] info is not exists\n", pkgname);
4161 ret = LB_STATUS_ERROR_FAULT;
4165 if (package_is_fault(pkg)) {
4166 ret = LB_STATUS_ERROR_FAULT;
4167 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4168 struct buffer_info *buffer;
4169 struct slave_node *slave;
4171 buffer = instance_lb_buffer(inst);
4173 ErrPrint("Instance[%s] has no buffer\n", id);
4174 ret = LB_STATUS_ERROR_FAULT;
4178 slave = package_slave(pkg);
4180 ErrPrint("Slave is not exists\n");
4181 ret = LB_STATUS_ERROR_INVALID;
4185 packet_ref((struct packet *)packet);
4186 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4188 * Enen if it fails to send packet,
4189 * The packet will be unref'd
4190 * So we don't need to check the ret value.
4192 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4193 struct script_info *script;
4196 script = instance_lb_script(inst);
4198 ErrPrint("Instance has no script\n");
4199 ret = LB_STATUS_ERROR_FAULT;
4203 e = script_handler_evas(script);
4205 ErrPrint("Instance has no evas\n");
4206 ret = LB_STATUS_ERROR_INVALID;
4210 script_handler_update_pointer(script, x, y, -1);
4211 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
4213 struct access_cbdata *cbdata;
4215 cbdata = malloc(sizeof(*cbdata));
4217 ret = LB_STATUS_ERROR_MEMORY;
4219 cbdata->inst = instance_ref(inst);
4220 cbdata->status = ret;
4222 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4223 instance_unref(cbdata->inst);
4225 ret = LB_STATUS_ERROR_FAULT;
4227 ret = LB_STATUS_SUCCESS;
4232 ErrPrint("Unsupported package\n");
4233 ret = LB_STATUS_ERROR_INVALID;
4237 result = packet_create_reply(packet, "i", ret);
4239 ErrPrint("Failed to create a reply packet\n");
4244 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
4246 struct packet *result;
4247 struct client_node *client;
4248 const char *pkgname;
4254 struct inst_info *inst;
4255 const struct pkg_info *pkg;
4257 client = client_find_by_pid(pid);
4259 ErrPrint("Client %d is not exists\n", pid);
4260 ret = LB_STATUS_ERROR_NOT_EXIST;
4264 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4266 ErrPrint("Parameter is not matched\n");
4267 ret = LB_STATUS_ERROR_INVALID;
4273 * Trust the package name which are sent by the client.
4274 * The package has to be a livebox package name.
4276 inst = package_find_instance_by_id(pkgname, id);
4278 ErrPrint("Instance[%s] is not exists\n", id);
4279 ret = LB_STATUS_ERROR_NOT_EXIST;
4283 pkg = instance_package(inst);
4285 ErrPrint("Package[%s] info is not exists\n", pkgname);
4286 ret = LB_STATUS_ERROR_INVALID;
4290 if (package_is_fault(pkg)) {
4293 * If the package is registered as fault module,
4294 * slave has not load it, so we don't need to do anything at here!
4296 DbgPrint("Package[%s] is faulted\n", pkgname);
4297 ret = LB_STATUS_ERROR_FAULT;
4298 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4299 struct buffer_info *buffer;
4300 struct slave_node *slave;
4301 //struct packet *packet;
4303 buffer = instance_lb_buffer(inst);
4305 ErrPrint("Instance[%s] has no buffer\n", id);
4306 ret = LB_STATUS_ERROR_FAULT;
4310 slave = package_slave(pkg);
4312 ErrPrint("Package[%s] has no slave\n", pkgname);
4313 ret = LB_STATUS_ERROR_INVALID;
4318 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4320 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4321 ret = LB_STATUS_ERROR_FAULT;
4326 packet_ref((struct packet *)packet);
4327 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4328 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4329 struct script_info *script;
4332 script = instance_lb_script(inst);
4334 ErrPrint("Instance has no script\n");
4335 ret = LB_STATUS_ERROR_FAULT;
4339 e = script_handler_evas(script);
4341 ErrPrint("Script has no Evas\n");
4342 ret = LB_STATUS_ERROR_INVALID;
4346 script_handler_update_pointer(script, x, y, -1);
4347 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
4349 struct access_cbdata *cbdata;
4351 cbdata = malloc(sizeof(*cbdata));
4353 ret = LB_STATUS_ERROR_MEMORY;
4355 cbdata->inst = instance_ref(inst);
4356 cbdata->status = ret;
4358 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4359 instance_unref(cbdata->inst);
4361 ret = LB_STATUS_ERROR_FAULT;
4363 ret = LB_STATUS_SUCCESS;
4368 ErrPrint("Unsupported package\n");
4369 ret = LB_STATUS_ERROR_INVALID;
4373 result = packet_create_reply(packet, "i", ret);
4375 ErrPrint("Failed to create a reply packet\n");
4380 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
4382 struct client_node *client;
4383 const char *pkgname;
4389 struct inst_info *inst;
4390 const struct pkg_info *pkg;
4392 client = client_find_by_pid(pid);
4394 ErrPrint("Client %d is not exists\n", pid);
4395 ret = LB_STATUS_ERROR_NOT_EXIST;
4399 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4401 ErrPrint("Parameter is not matched\n");
4402 ret = LB_STATUS_ERROR_INVALID;
4408 * Trust the package name which are sent by the client.
4409 * The package has to be a livebox package name.
4411 inst = package_find_instance_by_id(pkgname, id);
4413 ErrPrint("Instance[%s] is not exists\n", id);
4414 ret = LB_STATUS_ERROR_NOT_EXIST;
4418 pkg = instance_package(inst);
4420 ErrPrint("Package[%s] info is not exists\n", pkgname);
4421 ret = LB_STATUS_ERROR_FAULT;
4425 if (package_is_fault(pkg)) {
4428 * If the package is registered as fault module,
4429 * slave has not load it, so we don't need to do anything at here!
4431 DbgPrint("Package[%s] is faulted\n", pkgname);
4432 ret = LB_STATUS_ERROR_FAULT;
4433 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4434 struct buffer_info *buffer;
4435 struct slave_node *slave;
4436 //struct packet *packet;
4438 buffer = instance_lb_buffer(inst);
4440 ErrPrint("Instance[%s] has no buffer\n", id);
4441 ret = LB_STATUS_ERROR_FAULT;
4445 slave = package_slave(pkg);
4447 ErrPrint("Package[%s] has no slave\n", pkgname);
4448 ret = LB_STATUS_ERROR_INVALID;
4453 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4455 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4456 ret = LB_STATUS_ERROR_FAULT;
4461 packet_ref((struct packet *)packet);
4462 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4463 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4464 struct script_info *script;
4467 script = instance_lb_script(inst);
4469 ret = LB_STATUS_ERROR_FAULT;
4473 e = script_handler_evas(script);
4475 ret = LB_STATUS_ERROR_FAULT;
4479 script_handler_update_pointer(script, x, y, -1);
4482 * \TODO: Feed up this KEY_DOWN event
4486 ErrPrint("Unsupported package\n");
4487 ret = LB_STATUS_ERROR_INVALID;
4491 /*! \note No reply packet */
4495 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
4497 struct client_node *client;
4498 const char *pkgname;
4504 struct inst_info *inst;
4505 const struct pkg_info *pkg;
4507 client = client_find_by_pid(pid);
4509 ErrPrint("Client %d is not exists\n", pid);
4510 ret = LB_STATUS_ERROR_NOT_EXIST;
4514 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4516 ErrPrint("Parameter is not matched\n");
4517 ret = LB_STATUS_ERROR_INVALID;
4523 * Trust the package name which are sent by the client.
4524 * The package has to be a livebox package name.
4526 inst = package_find_instance_by_id(pkgname, id);
4528 ErrPrint("Instance[%s] is not exists\n", id);
4529 ret = LB_STATUS_ERROR_NOT_EXIST;
4533 pkg = instance_package(inst);
4535 ErrPrint("Package[%s] info is not exists\n", pkgname);
4536 ret = LB_STATUS_ERROR_FAULT;
4540 if (package_is_fault(pkg)) {
4543 * If the package is registered as fault module,
4544 * slave has not load it, so we don't need to do anything at here!
4546 DbgPrint("Package[%s] is faulted\n", pkgname);
4547 ret = LB_STATUS_ERROR_FAULT;
4548 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4549 struct buffer_info *buffer;
4550 struct slave_node *slave;
4551 //struct packet *packet;
4553 buffer = instance_lb_buffer(inst);
4555 ErrPrint("Instance[%s] has no buffer\n", id);
4556 ret = LB_STATUS_ERROR_FAULT;
4560 slave = package_slave(pkg);
4562 ErrPrint("Package[%s] has no slave\n", pkgname);
4563 ret = LB_STATUS_ERROR_INVALID;
4568 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
4570 ErrPrint("Failed to create a packet[%s]\n", pkgname);
4571 ret = LB_STATUS_ERROR_FAULT;
4576 packet_ref((struct packet *)packet);
4577 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4578 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4579 struct script_info *script;
4582 script = instance_lb_script(inst);
4584 ret = LB_STATUS_ERROR_FAULT;
4588 e = script_handler_evas(script);
4590 ret = LB_STATUS_ERROR_FAULT;
4594 script_handler_update_pointer(script, x, y, -1);
4597 * \TODO: Feed up this KEY_UP event
4601 ErrPrint("Unsupported package\n");
4602 ret = LB_STATUS_ERROR_INVALID;
4606 /*! \note No reply packet */
4610 static int release_pixmap_cb(struct client_node *client, void *canvas)
4612 DbgPrint("Forcely unref the \"buffer\"\n");
4613 buffer_handler_pixmap_unref(canvas);
4614 return -1; /* Delete this callback */
4617 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 */
4619 struct packet *result;
4620 const char *pkgname;
4622 struct client_node *client;
4623 struct inst_info *inst;
4627 struct buffer_info *buffer;
4629 client = client_find_by_pid(pid);
4631 ErrPrint("Client %d is not exists\n", pid);
4635 ret = packet_get(packet, "ss", &pkgname, &id);
4637 ErrPrint("Parameter is not matched\n");
4643 * Trust the package name which are sent by the client.
4644 * The package has to be a livebox package name.
4646 inst = package_find_instance_by_id(pkgname, id);
4648 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4652 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4653 buffer = instance_lb_buffer(inst);
4655 ErrPrint("Unable to get LB buffer: %s\n", id);
4659 buf_ptr = buffer_handler_pixmap_ref(buffer);
4661 ErrPrint("Failed to ref pixmap\n");
4665 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
4667 ErrPrint("Failed to add a new client deactivate callback\n");
4668 buffer_handler_pixmap_unref(buf_ptr);
4670 pixmap = buffer_handler_pixmap(buffer);
4674 result = packet_create_reply(packet, "i", pixmap);
4676 ErrPrint("Failed to create a reply packet\n");
4681 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
4683 const char *pkgname;
4685 struct client_node *client;
4686 struct inst_info *inst;
4691 client = client_find_by_pid(pid);
4693 ErrPrint("Client %d is not exists\n", pid);
4697 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
4699 ErrPrint("Parameter is not matched\n");
4702 DbgPrint("pid[%d] pkgname[%s] id[%s] Pixmap[0x%X]\n", pid, pkgname, id, pixmap);
4706 * Trust the package name which are sent by the client.
4707 * The package has to be a livebox package name.
4709 inst = package_find_instance_by_id(pkgname, id);
4711 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4715 buf_ptr = buffer_handler_pixmap_find(pixmap);
4717 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
4721 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
4722 buffer_handler_pixmap_unref(buf_ptr);
4725 /*! \note No reply packet */
4729 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 */
4731 struct packet *result;
4732 const char *pkgname;
4734 struct client_node *client;
4735 struct inst_info *inst;
4739 struct buffer_info *buffer;
4741 client = client_find_by_pid(pid);
4743 ErrPrint("Client %d is not exists\n", pid);
4747 ret = packet_get(packet, "ss", &pkgname, &id);
4749 ErrPrint("Parameter is not matched\n");
4755 * Trust the package name which are sent by the client.
4756 * The package has to be a livebox package name.
4758 inst = package_find_instance_by_id(pkgname, id);
4760 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4764 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4765 buffer = instance_pd_buffer(inst);
4767 ErrPrint("Unable to get PD buffer (%s)\n", id);
4771 buf_ptr = buffer_handler_pixmap_ref(buffer);
4773 ErrPrint("Failed to ref pixmap\n");
4777 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
4779 buffer_handler_pixmap_unref(buf_ptr);
4781 pixmap = buffer_handler_pixmap(buffer);
4783 result = packet_create_reply(packet, "i", pixmap);
4785 ErrPrint("Failed to create a reply packet\n");
4790 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
4792 const char *pkgname;
4794 struct client_node *client;
4795 struct inst_info *inst;
4800 client = client_find_by_pid(pid);
4802 ErrPrint("Client %d is not exists\n", pid);
4806 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
4808 ErrPrint("Parameter is not matched\n");
4811 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4815 * Trust the package name which are sent by the client.
4816 * The package has to be a livebox package name.
4818 inst = package_find_instance_by_id(pkgname, id);
4820 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
4824 buf_ptr = buffer_handler_pixmap_find(pixmap);
4826 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
4830 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
4831 buffer_handler_pixmap_unref(buf_ptr);
4834 /*! \note No reply packet */
4838 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
4840 struct client_node *client;
4841 struct packet *result;
4842 const char *pkgname;
4846 struct inst_info *inst;
4848 client = client_find_by_pid(pid);
4850 ErrPrint("Client %d is not exists\n", pid);
4851 ret = LB_STATUS_ERROR_NOT_EXIST;
4856 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
4858 ErrPrint("Parameter is not matched\n");
4859 ret = LB_STATUS_ERROR_INVALID;
4864 DbgPrint("pid[%d] pkgname[%s] id[%s] pinup[%d]\n", pid, pkgname, id, pinup);
4868 * Trust the package name which are sent by the client.
4869 * The package has to be a livebox package name.
4871 inst = package_find_instance_by_id(pkgname, id);
4873 ret = LB_STATUS_ERROR_NOT_EXIST;
4874 else if (package_is_fault(instance_package(inst)))
4875 ret = LB_STATUS_ERROR_FAULT;
4877 ret = instance_set_pinup(inst, pinup);
4880 result = packet_create_reply(packet, "i", ret);
4882 ErrPrint("Failed to create a packet\n");
4887 static Eina_Bool lazy_pd_created_cb(void *data)
4889 if (instance_unref(data)) {
4891 ret = instance_client_pd_created(data, LB_STATUS_SUCCESS);
4892 DbgPrint("Send PD Create event (%d)\n", ret);
4895 return ECORE_CALLBACK_CANCEL;
4898 static Eina_Bool lazy_pd_destroyed_cb(void *data)
4900 if (instance_unref(data)) {
4901 DbgPrint("Send PD Destroy event\n");
4902 instance_client_pd_destroyed(data, LB_STATUS_SUCCESS);
4905 return ECORE_CALLBACK_CANCEL;
4908 static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
4910 struct client_node *client;
4911 struct inst_info *inst;
4912 const char *pkgname;
4918 client = client_find_by_pid(pid);
4920 ErrPrint("Client %d is not exists\n", pid);
4921 ret = LB_STATUS_ERROR_NOT_EXIST;
4925 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
4927 ErrPrint("Parameter is not correct\n");
4928 ret = LB_STATUS_ERROR_INVALID;
4932 DbgPrint("pid[%d] pkgname[%s] id[%s] %lfx%lf\n", pid, pkgname, id, x, y);
4934 inst = package_find_instance_by_id(pkgname, id);
4936 ret = LB_STATUS_ERROR_NOT_EXIST;
4937 else if (package_is_fault(instance_package(inst)))
4938 ret = LB_STATUS_ERROR_FAULT;
4939 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4940 instance_slave_set_pd_pos(inst, x, y);
4941 ret = instance_signal_emit(inst,
4942 "pd,move", util_uri_to_path(instance_id(inst)),
4943 0.0, 0.0, 0.0, 0.0, x, y, 0);
4944 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4948 instance_slave_set_pd_pos(inst, x, y);
4949 ix = x * instance_pd_width(inst);
4950 iy = y * instance_pd_height(inst);
4951 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
4952 ret = instance_signal_emit(inst,
4953 "pd,move", util_uri_to_path(instance_id(inst)),
4954 0.0, 0.0, 0.0, 0.0, x, y, 0);
4956 ErrPrint("Invalid PD type\n");
4957 ret = LB_STATUS_ERROR_INVALID;
4960 DbgPrint("Update PD position: %lfx%lf (%d)\n", x, y, ret);
4964 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
4966 struct client_node *client;
4967 struct packet *result;
4968 const char *pkgname;
4971 struct inst_info *inst;
4975 client = client_find_by_pid(pid);
4977 ErrPrint("Client %d is not exists\n", pid);
4978 ret = LB_STATUS_ERROR_NOT_EXIST;
4982 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
4984 ErrPrint("Parameter is not matched\n");
4985 ret = LB_STATUS_ERROR_INVALID;
4989 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4993 * Trust the package name which are sent by the client.
4994 * The package has to be a livebox package name.
4996 inst = package_find_instance_by_id(pkgname, id);
4998 ret = LB_STATUS_ERROR_NOT_EXIST;
4999 else if (package_is_fault(instance_package(inst)))
5000 ret = LB_STATUS_ERROR_FAULT;
5001 else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
5002 ret = LB_STATUS_ERROR_NO_SPACE;
5003 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
5004 instance_slave_set_pd_pos(inst, x, y);
5005 ret = instance_slave_open_pd(inst, client);
5006 ret = instance_signal_emit(inst,
5007 "pd,show", util_uri_to_path(instance_id(inst)),
5008 0.0, 0.0, 0.0, 0.0, x, y, 0);
5011 * PD craeted event will be send by the acquire_buffer function.
5012 * Because the slave will make request the acquire_buffer to
5015 * instance_client_pd_created(inst);
5017 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
5022 * ret value should be cared but in this case,
5023 * we ignore this for this moment, so we have to handle this error later.
5025 * if ret is less than 0, the slave has some problem.
5026 * but the script mode doesn't need slave for rendering default view of PD
5027 * so we can hanle it later.
5029 instance_slave_set_pd_pos(inst, x, y);
5030 ix = x * instance_pd_width(inst);
5031 iy = y * instance_pd_height(inst);
5033 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
5035 ret = instance_slave_open_pd(inst, client);
5036 if (ret == LB_STATUS_SUCCESS) {
5037 ret = script_handler_load(instance_pd_script(inst), 1);
5041 * Send the PD created event to the clients,
5043 if (ret == LB_STATUS_SUCCESS) {
5046 * But the created event has to be send afte return
5047 * from this function or the viewer couldn't care
5048 * the event correctly.
5050 inst = instance_ref(inst); /* To guarantee the inst */
5051 if (!ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst)) {
5052 instance_unref(inst);
5053 script_handler_unload(instance_pd_script(inst), 1);
5054 instance_slave_close_pd(inst, client);
5056 ErrPrint("Failed to add delayed timer\n");
5057 ret = LB_STATUS_ERROR_FAULT;
5060 instance_slave_close_pd(inst, client);
5063 ErrPrint("Failed to request open PD to the slave\n");
5066 ErrPrint("Invalid PD TYPE\n");
5067 ret = LB_STATUS_ERROR_INVALID;
5071 result = packet_create_reply(packet, "i", ret);
5073 ErrPrint("Failed to create a packet\n");
5078 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
5080 struct client_node *client;
5081 struct packet *result;
5082 const char *pkgname;
5085 struct inst_info *inst;
5087 client = client_find_by_pid(pid);
5089 ErrPrint("Client %d is not exists\n", pid);
5090 ret = LB_STATUS_ERROR_NOT_EXIST;
5094 ret = packet_get(packet, "ss", &pkgname, &id);
5096 ErrPrint("Parameter is not matched\n");
5097 ret = LB_STATUS_ERROR_INVALID;
5101 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
5105 * Trust the package name which are sent by the client.
5106 * The package has to be a livebox package name.
5108 inst = package_find_instance_by_id(pkgname, id);
5110 ret = LB_STATUS_ERROR_NOT_EXIST;
5111 else if (package_is_fault(instance_package(inst)))
5112 ret = LB_STATUS_ERROR_FAULT;
5113 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
5114 ret = instance_signal_emit(inst,
5115 "pd,hide", util_uri_to_path(instance_id(inst)),
5116 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
5117 ret = instance_slave_close_pd(inst, client);
5121 * release_buffer will be called by the slave after this.
5122 * Then it will send the "pd_destroyed" event to the client
5124 * instance_client_pd_destroyed(inst);
5127 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
5128 ret = script_handler_unload(instance_pd_script(inst), 1);
5129 ret = instance_slave_close_pd(inst, client);
5133 * Send the destroyed PD event to the client
5135 if (ret == LB_STATUS_SUCCESS) {
5136 inst = instance_ref(inst);
5137 if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst)) {
5138 instance_unref(inst);
5140 * How can we handle this?
5142 ret = LB_STATUS_ERROR_FAULT;
5146 ErrPrint("Invalid PD TYPE\n");
5147 ret = LB_STATUS_ERROR_INVALID;
5151 result = packet_create_reply(packet, "i", ret);
5153 ErrPrint("Failed to create a packet\n");
5158 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
5160 struct client_node *client;
5161 struct packet *result;
5162 const char *pkgname;
5164 struct pkg_info *info;
5166 client = client_find_by_pid(pid);
5168 ErrPrint("Client %d is not exists\n", pid);
5169 ret = LB_STATUS_ERROR_NOT_EXIST;
5174 ret = packet_get(packet, "s", &pkgname);
5176 ErrPrint("Parameter is not matched\n");
5177 ret = LB_STATUS_ERROR_INVALID;
5182 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
5186 * Validate the livebox package name.
5188 if (!package_is_lb_pkgname(pkgname)) {
5189 ErrPrint("%s is not a valid livebox package\n", pkgname);
5191 ret = LB_STATUS_ERROR_INVALID;
5195 info = package_find(pkgname);
5197 ret = LB_STATUS_ERROR_NOT_EXIST;
5199 ret = package_clear_fault(info);
5202 result = packet_create_reply(packet, "is", ret, pkgname);
5204 ErrPrint("Failed to create a packet\n");
5209 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
5211 const char *cluster;
5212 const char *category;
5213 struct client_node *client;
5216 client = client_find_by_pid(pid);
5218 ErrPrint("Client %d is not exists\n", pid);
5219 ret = LB_STATUS_ERROR_NOT_EXIST;
5223 ret = packet_get(packet, "ss", &cluster, &category);
5225 ErrPrint("Invalid argument\n");
5226 ret = LB_STATUS_ERROR_INVALID;
5230 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5231 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5232 ErrPrint("Invalid cluster name\n");
5238 * SUBSCRIBE cluster & sub-cluster for a client.
5240 ret = client_subscribe(client, cluster, category);
5242 package_alter_instances_to_client(client, ALTER_CREATE);
5245 /*! \note No reply packet */
5249 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
5251 const char *cluster;
5252 struct client_node *client;
5253 struct packet *result;
5256 client = client_find_by_pid(pid);
5258 ErrPrint("Client %d is not exists\n", pid);
5259 ret = LB_STATUS_ERROR_NOT_EXIST;
5263 ret = packet_get(packet, "s", &cluster);
5265 ErrPrint("Invalid parameters\n");
5266 ret = LB_STATUS_ERROR_INVALID;
5270 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
5272 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5273 ErrPrint("Invalid cluster: %s\n", cluster);
5274 ret = LB_STATUS_ERROR_INVALID;
5281 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
5284 result = packet_create_reply(packet, "i", ret);
5286 ErrPrint("Failed to create a packet\n");
5290 static inline int update_pkg_cb(struct category *category, const char *pkgname)
5295 c_name = group_cluster_name_by_category(category);
5296 s_name = group_category_name(category);
5298 if (!c_name || !s_name || !pkgname) {
5299 ErrPrint("Name is not valid\n");
5300 return EXIT_FAILURE;
5303 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
5304 slave_rpc_request_update(pkgname, "", c_name, s_name);
5306 /* Just try to create a new package */
5307 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
5309 struct inst_info *inst;
5311 timestamp = util_timestamp();
5314 * Don't need to check the subscribed clients.
5315 * Because this callback is called by the requests of clients.
5316 * It means. some clients wants to handle this instances ;)
5318 inst = instance_create(NULL, timestamp, pkgname, DEFAULT_CONTENT, c_name, s_name, DEFAULT_PERIOD, 0, 0);
5320 ErrPrint("Failed to create a new instance\n");
5322 ErrPrint("Not enough space\n");
5324 return EXIT_SUCCESS;
5327 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
5329 struct inst_info *inst;
5330 struct client_node *client;
5331 const char *pkgname;
5335 client = client_find_by_pid(pid);
5337 ErrPrint("Cilent %d is not exists\n", pid);
5341 ret = packet_get(packet, "ss", &pkgname, &id);
5343 ErrPrint("Invalid argument\n");
5347 inst = package_find_instance_by_id(pkgname, id);
5349 } else if (package_is_fault(instance_package(inst))) {
5350 } else if (instance_client(inst) != client) {
5352 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
5356 /*! \note No reply packet */
5360 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
5362 const char *cluster_id;
5363 const char *category_id;
5364 struct client_node *client;
5366 struct cluster *cluster;
5367 struct category *category;
5368 struct context_info *info;
5369 Eina_List *info_list;
5372 client = client_find_by_pid(pid);
5374 ErrPrint("Cilent %d is not exists\n", pid);
5378 ret = packet_get(packet, "ss", &cluster_id, &category_id);
5380 ErrPrint("Invalid parameter\n");
5384 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
5386 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
5387 ErrPrint("Invalid cluster name: %s\n", cluster_id);
5391 cluster = group_find_cluster(cluster_id);
5393 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
5397 category = group_find_category(cluster, category_id);
5399 ErrPrint("Category [%s] is not registered\n", category_id);
5403 info_list = group_context_info_list(category);
5404 EINA_LIST_FOREACH(info_list, l, info) {
5405 update_pkg_cb(category, group_pkgname_from_context_info(info));
5409 /*! \note No reply packet */
5413 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
5415 const char *cluster;
5416 const char *category;
5417 struct client_node *client;
5418 struct packet *result;
5421 client = client_find_by_pid(pid);
5423 ErrPrint("Client %d is not exists\n", pid);
5424 ret = LB_STATUS_ERROR_NOT_EXIST;
5428 ret = packet_get(packet, "ss", &cluster, &category);
5430 ErrPrint("Invalid paramenters\n");
5431 ret = LB_STATUS_ERROR_INVALID;
5435 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5436 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5437 ErrPrint("Invalid cluster: %s\n", cluster);
5438 ret = LB_STATUS_ERROR_INVALID;
5445 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
5448 result = packet_create_reply(packet, "i", ret);
5450 ErrPrint("Failed to create a packet\n");
5454 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
5456 const char *cluster;
5457 const char *category;
5458 struct client_node *client;
5461 client = client_find_by_pid(pid);
5463 ErrPrint("Client %d is not exists\n", pid);
5464 ret = LB_STATUS_ERROR_NOT_EXIST;
5468 ret = packet_get(packet, "ss", &cluster, &category);
5470 ErrPrint("Invalid argument\n");
5471 ret = LB_STATUS_ERROR_INVALID;
5475 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5477 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5478 ErrPrint("Invalid cluster name: %s\n", cluster);
5484 * UNSUBSCRIBE cluster & sub-cluster for a client.
5486 ret = client_unsubscribe(client, cluster, category);
5488 package_alter_instances_to_client(client, ALTER_DESTROY);
5491 /*! \note No reply packet */
5495 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
5497 struct slave_node *slave;
5498 const char *slavename;
5501 ret = packet_get(packet, "s", &slavename);
5503 ErrPrint("Parameter is not matched\n");
5507 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
5509 slave = slave_find_by_pid(pid);
5512 char pkgname[pathconf("/", _PC_PATH_MAX)];
5515 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
5516 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
5517 slave = slave_find_by_name(slavename);
5518 pkgname[0] = '\0'; /* Reset the pkgname */
5520 slave = slave_find_by_pkgname(pkgname);
5524 abi = abi_find_by_pkgname(pkgname);
5527 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
5530 slave = slave_create(slavename, 1, abi, pkgname, 0);
5532 ErrPrint("Failed to create a new slave for %s\n", slavename);
5536 DbgPrint("New slave is created (net: 0)\n");
5538 DbgPrint("Registered slave is replaced with this new one\n");
5539 abi = slave_abi(slave);
5542 slave_set_pid(slave, pid);
5543 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
5545 ErrPrint("Slave[%d] is not exists\n", pid);
5552 * After updating handle,
5553 * slave activated callback will be called.
5555 slave_rpc_update_handle(slave, handle);
5561 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
5563 struct slave_node *slave;
5564 const char *slavename;
5567 slave = slave_find_by_pid(pid);
5569 ErrPrint("Slave %d is not exists\n", pid);
5573 ret = packet_get(packet, "s", &slavename);
5575 ErrPrint("Parameter is not matched\n");
5577 slave_rpc_ping(slave);
5583 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
5585 struct slave_node *slave;
5586 struct inst_info *inst;
5587 const char *pkgname;
5592 slave = slave_find_by_pid(pid);
5594 ErrPrint("Slave %d is not exists\n", pid);
5598 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5600 ErrPrint("Parameter is not matched\n");
5604 ret = fault_info_set(slave, pkgname, id, func);
5605 DbgPrint("Slave Faulted: %s (%d)\n", slave_name(slave), ret);
5607 inst = package_find_instance_by_id(pkgname, id);
5609 DbgPrint("There is a no such instance(%s)\n", id);
5610 } else if (instance_state(inst) == INST_DESTROYED) {
5611 ErrPrint("Instance(%s) is already destroyed\n", id);
5613 ret = instance_destroy(inst);
5614 DbgPrint("Destroy instance(%s) %d\n", id, ret);
5621 static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
5623 struct slave_node *slave;
5624 struct inst_info *inst;
5625 struct pkg_info *pkg;
5626 const char *pkgname;
5629 const char *content;
5633 slave = slave_find_by_pid(pid);
5635 ErrPrint("Slave %d is not exists\n", pid);
5639 ret = packet_get(packet, "ssdss", &pkgname, &id, &priority, &content, &title);
5641 ErrPrint("Invalid parameters\n");
5645 inst = package_find_instance_by_id(pkgname, id);
5647 ErrPrint("Instance(%s) is not exists\n", id);
5649 } else if (instance_state(inst) == INST_DESTROYED) {
5650 ErrPrint("Instance(%s) is already destroyed\n", id);
5654 pkg = instance_package(inst);
5656 ErrPrint("Invalid instance\n");
5657 } else if (package_is_fault(pkg)) {
5658 ErrPrint("Faulted instance %s.\n", id);
5659 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5660 ret = instance_lb_update_begin(inst, priority, content, title);
5661 if (ret == LB_STATUS_SUCCESS)
5662 slave_freeze_ttl(slave);
5664 ErrPrint("Invalid request[%s]\n", id);
5671 static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct packet *packet)
5673 struct slave_node *slave;
5674 struct inst_info *inst;
5675 struct pkg_info *pkg;
5676 const char *pkgname;
5680 slave = slave_find_by_pid(pid);
5682 ErrPrint("Slave %d is not exists\n", pid);
5686 ret = packet_get(packet, "ss", &pkgname, &id);
5688 ErrPrint("Invalid parameters\n");
5692 inst = package_find_instance_by_id(pkgname, id);
5694 ErrPrint("Instance[%s] is not exists\n", id);
5696 } else if (instance_state(inst) == INST_DESTROYED) {
5697 ErrPrint("Instance[%s] is already destroyed\n", id);
5701 pkg = instance_package(inst);
5703 ErrPrint("Invalid instance\n");
5704 } else if (package_is_fault(pkg)) {
5705 ErrPrint("Faulted instance %s\n", id);
5706 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5707 ret = instance_lb_update_end(inst);
5708 if (ret == LB_STATUS_SUCCESS)
5709 slave_thaw_ttl(slave);
5711 ErrPrint("Invalid request[%s]\n", id);
5718 static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
5720 struct slave_node *slave;
5721 struct pkg_info *pkg;
5722 struct inst_info *inst;
5723 const char *pkgname;
5727 slave = slave_find_by_pid(pid);
5729 ErrPrint("Slave %d is not exists\n", pid);
5733 ret = packet_get(packet, "ss", &pkgname, &id);
5735 ErrPrint("Invalid parameters\n");
5739 inst = package_find_instance_by_id(pkgname, id);
5741 ErrPrint("Instance[%s] is not exists\n", id);
5745 pkg = instance_package(inst);
5747 ErrPrint("Invalid package\n");
5748 } else if (package_is_fault(pkg)) {
5749 ErrPrint("Faulted instance %s\n", id);
5750 } else if (instance_state(inst) == INST_DESTROYED) {
5751 ErrPrint("Instance[%s] is already destroyed\n", id);
5752 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5753 (void)instance_pd_update_begin(inst);
5755 ErrPrint("Invalid request[%s]\n", id);
5762 static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
5764 struct slave_node *slave;
5765 struct pkg_info *pkg;
5766 struct inst_info *inst;
5767 const char *pkgname;
5772 slave = slave_find_by_pid(pid);
5774 ErrPrint("Slave %d is not exists\n", pid);
5778 ret = packet_get(packet, "ssi", &pkgname, &id, &status);
5780 ErrPrint("Invalid parameters\n");
5784 inst = package_find_instance_by_id(pkgname, id);
5786 ErrPrint("Instance[%s] is not exists\n", id);
5790 pkg = instance_package(inst);
5792 ErrPrint("Invalid package\n");
5793 } else if (package_is_fault(pkg)) {
5794 ErrPrint("Faulted instance %s\n", id);
5795 } else if (instance_state(inst) == INST_DESTROYED) {
5796 ErrPrint("Instance[%s] is already destroyed\n", id);
5800 * Forward packet to client
5802 (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
5809 static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
5811 struct slave_node *slave;
5812 struct pkg_info *pkg;
5813 struct inst_info *inst;
5814 const char *pkgname;
5818 slave = slave_find_by_pid(pid);
5820 ErrPrint("Slave %d is not exists\n", pid);
5824 ret = packet_get(packet, "ss", &pkgname, &id);
5826 ErrPrint("Invalid parameters\n");
5830 inst = package_find_instance_by_id(pkgname, id);
5832 ErrPrint("Instance[%s] is not exists\n", id);
5836 pkg = instance_package(inst);
5838 ErrPrint("Invalid package\n");
5839 } else if (package_is_fault(pkg)) {
5840 ErrPrint("Faulted instance %s\n", id);
5841 } else if (instance_state(inst) == INST_DESTROYED) {
5842 ErrPrint("Instance[%s] is already destroyed\n", id);
5843 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5844 (void)instance_pd_update_end(inst);
5846 ErrPrint("Invalid request[%s]\n", id);
5853 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
5855 struct slave_node *slave;
5856 const char *pkgname;
5861 slave = slave_find_by_pid(pid);
5863 ErrPrint("Slave %d is not exists\n", pid);
5867 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5869 ErrPrint("Parameter is not matched\n");
5873 ret = fault_func_call(slave, pkgname, id, func);
5874 slave_give_more_ttl(slave);
5880 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
5882 struct slave_node *slave;
5883 const char *pkgname;
5888 slave = slave_find_by_pid(pid);
5890 ErrPrint("Slave %d is not exists\n", pid);
5894 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5896 ErrPrint("Parameter is not matched\n");
5900 ret = fault_func_ret(slave, pkgname, id, func);
5901 slave_give_more_ttl(slave);
5907 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
5909 struct slave_node *slave;
5910 const char *pkgname;
5912 const char *content_info;
5918 struct inst_info *inst;
5920 slave = slave_find_by_pid(pid);
5922 ErrPrint("Slave %d is not exists\n", pid);
5926 ret = packet_get(packet, "ssiidss", &pkgname, &id,
5928 &content_info, &title);
5930 ErrPrint("Parameter is not matched\n");
5934 inst = package_find_instance_by_id(pkgname, id);
5936 } else if (package_is_fault(instance_package(inst))) {
5937 ErrPrint("Faulted instance cannot make any event.\n");
5938 } else if (instance_state(inst) == INST_DESTROYED) {
5939 ErrPrint("Instance is already destroyed\n");
5943 switch (package_lb_type(instance_package(inst))) {
5944 case LB_TYPE_SCRIPT:
5945 script_handler_resize(instance_lb_script(inst), w, h);
5946 filename = util_get_file_kept_in_safe(id);
5948 (void)script_handler_parse_desc(pkgname, id,
5952 (void)script_handler_parse_desc(pkgname, id,
5953 util_uri_to_path(id), 0);
5956 case LB_TYPE_BUFFER:
5960 * text format (inst)
5962 instance_set_lb_info(inst, w, h, priority, content_info, title);
5963 instance_lb_updated_by_instance(inst);
5967 slave_give_more_ttl(slave);
5974 static struct packet *slave_hold_scroll(pid_t pid, int handle, const struct packet *packet)
5976 struct slave_node *slave;
5977 struct inst_info *inst;
5978 const char *pkgname;
5983 slave = slave_find_by_pid(pid);
5985 ErrPrint("Slave %d is not exists\n", pid);
5989 ret = packet_get(packet, "ssi", &pkgname, &id, &seize);
5991 ErrPrint("Parameter is not matched\n");
5995 inst = package_find_instance_by_id(pkgname, id);
5997 ErrPrint("No such instance(%s)\n", id);
5998 } else if (package_is_fault(instance_package(inst))) {
5999 ErrPrint("Faulted instance cannot seize the screen\n");
6000 } else if (instance_state(inst) == INST_DESTROYED) {
6001 ErrPrint("Instance(%s) is already destroyed\n", id);
6003 (void)instance_hold_scroll(inst, seize);
6010 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
6012 struct slave_node *slave;
6013 const char *pkgname;
6015 const char *descfile;
6017 struct inst_info *inst;
6019 slave = slave_find_by_pid(pid);
6021 ErrPrint("Slave %d is not exists\n", pid);
6025 ret = packet_get(packet, "sss", &pkgname, &id, &descfile);
6027 ErrPrint("Parameter is not matched\n");
6031 inst = package_find_instance_by_id(pkgname, id);
6033 } else if (package_is_fault(instance_package(inst))) {
6034 ErrPrint("Faulted package cannot make event\n");
6035 } else if (instance_state(inst) == INST_DESTROYED) {
6036 ErrPrint("Instance is already destroyed\n");
6038 switch (package_pd_type(instance_package(inst))) {
6039 case PD_TYPE_SCRIPT:
6040 DbgPrint("Script (%s)\n", id);
6041 if (script_handler_is_loaded(instance_pd_script(inst))) {
6042 (void)script_handler_parse_desc(pkgname, id,
6047 instance_set_pd_info(inst, 0, 0);
6048 case PD_TYPE_BUFFER:
6049 instance_pd_updated(pkgname, id, descfile);
6052 DbgPrint("Ignore updated DESC(%s - %s - %s)\n",
6053 pkgname, id, descfile);
6062 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
6064 struct slave_node *slave;
6065 const char *pkgname;
6068 struct inst_info *inst;
6070 slave = slave_find_by_pid(pid);
6072 ErrPrint("Slave %d is not exists\n", pid);
6076 ret = packet_get(packet, "ss", &pkgname, &id);
6078 ErrPrint("Parameter is not matched\n");
6082 inst = package_find_instance_by_id(pkgname, id);
6084 } else if (package_is_fault(instance_package(inst))) {
6086 ret = instance_destroyed(inst);
6087 DbgPrint("Destroy instance %d\n", ret);
6095 * \note for the BUFFER Type slave
6097 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
6099 enum target_type target;
6100 const char *pkgname;
6105 struct packet *result;
6106 struct slave_node *slave;
6107 struct inst_info *inst;
6108 const struct pkg_info *pkg;
6111 slave = slave_find_by_pid(pid);
6113 ErrPrint("Failed to find a slave\n");
6115 ret = LB_STATUS_ERROR_NOT_EXIST;
6119 ret = packet_get(packet, "issiii", &target, &pkgname, &id, &w, &h, &pixel_size);
6121 ErrPrint("Invalid argument\n");
6123 ret = LB_STATUS_ERROR_INVALID;
6127 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
6128 DbgPrint("No space\n");
6129 ret = LB_STATUS_ERROR_NO_SPACE;
6135 inst = package_find_instance_by_id(pkgname, id);
6137 DbgPrint("Package[%s] Id[%s] is not found\n", pkgname, id);
6138 ret = LB_STATUS_ERROR_INVALID;
6143 pkg = instance_package(inst);
6145 ret = LB_STATUS_ERROR_INVALID;
6146 if (target == TYPE_LB) {
6147 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
6148 struct buffer_info *info;
6150 info = instance_lb_buffer(inst);
6152 if (!instance_create_lb_buffer(inst)) {
6153 ErrPrint("Failed to create a LB buffer\n");
6155 info = instance_lb_buffer(inst);
6157 ErrPrint("LB buffer is not valid\n");
6158 ret = LB_STATUS_ERROR_INVALID;
6165 ret = buffer_handler_resize(info, w, h);
6166 DbgPrint("Buffer resize returns %d\n", ret);
6168 ret = buffer_handler_load(info);
6170 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
6171 id = buffer_handler_id(info);
6172 DbgPrint("Buffer handler ID: %s\n", id);
6174 DbgPrint("Failed to load a buffer(%d)\n", ret);
6177 } else if (target == TYPE_PD) {
6178 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
6179 struct buffer_info *info;
6181 DbgPrint("Slave acquire buffer for PD\n");
6183 info = instance_pd_buffer(inst);
6185 if (!instance_create_pd_buffer(inst)) {
6186 ErrPrint("Failed to create a PD buffer\n");
6188 info = instance_pd_buffer(inst);
6190 ErrPrint("PD buffer is not valid\n");
6191 ret = LB_STATUS_ERROR_INVALID;
6193 instance_client_pd_created(inst, ret);
6199 ret = buffer_handler_resize(info, w, h);
6200 DbgPrint("Buffer resize returns %d\n", ret);
6202 ret = buffer_handler_load(info);
6204 instance_set_pd_info(inst, w, h);
6205 id = buffer_handler_id(info);
6206 DbgPrint("Buffer handler ID: %s\n", id);
6208 DbgPrint("Failed to load a buffer (%d)\n", ret);
6212 * Send the PD created event to the client
6214 instance_client_pd_created(inst, ret);
6219 result = packet_create_reply(packet, "is", ret, id);
6221 ErrPrint("Failed to create a packet\n");
6226 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
6228 struct slave_node *slave;
6229 struct packet *result;
6230 enum target_type type;
6231 const char *pkgname;
6235 struct inst_info *inst;
6236 const struct pkg_info *pkg;
6239 slave = slave_find_by_pid(pid);
6241 ErrPrint("Failed to find a slave\n");
6242 ret = LB_STATUS_ERROR_NOT_EXIST;
6247 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
6248 ErrPrint("Not enough space\n");
6249 ret = LB_STATUS_ERROR_NO_SPACE;
6254 ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
6256 ErrPrint("Invalid argument\n");
6257 ret = LB_STATUS_ERROR_INVALID;
6262 inst = package_find_instance_by_id(pkgname, id);
6264 DbgPrint("Instance is not found[%s] [%s]\n", pkgname, id);
6265 ret = LB_STATUS_ERROR_NOT_EXIST;
6270 pkg = instance_package(inst);
6274 * THIS statement should not be entered.
6276 ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
6277 ret = LB_STATUS_ERROR_FAULT;
6282 ret = LB_STATUS_ERROR_INVALID;
6285 * Reset "id", It will be re-used from here
6288 if (type == TYPE_LB) {
6289 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
6290 struct buffer_info *info;
6292 info = instance_lb_buffer(inst);
6294 ret = buffer_handler_resize(info, w, h);
6297 * id is resued for newly assigned ID
6300 id = buffer_handler_id(info);
6301 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
6305 } else if (type == TYPE_PD) {
6306 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
6307 struct buffer_info *info;
6309 info = instance_pd_buffer(inst);
6311 ret = buffer_handler_resize(info, w, h);
6314 * id is resued for newly assigned ID
6317 id = buffer_handler_id(info);
6318 instance_set_pd_info(inst, w, h);
6325 result = packet_create_reply(packet, "is", ret, id);
6327 ErrPrint("Failed to create a packet\n");
6332 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
6334 enum target_type type;
6335 const char *pkgname;
6337 struct packet *result;
6338 struct slave_node *slave;
6339 struct inst_info *inst;
6342 slave = slave_find_by_pid(pid);
6344 ErrPrint("Failed to find a slave\n");
6345 ret = LB_STATUS_ERROR_NOT_EXIST;
6349 if (packet_get(packet, "iss", &type, &pkgname, &id) != 3) {
6350 ErrPrint("Inavlid argument\n");
6351 ret = LB_STATUS_ERROR_INVALID;
6355 inst = package_find_instance_by_id(pkgname, id);
6357 ErrPrint("Instance is not found [%s - %s]\n", pkgname, id);
6358 ret = LB_STATUS_ERROR_NOT_EXIST;
6362 ret = LB_STATUS_ERROR_INVALID;
6363 if (type == TYPE_LB) {
6364 struct buffer_info *info;
6366 info = instance_lb_buffer(inst);
6367 ret = buffer_handler_unload(info);
6368 } else if (type == TYPE_PD) {
6369 struct buffer_info *info;
6371 DbgPrint("Slave release buffer for PD\n");
6373 info = instance_pd_buffer(inst);
6374 ret = buffer_handler_unload(info);
6378 * Send the PD destroyed event to the client
6380 instance_client_pd_destroyed(inst, ret);
6384 result = packet_create_reply(packet, "i", ret);
6386 ErrPrint("Failed to create a packet\n");
6391 static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
6393 struct inst_info *inst;
6394 struct packet *result;
6395 const char *pkgname;
6400 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
6402 ErrPrint("Invalid packet\n");
6403 ret = LB_STATUS_ERROR_INVALID;
6408 struct pkg_info *pkg;
6410 pkg = package_find(pkgname);
6412 ret = LB_STATUS_ERROR_NOT_EXIST;
6413 } else if (package_is_fault(pkg)) {
6414 ret = LB_STATUS_ERROR_FAULT;
6416 Eina_List *inst_list;
6419 inst_list = package_instance_list(pkg);
6420 EINA_LIST_FOREACH(inst_list, l, inst) {
6421 ret = instance_set_period(inst, period);
6423 DbgPrint("Failed to change the period of %s to (%lf)\n", instance_id(inst), period);
6427 inst = package_find_instance_by_id(pkgname, id);
6429 ret = LB_STATUS_ERROR_NOT_EXIST;
6430 else if (package_is_fault(instance_package(inst)))
6431 ret = LB_STATUS_ERROR_FAULT;
6433 ret = instance_set_period(inst, period);
6436 DbgPrint("Change the update period: %s(%s), %lf : %d\n", pkgname, id, period, ret);
6438 result = packet_create_reply(packet, "i", ret);
6440 ErrPrint("Failed to create a packet\n");
6445 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
6447 struct pkg_info *pkg;
6448 struct packet *result;
6449 const char *pkgname;
6451 const char *cluster;
6452 const char *category;
6456 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
6458 ErrPrint("Invalid Packet\n");
6459 ret = LB_STATUS_ERROR_INVALID;
6463 lb_pkgname = package_lb_pkgname(pkgname);
6465 ErrPrint("Invalid package %s\n", pkgname);
6466 ret = LB_STATUS_ERROR_INVALID;
6470 pkg = package_find(lb_pkgname);
6472 ret = LB_STATUS_ERROR_NOT_EXIST;
6473 DbgFree(lb_pkgname);
6477 if (package_is_fault(pkg)) {
6478 ret = LB_STATUS_ERROR_FAULT;
6479 DbgFree(lb_pkgname);
6485 * Validate the update requstor.
6487 slave_rpc_request_update(lb_pkgname, id, cluster, category);
6488 DbgFree(lb_pkgname);
6489 ret = LB_STATUS_SUCCESS;
6492 result = packet_create_reply(packet, "i", ret);
6494 ErrPrint("Failed to create a packet\n");
6499 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
6501 struct liveinfo *info;
6502 struct packet *result;
6504 const char *fifo_name;
6507 DbgPrint("Request arrived from %d\n", pid);
6509 if (packet_get(packet, "d", ×tamp) != 1) {
6510 ErrPrint("Invalid packet\n");
6512 ret = LB_STATUS_ERROR_INVALID;
6516 info = liveinfo_create(pid, handle);
6518 ErrPrint("Failed to create a liveinfo object\n");
6520 ret = LB_STATUS_ERROR_INVALID;
6525 fifo_name = liveinfo_filename(info);
6526 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
6529 result = packet_create_reply(packet, "si", fifo_name, ret);
6531 ErrPrint("Failed to create a result packet\n");
6536 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
6540 struct liveinfo *info;
6541 struct slave_node *slave;
6545 if (packet_get(packet, "d", ×tamp) != 1) {
6546 ErrPrint("Invalid argument\n");
6550 info = liveinfo_find_by_pid(pid);
6552 ErrPrint("Invalid request\n");
6556 liveinfo_open_fifo(info);
6557 fp = liveinfo_fifo(info);
6559 liveinfo_close_fifo(info);
6563 list = (Eina_List *)slave_list();
6564 EINA_LIST_FOREACH(list, l, slave) {
6565 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
6568 slave_pkgname(slave),
6570 slave_is_secured(slave),
6571 slave_refcnt(slave),
6572 slave_fault_count(slave),
6573 slave_state_string(slave),
6574 slave_loaded_instance(slave),
6575 slave_loaded_package(slave),
6580 fprintf(fp, "EOD\n");
6581 liveinfo_close_fifo(info);
6586 static inline const char *visible_state_string(enum livebox_visible_state state)
6593 case LB_HIDE_WITH_PAUSE:
6602 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
6604 const char *pkgname;
6605 struct liveinfo *info;
6606 struct pkg_info *pkg;
6608 Eina_List *inst_list;
6609 struct inst_info *inst;
6612 if (packet_get(packet, "s", &pkgname) != 1) {
6613 ErrPrint("Invalid argument\n");
6617 info = liveinfo_find_by_pid(pid);
6619 ErrPrint("Invalid request\n");
6623 liveinfo_open_fifo(info);
6624 fp = liveinfo_fifo(info);
6626 ErrPrint("Invalid fp\n");
6627 liveinfo_close_fifo(info);
6631 if (!package_is_lb_pkgname(pkgname)) {
6632 ErrPrint("Invalid package name\n");
6636 pkg = package_find(pkgname);
6638 ErrPrint("Package is not exists\n");
6642 inst_list = package_instance_list(pkg);
6643 EINA_LIST_FOREACH(inst_list, l, inst) {
6644 fprintf(fp, "%s %s %s %lf %s %d %d\n",
6646 instance_cluster(inst),
6647 instance_category(inst),
6648 instance_period(inst),
6649 visible_state_string(instance_visible_state(inst)),
6650 instance_lb_width(inst),
6651 instance_lb_height(inst));
6655 fprintf(fp, "EOD\n");
6656 liveinfo_close_fifo(info);
6662 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
6666 Eina_List *inst_list;
6667 struct liveinfo *info;
6668 struct pkg_info *pkg;
6669 struct slave_node *slave;
6671 const char *slavename;
6674 if (packet_get(packet, "d", ×tamp) != 1) {
6675 ErrPrint("Invalid argument\n");
6679 info = liveinfo_find_by_pid(pid);
6681 ErrPrint("Invalid request\n");
6685 liveinfo_open_fifo(info);
6686 fp = liveinfo_fifo(info);
6688 liveinfo_close_fifo(info);
6692 list = (Eina_List *)package_list();
6693 EINA_LIST_FOREACH(list, l, pkg) {
6694 slave = package_slave(pkg);
6697 slavename = slave_name(slave);
6698 pid = slave_pid(slave);
6704 inst_list = (Eina_List *)package_instance_list(pkg);
6705 fprintf(fp, "%d %s %s %s %d %d %d\n",
6707 strlen(slavename) ? slavename : "(none)",
6710 package_refcnt(pkg),
6711 package_fault_count(pkg),
6712 eina_list_count(inst_list)
6716 fprintf(fp, "EOD\n");
6717 liveinfo_close_fifo(info);
6722 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
6727 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
6729 struct liveinfo *info;
6735 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
6736 ErrPrint("Invalid argument\n");
6740 info = liveinfo_find_by_pid(pid);
6742 ErrPrint("Invalid request\n");
6746 liveinfo_open_fifo(info);
6747 fp = liveinfo_fifo(info);
6749 liveinfo_close_fifo(info);
6753 if (!strcmp(cmd, "rmpack")) {
6754 fprintf(fp, "%d\n", ENOSYS);
6755 } else if (!strcmp(cmd, "rminst")) {
6756 struct inst_info *inst;
6757 inst = package_find_instance_by_id(pkgname, id);
6759 fprintf(fp, "%d\n", ENOENT);
6761 instance_destroy(inst);
6762 fprintf(fp, "%d\n", 0);
6766 fprintf(fp, "EOD\n");
6767 liveinfo_close_fifo(info);
6773 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
6775 struct liveinfo *info;
6780 int ret = LB_STATUS_ERROR_INVALID;
6782 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
6783 ErrPrint("Invalid argument\n");
6787 info = liveinfo_find_by_pid(pid);
6789 ErrPrint("Invalid request\n");
6793 if (!strcasecmp(var, "debug")) {
6794 if (!strcasecmp(cmd, "set")) {
6795 g_conf.debug_mode = !strcasecmp(val, "on");
6796 } else if (!strcasecmp(cmd, "get")) {
6798 ret = g_conf.debug_mode;
6799 } else if (!strcasecmp(var, "slave_max_load")) {
6800 if (!strcasecmp(cmd, "set")) {
6801 g_conf.slave_max_load = atoi(val);
6802 } else if (!strcasecmp(cmd, "get")) {
6804 ret = g_conf.slave_max_load;
6807 liveinfo_open_fifo(info);
6808 fp = liveinfo_fifo(info);
6810 liveinfo_close_fifo(info);
6813 fprintf(fp, "%d\nEOD\n", ret);
6814 liveinfo_close_fifo(info);
6820 static struct method s_info_table[] = {
6822 .cmd = "liveinfo_hello",
6823 .handler = liveinfo_hello,
6826 .cmd = "slave_list",
6827 .handler = liveinfo_slave_list,
6831 .handler = liveinfo_pkg_list,
6835 .handler = liveinfo_inst_list,
6838 .cmd = "slave_ctrl",
6839 .handler = liveinfo_slave_ctrl,
6843 .handler = liveinfo_pkg_ctrl,
6846 .cmd = "master_ctrl",
6847 .handler = liveinfo_master_ctrl,
6855 static struct method s_client_table[] = {
6857 .cmd = "pd_mouse_move",
6858 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6861 .cmd = "lb_mouse_move",
6862 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6865 .cmd = "pd_mouse_down",
6866 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6869 .cmd = "pd_mouse_up",
6870 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6873 .cmd = "lb_mouse_down",
6874 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6877 .cmd = "lb_mouse_up",
6878 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6881 .cmd = "pd_mouse_enter",
6882 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6885 .cmd = "pd_mouse_leave",
6886 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6889 .cmd = "lb_mouse_enter",
6890 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6893 .cmd = "lb_mouse_leave",
6894 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6897 .cmd = "lb_mouse_set",
6898 .handler = client_lb_mouse_set,
6901 .cmd = "lb_mouse_unset",
6902 .handler = client_lb_mouse_unset,
6905 .cmd = "pd_mouse_set",
6906 .handler = client_pd_mouse_set,
6909 .cmd = "pd_mouse_unset",
6910 .handler = client_pd_mouse_unset,
6913 .cmd = "change,visibility",
6914 .handler = client_change_visibility,
6917 .cmd = "lb_acquire_pixmap",
6918 .handler = client_lb_acquire_pixmap,
6921 .cmd = "lb_release_pixmap",
6922 .handler = client_lb_release_pixmap,
6925 .cmd = "pd_acquire_pixmap",
6926 .handler = client_pd_acquire_pixmap,
6929 .cmd = "pd_release_pixmap",
6930 .handler = client_pd_release_pixmap,
6934 .handler = client_acquire, /*!< pid, ret */
6938 .handler = cilent_release, /*!< pid, ret */
6942 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
6945 .cmd = "text_signal",
6946 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
6950 .handler = client_delete, /* pid, pkgname, filename, ret */
6954 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
6958 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
6961 .cmd = "set_period",
6962 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
6965 .cmd = "change_group",
6966 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
6969 .cmd = "pinup_changed",
6970 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
6974 .handler = client_create_pd, /* pid, pkgname, filename, ret */
6978 .handler = client_pd_move, /* pkgname, id, x, y */
6981 .cmd = "destroy_pd",
6982 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
6985 .cmd = "activate_package",
6986 .handler = client_activate_package, /* pid, pkgname, ret */
6989 .cmd = "subscribe", /* pid, cluster, sub-cluster */
6990 .handler = client_subscribed,
6993 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
6994 .handler = client_unsubscribed,
6997 .cmd = "delete_cluster",
6998 .handler = client_delete_cluster,
7001 .cmd = "delete_category",
7002 .handler = client_delete_category,
7005 .cmd = "refresh_group",
7006 .handler = client_refresh_group,
7010 .handler = client_update,
7014 .cmd = "pd_access_hl",
7015 .handler = client_pd_access_hl,
7018 .cmd = "pd_access_hl_prev",
7019 .handler = client_pd_access_hl_prev,
7022 .cmd = "pd_access_hl_next",
7023 .handler = client_pd_access_hl_next,
7026 .cmd = "pd_access_activate",
7027 .handler = client_pd_access_activate,
7030 .cmd = "pd_access_value_change",
7031 .handler = client_pd_access_value_change,
7034 .cmd = "pd_access_scroll",
7035 .handler = client_pd_access_scroll,
7038 .cmd = "pd_access_unhighlight",
7039 .handler = client_pd_access_unhighlight,
7043 .cmd = "lb_access_hl",
7044 .handler = client_lb_access_hl,
7047 .cmd = "lb_access_hl_prev",
7048 .handler = client_lb_access_hl_prev,
7051 .cmd = "lb_access_hl_next",
7052 .handler = client_lb_access_hl_next,
7055 .cmd = "lb_access_activate",
7056 .handler = client_lb_access_activate,
7059 .cmd = "lb_access_value_change",
7060 .handler = client_lb_access_value_change,
7063 .cmd = "lb_access_scroll",
7064 .handler = client_lb_access_scroll,
7067 .cmd = "lb_access_unhighlight",
7068 .handler = client_lb_access_unhighlight,
7072 .cmd = "lb_key_down",
7073 .handler = client_lb_key_down,
7077 .handler = client_lb_key_up,
7081 .cmd = "pd_key_down",
7082 .handler = client_pd_key_down,
7086 .handler = client_pd_key_up,
7090 .cmd = "client_paused",
7091 .handler = client_pause_request,
7094 .cmd = "client_resumed",
7095 .handler = client_resume_request,
7099 .cmd = "update_mode",
7100 .handler = client_update_mode,
7109 static struct method s_service_table[] = {
7111 .cmd = "service_update",
7112 .handler = service_update,
7115 .cmd = "service_change_period",
7116 .handler = service_change_period,
7124 static struct method s_slave_table[] = {
7127 .handler = slave_hello, /* slave_name, ret */
7131 .handler = slave_ping, /* slave_name, ret */
7135 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
7139 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
7143 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
7146 .cmd = "desc_updated",
7147 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
7151 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
7154 .cmd = "acquire_buffer",
7155 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
7158 .cmd = "resize_buffer",
7159 .handler = slave_resize_buffer,
7162 .cmd = "release_buffer",
7163 .handler = slave_release_buffer, /* slave_name, id - ret */
7167 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
7171 .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
7175 .cmd = "lb_update_begin",
7176 .handler = slave_lb_update_begin,
7179 .cmd = "lb_update_end",
7180 .handler = slave_lb_update_end,
7183 .cmd = "pd_update_begin",
7184 .handler = slave_pd_update_begin,
7187 .cmd = "pd_update_end",
7188 .handler = slave_pd_update_end,
7192 .cmd = "access_status",
7193 .handler = slave_access_status,
7202 HAPI int server_init(void)
7204 com_core_packet_use_thread(COM_CORE_THREAD);
7206 if (unlink(INFO_SOCKET) < 0)
7207 ErrPrint("info socket: %s\n", strerror(errno));
7209 if (unlink(SLAVE_SOCKET) < 0)
7210 ErrPrint("slave socket: %s\n", strerror(errno));
7212 if (unlink(CLIENT_SOCKET) < 0)
7213 ErrPrint("client socket: %s\n", strerror(errno));
7215 if (unlink(SERVICE_SOCKET) < 0)
7216 ErrPrint("service socket: %s\n", strerror(errno));
7218 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
7219 if (s_info.info_fd < 0)
7220 ErrPrint("Failed to create a info socket\n");
7222 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
7223 if (s_info.slave_fd < 0)
7224 ErrPrint("Failed to create a slave socket\n");
7226 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
7227 if (s_info.client_fd < 0)
7228 ErrPrint("Failed to create a client socket\n");
7230 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
7231 if (s_info.service_fd < 0)
7232 ErrPrint("Faild to create a service socket\n");
7234 if (chmod(INFO_SOCKET, 0600) < 0)
7235 ErrPrint("info socket: %s\n", strerror(errno));
7237 if (chmod(SLAVE_SOCKET, 0666) < 0)
7238 ErrPrint("slave socket: %s\n", strerror(errno));
7240 if (chmod(CLIENT_SOCKET, 0666) < 0)
7241 ErrPrint("client socket: %s\n", strerror(errno));
7243 if (chmod(SERVICE_SOCKET, 0666) < 0)
7244 ErrPrint("service socket: %s\n", strerror(errno));
7249 HAPI int server_fini(void)
7251 if (s_info.info_fd > 0) {
7252 com_core_packet_server_fini(s_info.info_fd);
7253 s_info.info_fd = -1;
7256 if (s_info.slave_fd > 0) {
7257 com_core_packet_server_fini(s_info.slave_fd);
7258 s_info.slave_fd = -1;
7261 if (s_info.client_fd > 0) {
7262 com_core_packet_server_fini(s_info.client_fd);
7263 s_info.client_fd = -1;
7266 if (s_info.service_fd > 0) {
7267 com_core_packet_server_fini(s_info.service_fd);
7268 s_info.service_fd = -1;