2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <Ecore_Evas.h> /* fb.h */
29 #include <com-core_packet.h>
30 #include <livebox-errno.h>
31 #include <livebox-service.h>
33 #include "critical_log.h"
37 #include "slave_life.h"
38 #include "slave_rpc.h"
39 #include "client_life.h"
41 #include "client_rpc.h"
43 #include "script_handler.h"
44 #include "buffer_handler.h"
46 #include "fault_manager.h"
47 #include "fb.h" /* fb_type */
67 /* Share this with provider */
74 struct access_cbdata {
76 struct inst_info *inst;
80 struct client_node *client;
81 struct inst_info *inst;
84 static Eina_Bool lazy_access_status_cb(void *data)
86 struct access_cbdata *cbdata = data;
88 if (instance_unref(cbdata->inst)) {
89 instance_send_access_status(cbdata->inst, cbdata->status);
91 DbgPrint("Skip sending access status (%d)\n", cbdata->status);
94 * If instance_unref returns NULL,
95 * The instance is destroyed. it means, we don't need to send event to the viewer
98 return ECORE_CALLBACK_CANCEL;
101 static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
103 struct inst_info *inst = data;
104 const struct pkg_info *pkg;
105 struct slave_node *slave;
106 struct packet *packet;
109 pkg = instance_package(inst);
111 return LB_STATUS_ERROR_INVALID;
113 slave = package_slave(pkg);
115 return LB_STATUS_ERROR_INVALID;
118 case EVENT_STATE_ACTIVATE:
119 cmdstr = "lb_mouse_down";
121 case EVENT_STATE_ACTIVATED:
122 cmdstr = "lb_mouse_move";
124 case EVENT_STATE_DEACTIVATE:
125 cmdstr = "lb_mouse_up";
128 return LB_STATUS_ERROR_INVALID;
131 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
133 return LB_STATUS_ERROR_FAULT;
135 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
138 static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
140 struct script_info *script;
141 struct inst_info *inst = data;
142 const struct pkg_info *pkg;
146 pkg = instance_package(inst);
150 script = instance_lb_script(inst);
152 return LB_STATUS_ERROR_FAULT;
154 e = script_handler_evas(script);
156 return LB_STATUS_ERROR_FAULT;
158 timestamp = util_timestamp();
161 case EVENT_STATE_ACTIVATE:
162 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
163 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
165 case EVENT_STATE_ACTIVATED:
166 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
167 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
169 case EVENT_STATE_DEACTIVATE:
170 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
171 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
180 static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
182 struct inst_info *inst = data;
183 const struct pkg_info *pkg;
184 struct slave_node *slave;
185 struct packet *packet;
188 pkg = instance_package(inst);
190 return LB_STATUS_ERROR_INVALID;
192 slave = package_slave(pkg);
194 return LB_STATUS_ERROR_INVALID;
197 case EVENT_STATE_ACTIVATE:
198 cmdstr = "pd_mouse_down";
200 case EVENT_STATE_ACTIVATED:
201 cmdstr = "pd_mouse_move";
203 case EVENT_STATE_DEACTIVATE:
204 cmdstr = "pd_mouse_up";
207 return LB_STATUS_ERROR_INVALID;
210 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
212 return LB_STATUS_ERROR_FAULT;
214 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
217 static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
219 struct script_info *script;
220 struct inst_info *inst = data;
221 const struct pkg_info *pkg;
225 pkg = instance_package(inst);
229 script = instance_pd_script(inst);
231 return LB_STATUS_ERROR_FAULT;
233 e = script_handler_evas(script);
235 return LB_STATUS_ERROR_FAULT;
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 static inline int validate_request(const char *pkgname, const char *id, struct inst_info **out_inst, const struct pkg_info **out_pkg)
323 struct inst_info *inst;
324 const struct pkg_info *pkg;
326 inst = package_find_instance_by_id(pkgname, id);
328 ErrPrint("Instance is not exists\n");
329 return LB_STATUS_ERROR_NOT_EXIST;
332 pkg = instance_package(inst);
334 ErrPrint("System error - instance has no package?\n");
335 return LB_STATUS_ERROR_INVALID;
338 if (package_is_fault(pkg)) {
339 ErrPrint("Faulted package: %s\n", pkgname);
340 return LB_STATUS_ERROR_FAULT;
349 return LB_STATUS_SUCCESS;
352 /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
353 static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
355 struct client_node *client;
363 struct inst_info *inst;
365 client = client_find_by_pid(pid);
367 ErrPrint("Client %d is not exists\n", pid);
371 ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
373 ErrPrint("Parameter is not matched\n");
379 * Trust the package name which are sent by the client.
380 * The package has to be a livebox package name.
382 ret = validate_request(pkgname, id, &inst, NULL);
383 if (ret == LB_STATUS_SUCCESS)
384 (void)instance_clicked(inst, event, timestamp, x, y);
387 /*! \note No reply packet */
391 static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet)
393 struct packet *result;
394 struct client_node *client;
399 struct inst_info *inst;
401 client = client_find_by_pid(pid);
403 ErrPrint("Client %d is not exists\n", pid);
404 ret = LB_STATUS_ERROR_INVALID;
408 ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
410 ErrPrint("Invalid argument\n");
411 ret = LB_STATUS_ERROR_INVALID;
415 ret = validate_request(pkgname, id, &inst, NULL);
416 if (ret == LB_STATUS_SUCCESS) {
419 * Send change update mode request to a slave
421 ret = instance_set_update_mode(inst, active_update);
425 result = packet_create_reply(packet, "i", ret);
427 ErrPrint("Failed to create a packet\n");
432 /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
433 static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
435 struct client_node *client;
436 struct packet *result;
439 const char *emission;
445 struct inst_info *inst;
448 client = client_find_by_pid(pid);
450 ErrPrint("Client %d is not exists\n", pid);
451 ret = LB_STATUS_ERROR_NOT_EXIST;
455 ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
457 ErrPrint("Parameter is not matched\n");
458 ret = LB_STATUS_ERROR_INVALID;
464 * Trust the package name which are sent by the client.
465 * The package has to be a livebox package name.
467 ret = validate_request(pkgname, id, &inst, NULL);
468 if (ret == LB_STATUS_SUCCESS)
469 ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
472 result = packet_create_reply(packet, "i", ret);
474 ErrPrint("Failed to create a packet\n");
479 static Eina_Bool lazy_delete_cb(void *data)
481 struct deleted_item *item = data;
483 DbgPrint("Send delete event to the client\n");
486 * Before invoke this callback, the instance is able to already remove this client
489 if (instance_has_client(item->inst, item->client)) {
490 instance_unicast_deleted_event(item->inst, item->client);
491 instance_del_client(item->inst, item->client);
494 (void)client_unref(item->client);
495 (void)instance_unref(item->inst);
497 return ECORE_CALLBACK_CANCEL;
500 static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
502 struct client_node *client;
503 struct packet *result;
506 struct inst_info *inst;
509 client = client_find_by_pid(pid);
511 ErrPrint("Client %d is not exists\n", pid);
512 ret = LB_STATUS_ERROR_NOT_EXIST;
516 ret = packet_get(packet, "ss", &pkgname, &id);
518 ErrPrint("Parameter is not matched\n");
519 ret = LB_STATUS_ERROR_INVALID;
525 * Trust the package name which are sent by the client.
526 * The package has to be a livebox package name.
528 ret = validate_request(pkgname, id, &inst, NULL);
529 if (ret != LB_STATUS_SUCCESS)
532 if (instance_client(inst) != client) {
533 if (instance_has_client(inst, client)) {
534 struct deleted_item *item;
536 item = malloc(sizeof(*item));
538 ErrPrint("Heap: %s\n", strerror(errno));
539 ret = LB_STATUS_ERROR_MEMORY;
543 * Send DELETED EVENT to the client.
544 * after return from this function.
546 * Client will prepare the deleted event after get this function's return value.
547 * So We have to make a delay to send a deleted event.
550 item->client = client_ref(client);
551 item->inst = instance_ref(inst);
553 if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
554 ErrPrint("Failed to add a delayzed delete callback\n");
555 (void)client_unref(client);
556 (void)instance_unref(inst);
558 ret = LB_STATUS_ERROR_FAULT;
560 ret = LB_STATUS_SUCCESS;
564 ErrPrint("Client has no permission\n");
565 ret = LB_STATUS_ERROR_PERMISSION;
568 ret = instance_destroy(inst);
572 result = packet_create_reply(packet, "i", ret);
574 ErrPrint("Failed to create a packet\n");
579 static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
581 struct client_node *client;
582 struct packet *result;
587 struct inst_info *inst;
590 client = client_find_by_pid(pid);
592 ErrPrint("Client %d is not exists\n", pid);
593 ret = LB_STATUS_ERROR_NOT_EXIST;
597 ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
599 ErrPrint("Parameter is not matched\n");
600 ret = LB_STATUS_ERROR_INVALID;
604 DbgPrint("RESIZE: Client request resize to %dx%d (pid: %d, pkgname: %s)\n", w, h, pid, pkgname);
608 * Trust the package name which are sent by the client.
609 * The package has to be a livebox package name.
611 ret = validate_request(pkgname, id, &inst, NULL);
612 if (ret != LB_STATUS_SUCCESS)
615 if (instance_client(inst) != client)
616 ret = LB_STATUS_ERROR_PERMISSION;
618 ret = instance_resize(inst, w, h);
621 result = packet_create_reply(packet, "i", ret);
623 ErrPrint("Failed to create a packet\n");
628 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
630 struct client_node *client;
631 struct packet *result;
635 const char *category;
639 struct pkg_info *info;
645 client = client_find_by_pid(pid);
647 ErrPrint("Client %d is not exists\n", pid);
648 ret = LB_STATUS_ERROR_NOT_EXIST;
652 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
654 ErrPrint("Parameter is not matched\n");
655 ret = LB_STATUS_ERROR_INVALID;
659 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
660 pid, timestamp, pkgname, content, cluster, category, period);
662 lb_pkgname = package_lb_pkgname(pkgname);
664 ErrPrint("This %s has no livebox package\n", pkgname);
665 ret = LB_STATUS_ERROR_INVALID;
669 mainappid = livebox_service_mainappid(lb_pkgname);
670 if (!package_is_enabled(mainappid)) {
673 ret = LB_STATUS_ERROR_DISABLED;
678 info = package_find(lb_pkgname);
680 info = package_create(lb_pkgname);
683 ret = LB_STATUS_ERROR_FAULT;
684 } else if (package_is_fault(info)) {
685 ret = LB_STATUS_ERROR_FAULT;
686 } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
687 ErrPrint("Not enough space\n");
688 ret = LB_STATUS_ERROR_NO_SPACE;
690 struct inst_info *inst;
692 if (period > 0.0f && period < MINIMUM_PERIOD)
693 period = MINIMUM_PERIOD;
695 inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
698 * Using the "inst" without validate its value is at my disposal. ;)
700 ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
706 result = packet_create_reply(packet, "i", ret);
708 ErrPrint("Failed to create a packet\n");
713 static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
715 struct client_node *client;
718 enum livebox_visible_state state;
720 struct inst_info *inst;
722 client = client_find_by_pid(pid);
724 ErrPrint("Client %d is not exists\n", pid);
725 ret = LB_STATUS_ERROR_NOT_EXIST;
729 ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
731 ErrPrint("Parameter is not matched\n");
732 ret = LB_STATUS_ERROR_INVALID;
738 * Trust the package name which are sent by the client.
739 * The package has to be a livebox package name.
741 ret = validate_request(pkgname, id, &inst, NULL);
742 if (ret != LB_STATUS_SUCCESS)
745 if (instance_client(inst) != client)
746 ret = LB_STATUS_ERROR_PERMISSION;
748 ret = instance_set_visible_state(inst, state);
751 /*! \note No reply packet */
755 static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
757 struct client_node *client;
758 struct packet *result;
763 struct inst_info *inst;
765 client = client_find_by_pid(pid);
767 ErrPrint("Client %d is not exists\n", pid);
768 ret = LB_STATUS_ERROR_NOT_EXIST;
772 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
774 ErrPrint("Parameter is not matched\n");
775 ret = LB_STATUS_ERROR_INVALID;
779 DbgPrint("pid[%d] pkgname[%s] period[%lf]\n", pid, pkgname, period);
783 * Trust the package name which are sent by the client.
784 * The package has to be a livebox package name.
786 ret = validate_request(pkgname, id, &inst, NULL);
787 if (ret != LB_STATUS_SUCCESS)
790 if (instance_client(inst) != client)
791 ret = LB_STATUS_ERROR_PERMISSION;
793 ret = instance_set_period(inst, period);
796 result = packet_create_reply(packet, "i", ret);
798 ErrPrint("Failed to create a packet\n");
803 static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
805 struct client_node *client;
806 struct packet *result;
810 const char *category;
811 struct inst_info *inst;
814 client = client_find_by_pid(pid);
816 ErrPrint("Client %d is not exists\n", pid);
817 ret = LB_STATUS_ERROR_NOT_EXIST;
821 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
823 ErrPrint("Parameter is not matched\n");
824 ret = LB_STATUS_ERROR_INVALID;
828 DbgPrint("pid[%d] pkgname[%s] cluster[%s] category[%s]\n", pid, pkgname, cluster, category);
832 * Trust the package name which are sent by the client.
833 * The package has to be a livebox package name.
835 ret = validate_request(pkgname, id, &inst, NULL);
836 if (ret != LB_STATUS_SUCCESS)
839 if (instance_client(inst) != client)
840 ret = LB_STATUS_ERROR_PERMISSION;
842 ret = instance_change_group(inst, cluster, category);
845 result = packet_create_reply(packet, "i", ret);
847 ErrPrint("Failed to create a packet\n");
852 static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
854 struct client_node *client;
861 struct inst_info *inst;
862 const struct pkg_info *pkg;
864 client = client_find_by_pid(pid);
866 ErrPrint("Client %d is not exists\n", pid);
867 ret = LB_STATUS_ERROR_NOT_EXIST;
871 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
873 ErrPrint("Invalid parameter\n");
874 ret = LB_STATUS_ERROR_INVALID;
878 ret = validate_request(pkgname, id, &inst, &pkg);
879 if (ret != LB_STATUS_SUCCESS)
882 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
883 struct buffer_info *buffer;
884 struct slave_node *slave;
886 buffer = instance_pd_buffer(inst);
888 ErrPrint("Instance[%s] has no buffer\n", id);
889 ret = LB_STATUS_ERROR_FAULT;
893 slave = package_slave(pkg);
895 ErrPrint("Package[%s] has no slave\n", pkgname);
896 ret = LB_STATUS_ERROR_INVALID;
900 packet_ref((struct packet *)packet);
901 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
902 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
903 struct script_info *script;
906 script = instance_pd_script(inst);
908 ret = LB_STATUS_ERROR_FAULT;
912 e = script_handler_evas(script);
914 ret = LB_STATUS_ERROR_FAULT;
918 script_handler_update_pointer(script, x, y, -1);
919 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
922 ErrPrint("Unsupported package\n");
923 ret = LB_STATUS_ERROR_INVALID;
927 /*! \note No reply packet */
931 static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
933 struct client_node *client;
940 struct inst_info *inst;
941 const struct pkg_info *pkg;
943 client = client_find_by_pid(pid);
945 ErrPrint("Client %d is not exists\n", pid);
946 ret = LB_STATUS_ERROR_NOT_EXIST;
950 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
952 ErrPrint("Parameter is not matched\n");
953 ret = LB_STATUS_ERROR_INVALID;
957 ret = validate_request(pkgname, id, &inst, &pkg);
958 if (ret != LB_STATUS_SUCCESS)
961 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
962 struct buffer_info *buffer;
963 struct slave_node *slave;
965 buffer = instance_pd_buffer(inst);
967 ErrPrint("Instance[%s] has no buffer\n", id);
968 ret = LB_STATUS_ERROR_FAULT;
972 slave = package_slave(pkg);
974 ErrPrint("Package[%s] has no slave\n", pkgname);
975 ret = LB_STATUS_ERROR_INVALID;
979 packet_ref((struct packet *)packet);
980 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
981 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
982 struct script_info *script;
985 script = instance_pd_script(inst);
987 ret = LB_STATUS_ERROR_FAULT;
991 e = script_handler_evas(script);
993 ret = LB_STATUS_ERROR_FAULT;
997 script_handler_update_pointer(script, x, y, -1);
998 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
1001 ErrPrint("Unsupported package\n");
1002 ret = LB_STATUS_ERROR_INVALID;
1006 /*! \note No reply packet */
1010 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 */
1012 struct client_node *client;
1013 const char *pkgname;
1019 struct inst_info *inst;
1020 const struct pkg_info *pkg;
1022 client = client_find_by_pid(pid);
1024 ErrPrint("Client %d is not exists\n", pid);
1025 ret = LB_STATUS_ERROR_NOT_EXIST;
1029 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1031 ErrPrint("Parameter is not matched\n");
1032 ret = LB_STATUS_ERROR_INVALID;
1036 ret = validate_request(pkgname, id, &inst, &pkg);
1037 if (ret != LB_STATUS_SUCCESS)
1040 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1041 struct buffer_info *buffer;
1042 struct slave_node *slave;
1044 buffer = instance_pd_buffer(inst);
1046 ErrPrint("Instance[%s] has no buffer\n", id);
1047 ret = LB_STATUS_ERROR_FAULT;
1051 slave = package_slave(pkg);
1053 ErrPrint("Package[%s] has no slave\n", pkgname);
1054 ret = LB_STATUS_ERROR_INVALID;
1058 packet_ref((struct packet *)packet);
1059 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1060 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1061 struct script_info *script;
1064 script = instance_pd_script(inst);
1066 ret = LB_STATUS_ERROR_FAULT;
1070 e = script_handler_evas(script);
1072 ret = LB_STATUS_ERROR_FAULT;
1076 script_handler_update_pointer(script, x, y, 1);
1077 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
1080 ErrPrint("Unsupported package\n");
1081 ret = LB_STATUS_ERROR_INVALID;
1085 /*! \note No reply packet */
1089 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 */
1091 struct client_node *client;
1092 const char *pkgname;
1098 struct inst_info *inst;
1099 const struct pkg_info *pkg;
1101 client = client_find_by_pid(pid);
1103 ErrPrint("Client %d is not exists\n", pid);
1104 ret = LB_STATUS_ERROR_NOT_EXIST;
1108 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1110 ErrPrint("Parameter is not matched\n");
1111 ret = LB_STATUS_ERROR_INVALID;
1115 ret = validate_request(pkgname, id, &inst, &pkg);
1116 if (ret != LB_STATUS_SUCCESS)
1119 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1120 struct buffer_info *buffer;
1121 struct slave_node *slave;
1123 buffer = instance_pd_buffer(inst);
1125 ErrPrint("Instance[%s] has no buffer\n", id);
1126 ret = LB_STATUS_ERROR_FAULT;
1130 slave = package_slave(pkg);
1132 ErrPrint("Package[%s] has no slave\n", pkgname);
1133 ret = LB_STATUS_ERROR_INVALID;
1137 packet_ref((struct packet *)packet);
1138 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1139 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1140 struct script_info *script;
1143 script = instance_pd_script(inst);
1145 ret = LB_STATUS_ERROR_FAULT;
1149 e = script_handler_evas(script);
1151 ret = LB_STATUS_ERROR_FAULT;
1155 script_handler_update_pointer(script, x, y, 0);
1156 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
1159 ErrPrint("Unsupported package\n");
1160 ret = LB_STATUS_ERROR_INVALID;
1164 /*! \note No reply packet */
1168 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 */
1170 struct client_node *client;
1171 const char *pkgname;
1177 struct inst_info *inst;
1178 const struct pkg_info *pkg;
1180 client = client_find_by_pid(pid);
1182 ErrPrint("Client %d is not exists\n", pid);
1183 ret = LB_STATUS_ERROR_NOT_EXIST;
1187 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1189 ErrPrint("Parameter is not matched\n");
1190 ret = LB_STATUS_ERROR_INVALID;
1194 ret = validate_request(pkgname, id, &inst, &pkg);
1195 if (ret != LB_STATUS_SUCCESS)
1198 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1199 struct buffer_info *buffer;
1200 struct slave_node *slave;
1202 buffer = instance_pd_buffer(inst);
1204 ErrPrint("Instance[%s] has no buffer\n", id);
1205 ret = LB_STATUS_ERROR_FAULT;
1209 slave = package_slave(pkg);
1211 ErrPrint("Package[%s] has no slave\n", pkgname);
1212 ret = LB_STATUS_ERROR_INVALID;
1216 packet_ref((struct packet *)packet);
1217 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1218 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1219 struct script_info *script;
1222 script = instance_pd_script(inst);
1224 ret = LB_STATUS_ERROR_FAULT;
1228 e = script_handler_evas(script);
1230 ret = LB_STATUS_ERROR_FAULT;
1234 script_handler_update_pointer(script, x, y, -1);
1235 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1238 ErrPrint("Unsupported package\n");
1239 ret = LB_STATUS_ERROR_INVALID;
1243 /*! \note No reply packet */
1247 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 */
1249 struct client_node *client;
1250 const char *pkgname;
1256 struct inst_info *inst;
1257 const struct pkg_info *pkg;
1259 client = client_find_by_pid(pid);
1261 ErrPrint("Client %d is not exists\n", pid);
1262 ret = LB_STATUS_ERROR_NOT_EXIST;
1266 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1268 ErrPrint("Parameter is not matched\n");
1269 ret = LB_STATUS_ERROR_INVALID;
1273 ret = validate_request(pkgname, id, &inst, &pkg);
1274 if (ret != LB_STATUS_SUCCESS)
1277 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1278 struct buffer_info *buffer;
1279 struct slave_node *slave;
1281 buffer = instance_lb_buffer(inst);
1283 ErrPrint("Instance[%s] has no buffer\n", id);
1284 ret = LB_STATUS_ERROR_FAULT;
1288 slave = package_slave(pkg);
1290 ErrPrint("Package[%s] has no slave\n", pkgname);
1291 ret = LB_STATUS_ERROR_INVALID;
1295 packet_ref((struct packet *)packet);
1296 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1297 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1298 struct script_info *script;
1301 script = instance_lb_script(inst);
1303 ret = LB_STATUS_ERROR_FAULT;
1307 e = script_handler_evas(script);
1309 ret = LB_STATUS_ERROR_FAULT;
1313 script_handler_update_pointer(script, x, y, -1);
1314 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1317 ErrPrint("Unsupported package\n");
1318 ret = LB_STATUS_ERROR_INVALID;
1322 /*! \note No reply packet */
1326 static int inst_del_cb(struct inst_info *inst, void *data)
1328 (void)event_deactivate();
1329 return -1; /* Delete this callback */
1332 static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
1334 struct client_node *client;
1335 const char *pkgname;
1341 struct inst_info *inst;
1342 const struct pkg_info *pkg;
1344 client = client_find_by_pid(pid);
1346 ErrPrint("Client %d is not exists\n", pid);
1347 ret = LB_STATUS_ERROR_NOT_EXIST;
1351 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1353 ErrPrint("Parameter is not matched\n");
1354 ret = LB_STATUS_ERROR_INVALID;
1358 ret = validate_request(pkgname, id, &inst, &pkg);
1359 if (ret != LB_STATUS_SUCCESS)
1362 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1363 if (event_is_activated()) {
1364 if (event_deactivate() == 0)
1365 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1368 ret = event_activate(x, y, event_lb_route_cb, inst);
1370 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1371 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1372 if (event_is_activated()) {
1373 if (event_deactivate() == 0)
1374 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1377 ret = event_activate(x, y, event_lb_consume_cb, inst);
1379 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1381 ErrPrint("Unsupported package\n");
1382 ret = LB_STATUS_ERROR_INVALID;
1388 static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1390 struct client_node *client;
1391 const char *pkgname;
1397 struct inst_info *inst;
1398 const struct pkg_info *pkg;
1400 client = client_find_by_pid(pid);
1402 ErrPrint("Client %d is not exists\n", pid);
1403 ret = LB_STATUS_ERROR_NOT_EXIST;
1407 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1409 ErrPrint("Parameter is not matched\n");
1410 ret = LB_STATUS_ERROR_INVALID;
1414 ret = validate_request(pkgname, id, &inst, &pkg);
1415 if (ret != LB_STATUS_SUCCESS)
1418 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1419 ret = event_deactivate();
1421 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1422 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1423 ret = event_deactivate();
1425 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1427 ErrPrint("Unsupported package\n");
1428 ret = LB_STATUS_ERROR_INVALID;
1434 static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
1436 struct client_node *client;
1437 const char *pkgname;
1443 struct inst_info *inst;
1444 const struct pkg_info *pkg;
1446 client = client_find_by_pid(pid);
1448 ErrPrint("Client %d is not exists\n", pid);
1449 ret = LB_STATUS_ERROR_NOT_EXIST;
1453 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1455 ErrPrint("Parameter is not matched\n");
1456 ret = LB_STATUS_ERROR_INVALID;
1460 ret = validate_request(pkgname, id, &inst, &pkg);
1461 if (ret != LB_STATUS_SUCCESS)
1464 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1465 if (event_is_activated()) {
1466 if (event_deactivate() == 0)
1467 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1470 ret = event_activate(x, y, event_pd_route_cb, inst);
1472 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1473 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1474 if (event_is_activated()) {
1475 if (event_deactivate() == 0)
1476 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1479 ret = event_activate(x, y, event_pd_consume_cb, inst);
1481 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1483 ErrPrint("Unsupported package\n");
1484 ret = LB_STATUS_ERROR_INVALID;
1491 static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1493 struct client_node *client;
1494 const char *pkgname;
1500 struct inst_info *inst;
1501 const struct pkg_info *pkg;
1503 client = client_find_by_pid(pid);
1505 ErrPrint("Client %d is not exists\n", pid);
1506 ret = LB_STATUS_ERROR_NOT_EXIST;
1510 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1512 ErrPrint("Parameter is not matched\n");
1513 ret = LB_STATUS_ERROR_INVALID;
1517 ret = validate_request(pkgname, id, &inst, &pkg);
1518 if (ret != LB_STATUS_SUCCESS)
1521 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1522 ret = event_deactivate();
1524 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1525 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1526 ret = event_deactivate();
1528 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1530 ErrPrint("Unsupported package\n");
1531 ret = LB_STATUS_ERROR_INVALID;
1537 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 */
1539 struct client_node *client;
1540 const char *pkgname;
1546 struct inst_info *inst;
1547 const struct pkg_info *pkg;
1549 client = client_find_by_pid(pid);
1551 ErrPrint("Client %d is not exists\n", pid);
1552 ret = LB_STATUS_ERROR_NOT_EXIST;
1556 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1558 ErrPrint("Parameter is not matched\n");
1559 ret = LB_STATUS_ERROR_INVALID;
1563 ret = validate_request(pkgname, id, &inst, &pkg);
1564 if (ret != LB_STATUS_SUCCESS)
1567 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1568 struct buffer_info *buffer;
1569 struct slave_node *slave;
1571 buffer = instance_lb_buffer(inst);
1573 ErrPrint("Instance[%s] has no buffer\n", id);
1574 ret = LB_STATUS_ERROR_FAULT;
1578 slave = package_slave(pkg);
1580 ErrPrint("Package[%s] has no slave\n", pkgname);
1581 ret = LB_STATUS_ERROR_INVALID;
1585 packet_ref((struct packet *)packet);
1586 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1587 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1588 struct script_info *script;
1591 script = instance_lb_script(inst);
1593 ret = LB_STATUS_ERROR_FAULT;
1597 e = script_handler_evas(script);
1599 ret = LB_STATUS_ERROR_FAULT;
1603 script_handler_update_pointer(script, x, y, -1);
1604 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
1607 ErrPrint("Unsupported package\n");
1608 ret = LB_STATUS_ERROR_INVALID;
1612 /*! \note No reply packet */
1616 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 */
1618 struct client_node *client;
1619 const char *pkgname;
1625 struct inst_info *inst;
1626 const struct pkg_info *pkg;
1628 client = client_find_by_pid(pid);
1630 ErrPrint("Client %d is not exists\n", pid);
1631 ret = LB_STATUS_ERROR_NOT_EXIST;
1635 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1637 ErrPrint("Parameter is not matched\n");
1638 ret = LB_STATUS_ERROR_INVALID;
1642 ret = validate_request(pkgname, id, &inst, &pkg);
1643 if (ret != LB_STATUS_SUCCESS)
1646 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1647 struct buffer_info *buffer;
1648 struct slave_node *slave;
1650 buffer = instance_lb_buffer(inst);
1652 ErrPrint("Instance[%s] has no buffer\n", id);
1653 ret = LB_STATUS_ERROR_FAULT;
1657 slave = package_slave(pkg);
1659 ErrPrint("Package[%s] has no slave\n", pkgname);
1660 ret = LB_STATUS_ERROR_INVALID;
1664 packet_ref((struct packet *)packet);
1665 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1666 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1667 struct script_info *script;
1670 script = instance_lb_script(inst);
1672 ret = LB_STATUS_ERROR_FAULT;
1676 e = script_handler_evas(script);
1678 ret = LB_STATUS_ERROR_FAULT;
1682 script_handler_update_pointer(script, x, y, -1);
1683 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
1686 ErrPrint("Unsupported package\n");
1687 ret = LB_STATUS_ERROR_INVALID;
1691 /*! \note No reply packet */
1695 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 */
1697 struct client_node *client;
1698 const char *pkgname;
1704 struct inst_info *inst;
1705 const struct pkg_info *pkg;
1707 client = client_find_by_pid(pid);
1709 ErrPrint("Client %d is not exists\n", pid);
1710 ret = LB_STATUS_ERROR_NOT_EXIST;
1714 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1716 ErrPrint("Parameter is not matched\n");
1717 ret = LB_STATUS_ERROR_INVALID;
1721 ret = validate_request(pkgname, id, &inst, &pkg);
1722 if (ret != LB_STATUS_SUCCESS)
1725 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1726 struct buffer_info *buffer;
1727 struct slave_node *slave;
1729 buffer = instance_lb_buffer(inst);
1731 ErrPrint("Instance[%s] has no buffer\n", id);
1732 ret = LB_STATUS_ERROR_FAULT;
1736 slave = package_slave(pkg);
1738 ErrPrint("Package[%s] has no slave\n", pkgname);
1739 ret = LB_STATUS_ERROR_INVALID;
1743 packet_ref((struct packet *)packet);
1744 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1745 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1746 struct script_info *script;
1749 script = instance_lb_script(inst);
1751 ret = LB_STATUS_ERROR_FAULT;
1755 e = script_handler_evas(script);
1757 ret = LB_STATUS_ERROR_FAULT;
1761 script_handler_update_pointer(script, x, y, 1);
1762 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
1765 ErrPrint("Unsupported package\n");
1766 ret = LB_STATUS_ERROR_INVALID;
1770 /*! \note No reply packet */
1774 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 */
1776 struct client_node *client;
1777 const char *pkgname;
1783 struct inst_info *inst;
1784 const struct pkg_info *pkg;
1786 client = client_find_by_pid(pid);
1788 ErrPrint("Client %d is not exists\n", pid);
1789 ret = LB_STATUS_ERROR_NOT_EXIST;
1793 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1795 ErrPrint("Parameter is not matched\n");
1796 ret = LB_STATUS_ERROR_INVALID;
1800 ret = validate_request(pkgname, id, &inst, &pkg);
1801 if (ret != LB_STATUS_SUCCESS)
1804 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1805 struct buffer_info *buffer;
1806 struct slave_node *slave;
1808 buffer = instance_lb_buffer(inst);
1810 ErrPrint("Instance[%s] has no buffer\n", id);
1811 ret = LB_STATUS_ERROR_FAULT;
1815 slave = package_slave(pkg);
1817 ErrPrint("Package[%s] has no slave\n", pkgname);
1818 ret = LB_STATUS_ERROR_INVALID;
1822 packet_ref((struct packet *)packet);
1823 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1824 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1825 struct script_info *script;
1828 script = instance_lb_script(inst);
1830 ret = LB_STATUS_ERROR_FAULT;
1834 e = script_handler_evas(script);
1836 ret = LB_STATUS_ERROR_FAULT;
1840 script_handler_update_pointer(script, x, y, 0);
1841 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
1844 ErrPrint("Unsupported package\n");
1845 ret = LB_STATUS_ERROR_INVALID;
1849 /*! \note No reply packet */
1853 static struct packet *client_pd_access_action_up(pid_t pid, int handle, const struct packet *packet)
1855 struct packet *result;
1856 struct client_node *client;
1857 const char *pkgname;
1863 struct inst_info *inst;
1864 const struct pkg_info *pkg;
1866 client = client_find_by_pid(pid);
1868 ErrPrint("Client %d is not exists\n", pid);
1869 ret = LB_STATUS_ERROR_NOT_EXIST;
1873 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1875 ErrPrint("Invalid parameter\n");
1876 ret = LB_STATUS_ERROR_INVALID;
1880 ret = validate_request(pkgname, id, &inst, &pkg);
1881 if (ret != LB_STATUS_SUCCESS)
1884 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1885 struct buffer_info *buffer;
1886 struct slave_node *slave;
1888 buffer = instance_pd_buffer(inst);
1890 ErrPrint("Instance[%s] has no buffer\n", id);
1891 ret = LB_STATUS_ERROR_FAULT;
1895 slave = package_slave(pkg);
1897 ErrPrint("Package[%s] has no slave\n", pkgname);
1898 ret = LB_STATUS_ERROR_INVALID;
1902 packet_ref((struct packet *)packet);
1903 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1904 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1905 struct script_info *script;
1908 script = instance_pd_script(inst);
1910 ret = LB_STATUS_ERROR_FAULT;
1914 e = script_handler_evas(script);
1916 ret = LB_STATUS_ERROR_FAULT;
1920 script_handler_update_pointer(script, x, y, 0);
1921 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
1923 struct access_cbdata *cbdata;
1925 cbdata = malloc(sizeof(*cbdata));
1927 ret = LB_STATUS_ERROR_MEMORY;
1929 cbdata->inst = instance_ref(inst);
1930 cbdata->status = ret;
1932 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
1933 (void)instance_unref(cbdata->inst);
1935 ret = LB_STATUS_ERROR_FAULT;
1937 ret = LB_STATUS_SUCCESS;
1942 ErrPrint("Unsupported package\n");
1943 ret = LB_STATUS_ERROR_INVALID;
1947 result = packet_create_reply(packet, "i", ret);
1949 ErrPrint("Failed to create a reply packet\n");
1954 static struct packet *client_pd_access_action_down(pid_t pid, int handle, const struct packet *packet)
1956 struct packet *result;
1957 struct client_node *client;
1958 const char *pkgname;
1964 struct inst_info *inst;
1965 const struct pkg_info *pkg;
1967 client = client_find_by_pid(pid);
1969 ErrPrint("Client %d is not exists\n", pid);
1970 ret = LB_STATUS_ERROR_NOT_EXIST;
1974 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1976 ErrPrint("Invalid parameter\n");
1977 ret = LB_STATUS_ERROR_INVALID;
1981 ret = validate_request(pkgname, id, &inst, &pkg);
1982 if (ret != LB_STATUS_SUCCESS)
1985 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1986 struct buffer_info *buffer;
1987 struct slave_node *slave;
1989 buffer = instance_pd_buffer(inst);
1991 ErrPrint("Instance[%s] has no buffer\n", id);
1992 ret = LB_STATUS_ERROR_FAULT;
1996 slave = package_slave(pkg);
1998 ErrPrint("Package[%s] has no slave\n", pkgname);
1999 ret = LB_STATUS_ERROR_INVALID;
2003 packet_ref((struct packet *)packet);
2004 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2005 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2006 struct script_info *script;
2009 script = instance_pd_script(inst);
2011 ret = LB_STATUS_ERROR_FAULT;
2015 e = script_handler_evas(script);
2017 ret = LB_STATUS_ERROR_FAULT;
2021 script_handler_update_pointer(script, x, y, 1);
2022 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
2024 struct access_cbdata *cbdata;
2026 cbdata = malloc(sizeof(*cbdata));
2028 ret = LB_STATUS_ERROR_MEMORY;
2030 cbdata->inst = instance_ref(inst);
2031 cbdata->status = ret;
2033 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2034 (void)instance_unref(cbdata->inst);
2036 ret = LB_STATUS_ERROR_FAULT;
2038 ret = LB_STATUS_SUCCESS;
2043 ErrPrint("Unsupported package\n");
2044 ret = LB_STATUS_ERROR_INVALID;
2048 result = packet_create_reply(packet, "i", ret);
2050 ErrPrint("Failed to create a reply packet\n");
2055 static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
2057 struct packet *result;
2058 struct client_node *client;
2059 const char *pkgname;
2065 struct inst_info *inst;
2066 const struct pkg_info *pkg;
2068 client = client_find_by_pid(pid);
2070 ErrPrint("Client %d is not exists\n", pid);
2071 ret = LB_STATUS_ERROR_NOT_EXIST;
2075 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2077 ErrPrint("Invalid parameter\n");
2078 ret = LB_STATUS_ERROR_INVALID;
2082 ret = validate_request(pkgname, id, &inst, &pkg);
2083 if (ret != LB_STATUS_SUCCESS)
2086 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2087 struct buffer_info *buffer;
2088 struct slave_node *slave;
2090 buffer = instance_pd_buffer(inst);
2092 ErrPrint("Instance[%s] has no buffer\n", id);
2093 ret = LB_STATUS_ERROR_FAULT;
2097 slave = package_slave(pkg);
2099 ErrPrint("Package[%s] has no slave\n", pkgname);
2100 ret = LB_STATUS_ERROR_INVALID;
2104 packet_ref((struct packet *)packet);
2105 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2106 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2107 struct script_info *script;
2110 script = instance_pd_script(inst);
2112 ret = LB_STATUS_ERROR_FAULT;
2116 e = script_handler_evas(script);
2118 ret = LB_STATUS_ERROR_FAULT;
2122 script_handler_update_pointer(script, x, y, 1);
2123 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2125 struct access_cbdata *cbdata;
2127 cbdata = malloc(sizeof(*cbdata));
2129 ret = LB_STATUS_ERROR_MEMORY;
2131 cbdata->inst = instance_ref(inst);
2132 cbdata->status = ret;
2134 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2135 (void)instance_unref(cbdata->inst);
2137 ret = LB_STATUS_ERROR_FAULT;
2139 ret = LB_STATUS_SUCCESS;
2144 ErrPrint("Unsupported package\n");
2145 ret = LB_STATUS_ERROR_INVALID;
2149 result = packet_create_reply(packet, "i", ret);
2151 ErrPrint("Failed to create a reply packet\n");
2156 static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
2158 struct packet *result;
2159 struct client_node *client;
2160 const char *pkgname;
2166 struct inst_info *inst;
2167 const struct pkg_info *pkg;
2169 client = client_find_by_pid(pid);
2171 ErrPrint("Client %d is not exists\n", pid);
2172 ret = LB_STATUS_ERROR_NOT_EXIST;
2176 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2178 ErrPrint("Invalid parameter\n");
2179 ret = LB_STATUS_ERROR_INVALID;
2183 ret = validate_request(pkgname, id, &inst, &pkg);
2184 if (ret != LB_STATUS_SUCCESS)
2187 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2188 struct buffer_info *buffer;
2189 struct slave_node *slave;
2191 buffer = instance_pd_buffer(inst);
2193 ErrPrint("Instance[%s] has no buffer\n", id);
2194 ret = LB_STATUS_ERROR_FAULT;
2198 slave = package_slave(pkg);
2200 ErrPrint("Package[%s] has no slave\n", pkgname);
2201 ret = LB_STATUS_ERROR_INVALID;
2205 packet_ref((struct packet *)packet);
2206 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2207 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2208 struct script_info *script;
2211 script = instance_pd_script(inst);
2213 ret = LB_STATUS_ERROR_FAULT;
2217 e = script_handler_evas(script);
2219 ret = LB_STATUS_ERROR_FAULT;
2223 script_handler_update_pointer(script, x, y, -1);
2224 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2226 struct access_cbdata *cbdata;
2228 cbdata = malloc(sizeof(*cbdata));
2230 ret = LB_STATUS_ERROR_MEMORY;
2232 cbdata->inst = instance_ref(inst);
2233 cbdata->status = ret;
2235 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2236 (void)instance_unref(cbdata->inst);
2238 ret = LB_STATUS_ERROR_FAULT;
2240 ret = LB_STATUS_SUCCESS;
2245 ErrPrint("Unsupported package\n");
2246 ret = LB_STATUS_ERROR_INVALID;
2250 result = packet_create_reply(packet, "i", ret);
2252 ErrPrint("Failed to create a reply packet\n");
2257 static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
2259 struct packet *result;
2260 struct client_node *client;
2261 const char *pkgname;
2267 struct inst_info *inst;
2268 const struct pkg_info *pkg;
2270 client = client_find_by_pid(pid);
2272 ErrPrint("Client %d is not exists\n", pid);
2273 ret = LB_STATUS_ERROR_NOT_EXIST;
2277 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2279 ErrPrint("Invalid parameter\n");
2280 ret = LB_STATUS_ERROR_INVALID;
2284 ret = validate_request(pkgname, id, &inst, &pkg);
2285 if (ret != LB_STATUS_SUCCESS)
2288 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2289 struct buffer_info *buffer;
2290 struct slave_node *slave;
2292 buffer = instance_pd_buffer(inst);
2294 ErrPrint("Instance[%s] has no buffer\n", id);
2295 ret = LB_STATUS_ERROR_FAULT;
2299 slave = package_slave(pkg);
2301 ErrPrint("Package[%s] has no slave\n", pkgname);
2302 ret = LB_STATUS_ERROR_INVALID;
2306 packet_ref((struct packet *)packet);
2307 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2308 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2309 struct script_info *script;
2312 script = instance_pd_script(inst);
2314 ret = LB_STATUS_ERROR_FAULT;
2318 e = script_handler_evas(script);
2320 ret = LB_STATUS_ERROR_FAULT;
2324 script_handler_update_pointer(script, x, y, 0);
2325 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2327 struct access_cbdata *cbdata;
2329 cbdata = malloc(sizeof(*cbdata));
2331 ret = LB_STATUS_ERROR_MEMORY;
2333 cbdata->inst = instance_ref(inst);
2334 cbdata->status = ret;
2336 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2337 (void)instance_unref(cbdata->inst);
2339 ret = LB_STATUS_ERROR_FAULT;
2341 ret = LB_STATUS_SUCCESS;
2346 ErrPrint("Unsupported package\n");
2347 ret = LB_STATUS_ERROR_INVALID;
2351 result = packet_create_reply(packet, "i", ret);
2353 ErrPrint("Failed to create a reply packet\n");
2358 static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
2360 struct packet *result;
2361 struct client_node *client;
2362 const char *pkgname;
2366 struct inst_info *inst;
2367 const struct pkg_info *pkg;
2371 client = client_find_by_pid(pid);
2373 ErrPrint("Client %d is not exists\n", pid);
2374 ret = LB_STATUS_ERROR_NOT_EXIST;
2378 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2380 ErrPrint("Invalid parameter\n");
2381 ret = LB_STATUS_ERROR_INVALID;
2385 ret = validate_request(pkgname, id, &inst, &pkg);
2386 if (ret != LB_STATUS_SUCCESS)
2389 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2390 struct buffer_info *buffer;
2391 struct slave_node *slave;
2393 buffer = instance_pd_buffer(inst);
2395 ErrPrint("Instance[%s] has no buffer\n", id);
2396 ret = LB_STATUS_ERROR_FAULT;
2400 slave = package_slave(pkg);
2402 ErrPrint("Package[%s] has no slave\n", pkgname);
2403 ret = LB_STATUS_ERROR_INVALID;
2407 packet_ref((struct packet *)packet);
2408 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2409 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2410 struct script_info *script;
2413 script = instance_pd_script(inst);
2415 ret = LB_STATUS_ERROR_FAULT;
2419 e = script_handler_evas(script);
2421 ret = LB_STATUS_ERROR_FAULT;
2425 script_handler_update_pointer(script, x, y, -1);
2426 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
2428 struct access_cbdata *cbdata;
2430 cbdata = malloc(sizeof(*cbdata));
2432 ret = LB_STATUS_ERROR_MEMORY;
2434 cbdata->inst = instance_ref(inst);
2435 cbdata->status = ret;
2437 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2438 (void)instance_unref(cbdata->inst);
2440 ret = LB_STATUS_ERROR_FAULT;
2442 ret = LB_STATUS_SUCCESS;
2447 ErrPrint("Unsupported package\n");
2448 ret = LB_STATUS_ERROR_INVALID;
2451 result = packet_create_reply(packet, "i", ret);
2453 ErrPrint("Failed to create a reply packet\n");
2458 static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct packet *packet)
2460 struct packet *result;
2461 struct client_node *client;
2462 const char *pkgname;
2468 struct inst_info *inst;
2469 const struct pkg_info *pkg;
2471 client = client_find_by_pid(pid);
2473 ErrPrint("Client %d is not exists\n", pid);
2474 ret = LB_STATUS_ERROR_NOT_EXIST;
2478 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2480 ErrPrint("Invalid parameter\n");
2481 ret = LB_STATUS_ERROR_INVALID;
2485 ret = validate_request(pkgname, id, &inst, &pkg);
2486 if (ret != LB_STATUS_SUCCESS)
2489 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2490 struct buffer_info *buffer;
2491 struct slave_node *slave;
2493 buffer = instance_pd_buffer(inst);
2495 ErrPrint("Instance[%s] has no buffer\n", id);
2496 ret = LB_STATUS_ERROR_FAULT;
2500 slave = package_slave(pkg);
2502 ErrPrint("Package[%s] has no slave\n", pkgname);
2503 ret = LB_STATUS_ERROR_INVALID;
2507 packet_ref((struct packet *)packet);
2508 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2509 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2510 struct script_info *script;
2513 script = instance_pd_script(inst);
2515 ret = LB_STATUS_ERROR_FAULT;
2519 e = script_handler_evas(script);
2521 ret = LB_STATUS_ERROR_FAULT;
2525 script_handler_update_pointer(script, x, y, -1);
2526 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
2528 struct access_cbdata *cbdata;
2530 cbdata = malloc(sizeof(*cbdata));
2532 ret = LB_STATUS_ERROR_MEMORY;
2534 cbdata->inst = instance_ref(inst);
2535 cbdata->status = ret;
2537 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2538 (void)instance_unref(cbdata->inst);
2540 ret = LB_STATUS_ERROR_FAULT;
2542 ret = LB_STATUS_SUCCESS;
2547 ErrPrint("Unsupported package\n");
2548 ret = LB_STATUS_ERROR_INVALID;
2552 result = packet_create_reply(packet, "i", ret);
2554 ErrPrint("Failed to create a reply packet\n");
2559 static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
2561 struct packet *result;
2562 struct client_node *client;
2563 const char *pkgname;
2569 struct inst_info *inst;
2570 const struct pkg_info *pkg;
2572 client = client_find_by_pid(pid);
2574 ErrPrint("Client %d is not exists\n", pid);
2575 ret = LB_STATUS_ERROR_NOT_EXIST;
2579 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2581 ErrPrint("Invalid parameter\n");
2582 ret = LB_STATUS_ERROR_INVALID;
2586 ret = validate_request(pkgname, id, &inst, &pkg);
2587 if (ret != LB_STATUS_SUCCESS)
2590 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2591 struct buffer_info *buffer;
2592 struct slave_node *slave;
2594 buffer = instance_pd_buffer(inst);
2596 ErrPrint("Instance[%s] has no buffer\n", id);
2597 ret = LB_STATUS_ERROR_FAULT;
2601 slave = package_slave(pkg);
2603 ErrPrint("Package[%s] has no slave\n", pkgname);
2604 ret = LB_STATUS_ERROR_INVALID;
2608 packet_ref((struct packet *)packet);
2609 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2610 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2611 struct script_info *script;
2614 script = instance_pd_script(inst);
2616 ret = LB_STATUS_ERROR_FAULT;
2620 e = script_handler_evas(script);
2622 ret = LB_STATUS_ERROR_FAULT;
2626 script_handler_update_pointer(script, x, y, -1);
2627 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
2629 struct access_cbdata *cbdata;
2631 cbdata = malloc(sizeof(*cbdata));
2633 ret = LB_STATUS_ERROR_MEMORY;
2635 cbdata->inst = instance_ref(inst);
2636 cbdata->status = ret;
2638 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2639 (void)instance_unref(cbdata->inst);
2641 ret = LB_STATUS_ERROR_FAULT;
2643 ret = LB_STATUS_SUCCESS;
2648 ErrPrint("Unsupported package\n");
2649 ret = LB_STATUS_ERROR_INVALID;
2653 result = packet_create_reply(packet, "i", ret);
2655 ErrPrint("Failed to create a reply packet\n");
2660 static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const struct packet *packet)
2662 struct packet *result;
2663 struct client_node *client;
2664 const char *pkgname;
2670 struct inst_info *inst;
2671 const struct pkg_info *pkg;
2673 client = client_find_by_pid(pid);
2675 ErrPrint("Client %d is not exists\n", pid);
2676 ret = LB_STATUS_ERROR_NOT_EXIST;
2680 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2682 ErrPrint("Invalid parameter\n");
2683 ret = LB_STATUS_ERROR_INVALID;
2687 ret = validate_request(pkgname, id, &inst, &pkg);
2688 if (ret != LB_STATUS_SUCCESS)
2691 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2692 struct buffer_info *buffer;
2693 struct slave_node *slave;
2695 buffer = instance_pd_buffer(inst);
2697 ErrPrint("Instance[%s] has no buffer\n", id);
2698 ret = LB_STATUS_ERROR_FAULT;
2702 slave = package_slave(pkg);
2704 ErrPrint("Package[%s] has no slave\n", pkgname);
2705 ret = LB_STATUS_ERROR_INVALID;
2709 packet_ref((struct packet *)packet);
2710 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2711 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2712 struct script_info *script;
2715 script = instance_pd_script(inst);
2717 ErrPrint("Script is not created yet\n");
2718 ret = LB_STATUS_ERROR_FAULT;
2722 e = script_handler_evas(script);
2724 ErrPrint("Evas is not exists\n");
2725 ret = LB_STATUS_ERROR_FAULT;
2729 script_handler_update_pointer(script, x, y, -1);
2730 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
2732 struct access_cbdata *cbdata;
2734 cbdata = malloc(sizeof(*cbdata));
2736 ErrPrint("Heap: %s\n", strerror(errno));
2737 ret = LB_STATUS_ERROR_MEMORY;
2739 cbdata->inst = instance_ref(inst);
2740 cbdata->status = ret;
2742 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2743 ErrPrint("Failed to add timer\n");
2744 (void)instance_unref(cbdata->inst);
2746 ret = LB_STATUS_ERROR_FAULT;
2748 ret = LB_STATUS_SUCCESS;
2752 DbgPrint("Returns: %d\n", ret);
2755 ErrPrint("Unsupported package\n");
2756 ret = LB_STATUS_ERROR_INVALID;
2760 result = packet_create_reply(packet, "i", ret);
2762 ErrPrint("Failed to create a reply packet\n");
2767 static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
2769 struct packet *result;
2770 struct client_node *client;
2771 const char *pkgname;
2777 struct inst_info *inst;
2778 const struct pkg_info *pkg;
2780 client = client_find_by_pid(pid);
2782 ErrPrint("Client %d is not exists\n", pid);
2783 ret = LB_STATUS_ERROR_NOT_EXIST;
2787 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2789 ErrPrint("Invalid parameter\n");
2790 ret = LB_STATUS_ERROR_INVALID;
2794 ret = validate_request(pkgname, id, &inst, &pkg);
2795 if (ret != LB_STATUS_SUCCESS)
2798 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2799 struct buffer_info *buffer;
2800 struct slave_node *slave;
2802 buffer = instance_pd_buffer(inst);
2804 ErrPrint("Instance[%s] has no buffer\n", id);
2805 ret = LB_STATUS_ERROR_FAULT;
2809 slave = package_slave(pkg);
2811 ErrPrint("Package[%s] has no slave\n", pkgname);
2812 ret = LB_STATUS_ERROR_INVALID;
2816 packet_ref((struct packet *)packet);
2817 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2818 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2819 struct script_info *script;
2822 script = instance_pd_script(inst);
2824 ret = LB_STATUS_ERROR_FAULT;
2828 e = script_handler_evas(script);
2830 ret = LB_STATUS_ERROR_FAULT;
2834 script_handler_update_pointer(script, x, y, -1);
2835 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
2837 struct access_cbdata *cbdata;
2839 cbdata = malloc(sizeof(*cbdata));
2841 ret = LB_STATUS_ERROR_MEMORY;
2843 cbdata->inst = instance_ref(inst);
2844 cbdata->status = ret;
2846 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2847 (void)instance_unref(cbdata->inst);
2849 ret = LB_STATUS_ERROR_FAULT;
2851 ret = LB_STATUS_SUCCESS;
2856 ErrPrint("Unsupported package\n");
2857 ret = LB_STATUS_ERROR_INVALID;
2861 result = packet_create_reply(packet, "i", ret);
2863 ErrPrint("Failed to create a reply packet\n");
2868 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
2870 struct client_node *client;
2871 const char *pkgname;
2877 struct inst_info *inst;
2878 const struct pkg_info *pkg;
2880 client = client_find_by_pid(pid);
2882 ErrPrint("Client %d is not exists\n", pid);
2883 ret = LB_STATUS_ERROR_NOT_EXIST;
2887 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2889 ErrPrint("Invalid parameter\n");
2890 ret = LB_STATUS_ERROR_INVALID;
2894 ret = validate_request(pkgname, id, &inst, &pkg);
2895 if (ret != LB_STATUS_SUCCESS)
2898 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2899 struct buffer_info *buffer;
2900 struct slave_node *slave;
2902 buffer = instance_pd_buffer(inst);
2904 ErrPrint("Instance[%s] has no buffer\n", id);
2905 ret = LB_STATUS_ERROR_FAULT;
2909 slave = package_slave(pkg);
2911 ErrPrint("Package[%s] has no slave\n", pkgname);
2912 ret = LB_STATUS_ERROR_INVALID;
2916 packet_ref((struct packet *)packet);
2917 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2918 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2919 struct script_info *script;
2922 script = instance_pd_script(inst);
2924 ret = LB_STATUS_ERROR_FAULT;
2928 e = script_handler_evas(script);
2930 ret = LB_STATUS_ERROR_FAULT;
2934 script_handler_update_pointer(script, x, y, -1);
2936 * \TODO: Push up the KEY_DOWN event
2940 ErrPrint("Unsupported package\n");
2941 ret = LB_STATUS_ERROR_INVALID;
2945 /*! \note No reply packet */
2949 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
2951 struct client_node *client;
2955 client = client_find_by_pid(pid);
2957 ErrPrint("Client %d is paused - manually reported\n", pid);
2958 ret = LB_STATUS_ERROR_NOT_EXIST;
2962 ret = packet_get(packet, "d", ×tamp);
2964 ErrPrint("Invalid parameter\n");
2965 ret = LB_STATUS_ERROR_INVALID;
2970 DbgPrint("XMONITOR enabled. ignore client paused request\n");
2972 xmonitor_pause(client);
2978 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
2980 struct client_node *client;
2984 client = client_find_by_pid(pid);
2986 ErrPrint("Client %d is not exists\n", pid);
2990 ret = packet_get(packet, "d", ×tamp);
2992 ErrPrint("Invalid parameter\n");
2997 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
2999 xmonitor_resume(client);
3005 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
3007 struct client_node *client;
3008 const char *pkgname;
3014 struct inst_info *inst;
3015 const struct pkg_info *pkg;
3017 client = client_find_by_pid(pid);
3019 ErrPrint("Client %d is not exists\n", pid);
3020 ret = LB_STATUS_ERROR_NOT_EXIST;
3024 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3026 ErrPrint("Invalid parameter\n");
3027 ret = LB_STATUS_ERROR_INVALID;
3031 ret = validate_request(pkgname, id, &inst, &pkg);
3032 if (ret != LB_STATUS_SUCCESS)
3035 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3036 struct buffer_info *buffer;
3037 struct slave_node *slave;
3039 buffer = instance_pd_buffer(inst);
3041 ErrPrint("Instance[%s] has no buffer\n", id);
3042 ret = LB_STATUS_ERROR_FAULT;
3046 slave = package_slave(pkg);
3048 ErrPrint("Package[%s] has no slave\n", pkgname);
3049 ret = LB_STATUS_ERROR_INVALID;
3053 packet_ref((struct packet *)packet);
3054 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3055 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3056 struct script_info *script;
3059 script = instance_pd_script(inst);
3061 ret = LB_STATUS_ERROR_FAULT;
3065 e = script_handler_evas(script);
3067 ret = LB_STATUS_ERROR_FAULT;
3071 script_handler_update_pointer(script, x, y, -1);
3073 * \TODO: Push up the KEY_UP event
3077 ErrPrint("Unsupported package\n");
3078 ret = LB_STATUS_ERROR_INVALID;
3082 /*! \note No reply packet */
3086 static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
3088 struct packet *result;
3089 struct client_node *client;
3090 const char *pkgname;
3096 struct inst_info *inst;
3097 const struct pkg_info *pkg;
3099 client = client_find_by_pid(pid);
3101 ErrPrint("Client %d is not exists\n", pid);
3102 ret = LB_STATUS_ERROR_NOT_EXIST;
3106 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3108 ErrPrint("Parameter is not matched\n");
3109 ret = LB_STATUS_ERROR_INVALID;
3113 ret = validate_request(pkgname, id, &inst, &pkg);
3114 if (ret != LB_STATUS_SUCCESS)
3117 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3118 struct buffer_info *buffer;
3119 struct slave_node *slave;
3121 buffer = instance_lb_buffer(inst);
3123 ErrPrint("Instance[%s] has no buffer\n", id);
3124 ret = LB_STATUS_ERROR_FAULT;
3128 slave = package_slave(pkg);
3130 ErrPrint("Package[%s] has no slave\n", pkgname);
3131 ret = LB_STATUS_ERROR_INVALID;
3135 packet_ref((struct packet *)packet);
3136 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3137 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3138 struct script_info *script;
3141 script = instance_lb_script(inst);
3143 ret = LB_STATUS_ERROR_FAULT;
3147 e = script_handler_evas(script);
3149 ret = LB_STATUS_ERROR_FAULT;
3153 script_handler_update_pointer(script, x, y, -1);
3154 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
3156 struct access_cbdata *cbdata;
3158 cbdata = malloc(sizeof(*cbdata));
3160 ret = LB_STATUS_ERROR_MEMORY;
3162 cbdata->inst = instance_ref(inst);
3163 cbdata->status = ret;
3165 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3166 (void)instance_unref(cbdata->inst);
3168 ret = LB_STATUS_ERROR_FAULT;
3170 ret = LB_STATUS_SUCCESS;
3175 ErrPrint("Unsupported package\n");
3176 ret = LB_STATUS_ERROR_INVALID;
3180 result = packet_create_reply(packet, "i", ret);
3182 ErrPrint("Failed to create a reply packet\n");
3187 static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
3189 struct packet *result;
3190 struct client_node *client;
3191 const char *pkgname;
3197 struct inst_info *inst;
3198 const struct pkg_info *pkg;
3200 client = client_find_by_pid(pid);
3202 ErrPrint("Client %d is not exists\n", pid);
3203 ret = LB_STATUS_ERROR_NOT_EXIST;
3207 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3209 ErrPrint("Parameter is not matched\n");
3210 ret = LB_STATUS_ERROR_INVALID;
3214 ret = validate_request(pkgname, id, &inst, &pkg);
3215 if (ret != LB_STATUS_SUCCESS)
3218 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3219 struct buffer_info *buffer;
3220 struct slave_node *slave;
3222 buffer = instance_lb_buffer(inst);
3224 ErrPrint("Instance[%s] has no buffer\n", id);
3225 ret = LB_STATUS_ERROR_FAULT;
3229 slave = package_slave(pkg);
3231 ErrPrint("Package[%s] has no slave\n", pkgname);
3232 ret = LB_STATUS_ERROR_INVALID;
3236 packet_ref((struct packet *)packet);
3237 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3238 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3239 struct script_info *script;
3242 script = instance_lb_script(inst);
3244 ret = LB_STATUS_ERROR_FAULT;
3248 e = script_handler_evas(script);
3250 ret = LB_STATUS_ERROR_FAULT;
3254 script_handler_update_pointer(script, x, y, -1);
3255 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
3257 struct access_cbdata *cbdata;
3259 cbdata = malloc(sizeof(*cbdata));
3261 ret = LB_STATUS_ERROR_MEMORY;
3263 cbdata->inst = instance_ref(inst);
3264 cbdata->status = ret;
3266 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3267 (void)instance_unref(cbdata->inst);
3269 ret = LB_STATUS_ERROR_FAULT;
3271 ret = LB_STATUS_SUCCESS;
3276 ErrPrint("Unsupported package\n");
3277 ret = LB_STATUS_ERROR_INVALID;
3281 result = packet_create_reply(packet, "i", ret);
3283 ErrPrint("Failed to create a reply packet\n");
3288 static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet)
3290 struct packet *result;
3291 struct client_node *client;
3292 const char *pkgname;
3298 struct inst_info *inst;
3299 const struct pkg_info *pkg;
3301 client = client_find_by_pid(pid);
3303 ErrPrint("Client %d is not exists\n", pid);
3304 ret = LB_STATUS_ERROR_NOT_EXIST;
3308 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3310 ErrPrint("Parameter is not matched\n");
3311 ret = LB_STATUS_ERROR_INVALID;
3315 ret = validate_request(pkgname, id, &inst, &pkg);
3316 if (ret != LB_STATUS_SUCCESS)
3319 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3320 struct buffer_info *buffer;
3321 struct slave_node *slave;
3323 buffer = instance_lb_buffer(inst);
3325 ErrPrint("Instance[%s] has no buffer\n", id);
3326 ret = LB_STATUS_ERROR_FAULT;
3330 slave = package_slave(pkg);
3332 ErrPrint("Package[%s] has no slave\n", pkgname);
3333 ret = LB_STATUS_ERROR_INVALID;
3337 packet_ref((struct packet *)packet);
3338 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3339 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3340 struct script_info *script;
3343 script = instance_lb_script(inst);
3345 ret = LB_STATUS_ERROR_FAULT;
3349 e = script_handler_evas(script);
3351 ret = LB_STATUS_ERROR_FAULT;
3355 script_handler_update_pointer(script, x, y, -1);
3356 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
3358 struct access_cbdata *cbdata;
3360 cbdata = malloc(sizeof(*cbdata));
3362 ret = LB_STATUS_ERROR_MEMORY;
3364 cbdata->inst = instance_ref(inst);
3365 cbdata->status = ret;
3367 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3368 (void)instance_unref(cbdata->inst);
3370 ret = LB_STATUS_ERROR_FAULT;
3372 ret = LB_STATUS_SUCCESS;
3377 ErrPrint("Unsupported package\n");
3378 ret = LB_STATUS_ERROR_INVALID;
3382 result = packet_create_reply(packet, "i", ret);
3384 ErrPrint("Failed to create a reply packet\n");
3389 static struct packet *client_lb_access_action_up(pid_t pid, int handle, const struct packet *packet)
3391 struct packet *result;
3392 struct client_node *client;
3393 const char *pkgname;
3397 struct inst_info *inst;
3398 const struct pkg_info *pkg;
3402 client = client_find_by_pid(pid);
3404 ErrPrint("Client %d is not exist\n", pid);
3405 ret = LB_STATUS_ERROR_NOT_EXIST;
3409 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3411 ErrPrint("Parameter is not matched\n");
3412 ret = LB_STATUS_ERROR_INVALID;
3416 ret = validate_request(pkgname, id, &inst, &pkg);
3417 if (ret != LB_STATUS_SUCCESS)
3420 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3421 struct buffer_info *buffer;
3422 struct slave_node *slave;
3424 buffer = instance_lb_buffer(inst);
3426 ErrPrint("Instance[%s] has no buffer\n", id);
3427 ret = LB_STATUS_ERROR_FAULT;
3431 slave = package_slave(pkg);
3433 ErrPrint("Slave is not exists\n");
3434 ret = LB_STATUS_ERROR_INVALID;
3438 packet_ref((struct packet *)packet);
3439 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3441 * Enen if it fails to send packet,
3442 * The packet will be unref'd
3443 * So we don't need to check the ret value.
3445 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3446 struct script_info *script;
3449 script = instance_lb_script(inst);
3451 ErrPrint("Instance has no script\n");
3452 ret = LB_STATUS_ERROR_FAULT;
3456 e = script_handler_evas(script);
3458 ErrPrint("Script has no evas\n");
3459 ret = LB_STATUS_ERROR_INVALID;
3463 script_handler_update_pointer(script, x, y, 0);
3464 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
3466 struct access_cbdata *cbdata;
3468 cbdata = malloc(sizeof(*cbdata));
3470 ret = LB_STATUS_ERROR_MEMORY;
3472 cbdata->inst = instance_ref(inst);
3473 cbdata->status = ret;
3475 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3476 (void)instance_unref(cbdata->inst);
3478 ret = LB_STATUS_ERROR_FAULT;
3480 ret = LB_STATUS_SUCCESS;
3485 ErrPrint("Unsupported package\n");
3486 ret = LB_STATUS_ERROR_INVALID;
3490 result = packet_create_reply(packet, "i", ret);
3492 ErrPrint("Failed to create a reply packet\n");
3497 static struct packet *client_lb_access_action_down(pid_t pid, int handle, const struct packet *packet)
3499 struct packet *result;
3500 struct client_node *client;
3501 const char *pkgname;
3505 struct inst_info *inst;
3506 const struct pkg_info *pkg;
3510 client = client_find_by_pid(pid);
3512 ErrPrint("Client %d is not exist\n", pid);
3513 ret = LB_STATUS_ERROR_NOT_EXIST;
3517 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3519 ErrPrint("Parameter is not matched\n");
3520 ret = LB_STATUS_ERROR_INVALID;
3524 ret = validate_request(pkgname, id, &inst, &pkg);
3525 if (ret != LB_STATUS_SUCCESS)
3528 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3529 struct buffer_info *buffer;
3530 struct slave_node *slave;
3532 buffer = instance_lb_buffer(inst);
3534 ErrPrint("Instance[%s] has no buffer\n", id);
3535 ret = LB_STATUS_ERROR_FAULT;
3539 slave = package_slave(pkg);
3541 ErrPrint("Slave is not exists\n");
3542 ret = LB_STATUS_ERROR_INVALID;
3546 packet_ref((struct packet *)packet);
3547 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3549 * Enen if it fails to send packet,
3550 * The packet will be unref'd
3551 * So we don't need to check the ret value.
3553 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3554 struct script_info *script;
3557 script = instance_lb_script(inst);
3559 ErrPrint("Instance has no script\n");
3560 ret = LB_STATUS_ERROR_FAULT;
3564 e = script_handler_evas(script);
3566 ErrPrint("Script has no evas\n");
3567 ret = LB_STATUS_ERROR_INVALID;
3571 script_handler_update_pointer(script, x, y, 1);
3572 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
3574 struct access_cbdata *cbdata;
3576 cbdata = malloc(sizeof(*cbdata));
3578 ret = LB_STATUS_ERROR_MEMORY;
3580 cbdata->inst = instance_ref(inst);
3581 cbdata->status = ret;
3583 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3584 (void)instance_unref(cbdata->inst);
3586 ret = LB_STATUS_ERROR_FAULT;
3588 ret = LB_STATUS_SUCCESS;
3593 ErrPrint("Unsupported package\n");
3594 ret = LB_STATUS_ERROR_INVALID;
3598 result = packet_create_reply(packet, "i", ret);
3600 ErrPrint("Failed to create a reply packet\n");
3605 static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
3607 struct packet *result;
3608 struct client_node *client;
3609 const char *pkgname;
3615 struct inst_info *inst;
3616 const struct pkg_info *pkg;
3618 client = client_find_by_pid(pid);
3620 ErrPrint("Client %d is not exists\n", pid);
3621 ret = LB_STATUS_ERROR_NOT_EXIST;
3625 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3627 ErrPrint("Parameter is not matched\n");
3628 ret = LB_STATUS_ERROR_INVALID;
3632 ret = validate_request(pkgname, id, &inst, &pkg);
3633 if (ret != LB_STATUS_SUCCESS)
3636 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3637 struct buffer_info *buffer;
3638 struct slave_node *slave;
3640 buffer = instance_lb_buffer(inst);
3642 ErrPrint("Instance[%s] has no buffer\n", id);
3643 ret = LB_STATUS_ERROR_FAULT;
3647 slave = package_slave(pkg);
3649 ErrPrint("Package[%s] has no slave\n", pkgname);
3650 ret = LB_STATUS_ERROR_INVALID;
3654 packet_ref((struct packet *)packet);
3655 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3656 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3657 struct script_info *script;
3660 script = instance_lb_script(inst);
3662 ret = LB_STATUS_ERROR_FAULT;
3666 e = script_handler_evas(script);
3668 ret = LB_STATUS_ERROR_FAULT;
3672 script_handler_update_pointer(script, x, y, -1);
3673 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
3675 struct access_cbdata *cbdata;
3677 cbdata = malloc(sizeof(*cbdata));
3679 ret = LB_STATUS_ERROR_MEMORY;
3681 cbdata->inst = instance_ref(inst);
3682 cbdata->status = ret;
3684 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3685 (void)instance_unref(cbdata->inst);
3687 ret = LB_STATUS_ERROR_FAULT;
3689 ret = LB_STATUS_SUCCESS;
3694 ErrPrint("Unsupported package\n");
3695 ret = LB_STATUS_ERROR_INVALID;
3699 result = packet_create_reply(packet, "i", ret);
3701 ErrPrint("Failed to create a reply packet\n");
3706 static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
3708 struct packet *result;
3709 struct client_node *client;
3710 const char *pkgname;
3714 struct inst_info *inst;
3715 const struct pkg_info *pkg;
3719 client = client_find_by_pid(pid);
3721 ErrPrint("Client %d is not exist\n", pid);
3722 ret = LB_STATUS_ERROR_NOT_EXIST;
3726 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3728 ErrPrint("Parameter is not matched\n");
3729 ret = LB_STATUS_ERROR_INVALID;
3733 ret = validate_request(pkgname, id, &inst, &pkg);
3734 if (ret != LB_STATUS_SUCCESS)
3737 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3738 struct buffer_info *buffer;
3739 struct slave_node *slave;
3741 buffer = instance_lb_buffer(inst);
3743 ErrPrint("Instance[%s] has no buffer\n", id);
3744 ret = LB_STATUS_ERROR_FAULT;
3748 slave = package_slave(pkg);
3750 ErrPrint("Slave is not exists\n");
3751 ret = LB_STATUS_ERROR_INVALID;
3755 packet_ref((struct packet *)packet);
3756 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3758 * Enen if it fails to send packet,
3759 * The packet will be unref'd
3760 * So we don't need to check the ret value.
3762 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3763 struct script_info *script;
3766 script = instance_lb_script(inst);
3768 ErrPrint("Instance has no script\n");
3769 ret = LB_STATUS_ERROR_FAULT;
3773 e = script_handler_evas(script);
3775 ErrPrint("Instance has no evas\n");
3776 ret = LB_STATUS_ERROR_INVALID;
3780 script_handler_update_pointer(script, x, y, 1);
3781 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
3783 struct access_cbdata *cbdata;
3785 cbdata = malloc(sizeof(*cbdata));
3787 ret = LB_STATUS_ERROR_MEMORY;
3789 cbdata->inst = instance_ref(inst);
3790 cbdata->status = ret;
3792 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3793 (void)instance_unref(cbdata->inst);
3795 ret = LB_STATUS_ERROR_FAULT;
3797 ret = LB_STATUS_SUCCESS;
3802 ErrPrint("Unsupported package\n");
3803 ret = LB_STATUS_ERROR_INVALID;
3807 result = packet_create_reply(packet, "i", ret);
3809 ErrPrint("Failed to create a reply packet\n");
3814 static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
3816 struct packet *result;
3817 struct client_node *client;
3818 const char *pkgname;
3822 struct inst_info *inst;
3823 const struct pkg_info *pkg;
3827 client = client_find_by_pid(pid);
3829 ErrPrint("Client %d is not exist\n", pid);
3830 ret = LB_STATUS_ERROR_NOT_EXIST;
3834 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3836 ErrPrint("Parameter is not matched\n");
3837 ret = LB_STATUS_ERROR_INVALID;
3841 ret = validate_request(pkgname, id, &inst, &pkg);
3842 if (ret != LB_STATUS_SUCCESS)
3845 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3846 struct buffer_info *buffer;
3847 struct slave_node *slave;
3849 buffer = instance_lb_buffer(inst);
3851 ErrPrint("Instance[%s] has no buffer\n", id);
3852 ret = LB_STATUS_ERROR_FAULT;
3856 slave = package_slave(pkg);
3858 ErrPrint("Slave is not exists\n");
3859 ret = LB_STATUS_ERROR_INVALID;
3863 packet_ref((struct packet *)packet);
3864 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3866 * Enen if it fails to send packet,
3867 * The packet will be unref'd
3868 * So we don't need to check the ret value.
3870 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3871 struct script_info *script;
3874 script = instance_lb_script(inst);
3876 ErrPrint("Instance has no script\n");
3877 ret = LB_STATUS_ERROR_FAULT;
3881 e = script_handler_evas(script);
3883 ErrPrint("Instance has no evas\n");
3884 ret = LB_STATUS_ERROR_INVALID;
3888 script_handler_update_pointer(script, x, y, -1);
3889 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
3891 struct access_cbdata *cbdata;
3893 cbdata = malloc(sizeof(*cbdata));
3895 ret = LB_STATUS_ERROR_MEMORY;
3897 cbdata->inst = instance_ref(inst);
3898 cbdata->status = ret;
3900 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3901 (void)instance_unref(cbdata->inst);
3903 ret = LB_STATUS_ERROR_FAULT;
3905 ret = LB_STATUS_SUCCESS;
3910 ErrPrint("Unsupported package\n");
3911 ret = LB_STATUS_ERROR_INVALID;
3915 result = packet_create_reply(packet, "i", ret);
3917 ErrPrint("Failed to create a reply packet\n");
3922 static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
3924 struct packet *result;
3925 struct client_node *client;
3926 const char *pkgname;
3930 struct inst_info *inst;
3931 const struct pkg_info *pkg;
3935 client = client_find_by_pid(pid);
3937 ErrPrint("Client %d is not exist\n", pid);
3938 ret = LB_STATUS_ERROR_NOT_EXIST;
3942 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3944 ErrPrint("Parameter is not matched\n");
3945 ret = LB_STATUS_ERROR_INVALID;
3949 ret = validate_request(pkgname, id, &inst, &pkg);
3950 if (ret != LB_STATUS_SUCCESS)
3953 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3954 struct buffer_info *buffer;
3955 struct slave_node *slave;
3957 buffer = instance_lb_buffer(inst);
3959 ErrPrint("Instance[%s] has no buffer\n", id);
3960 ret = LB_STATUS_ERROR_FAULT;
3964 slave = package_slave(pkg);
3966 ErrPrint("Slave is not exists\n");
3967 ret = LB_STATUS_ERROR_INVALID;
3971 packet_ref((struct packet *)packet);
3972 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3974 * Enen if it fails to send packet,
3975 * The packet will be unref'd
3976 * So we don't need to check the ret value.
3978 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3979 struct script_info *script;
3982 script = instance_lb_script(inst);
3984 ErrPrint("Instance has no script\n");
3985 ret = LB_STATUS_ERROR_FAULT;
3989 e = script_handler_evas(script);
3991 ErrPrint("Instance has no evas\n");
3992 ret = LB_STATUS_ERROR_INVALID;
3996 script_handler_update_pointer(script, x, y, 0);
3997 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
3999 struct access_cbdata *cbdata;
4001 cbdata = malloc(sizeof(*cbdata));
4003 ret = LB_STATUS_ERROR_MEMORY;
4005 cbdata->inst = instance_ref(inst);
4006 cbdata->status = ret;
4008 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4009 (void)instance_unref(cbdata->inst);
4011 ret = LB_STATUS_ERROR_FAULT;
4013 ret = LB_STATUS_SUCCESS;
4018 ErrPrint("Unsupported package\n");
4019 ret = LB_STATUS_ERROR_INVALID;
4023 result = packet_create_reply(packet, "i", ret);
4025 ErrPrint("Failed to create a reply packet\n");
4030 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
4032 struct packet *result;
4033 struct client_node *client;
4034 const char *pkgname;
4040 struct inst_info *inst;
4041 const struct pkg_info *pkg;
4043 client = client_find_by_pid(pid);
4045 ErrPrint("Client %d is not exists\n", pid);
4046 ret = LB_STATUS_ERROR_NOT_EXIST;
4050 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4052 ErrPrint("Parameter is not matched\n");
4053 ret = LB_STATUS_ERROR_INVALID;
4057 ret = validate_request(pkgname, id, &inst, &pkg);
4058 if (ret != LB_STATUS_SUCCESS)
4061 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4062 struct buffer_info *buffer;
4063 struct slave_node *slave;
4065 buffer = instance_lb_buffer(inst);
4067 ErrPrint("Instance[%s] has no buffer\n", id);
4068 ret = LB_STATUS_ERROR_FAULT;
4072 slave = package_slave(pkg);
4074 ErrPrint("Package[%s] has no slave\n", pkgname);
4075 ret = LB_STATUS_ERROR_INVALID;
4079 packet_ref((struct packet *)packet);
4080 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4081 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4082 struct script_info *script;
4085 script = instance_lb_script(inst);
4087 ErrPrint("Instance has no script\n");
4088 ret = LB_STATUS_ERROR_FAULT;
4092 e = script_handler_evas(script);
4094 ErrPrint("Script has no Evas\n");
4095 ret = LB_STATUS_ERROR_INVALID;
4099 script_handler_update_pointer(script, x, y, -1);
4100 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
4102 struct access_cbdata *cbdata;
4104 cbdata = malloc(sizeof(*cbdata));
4106 ret = LB_STATUS_ERROR_MEMORY;
4108 cbdata->inst = instance_ref(inst);
4109 cbdata->status = ret;
4111 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4112 (void)instance_unref(cbdata->inst);
4114 ret = LB_STATUS_ERROR_FAULT;
4116 ret = LB_STATUS_SUCCESS;
4121 ErrPrint("Unsupported package\n");
4122 ret = LB_STATUS_ERROR_INVALID;
4126 result = packet_create_reply(packet, "i", ret);
4128 ErrPrint("Failed to create a reply packet\n");
4133 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
4135 struct client_node *client;
4136 const char *pkgname;
4142 struct inst_info *inst;
4143 const struct pkg_info *pkg;
4145 client = client_find_by_pid(pid);
4147 ErrPrint("Client %d is not exists\n", pid);
4148 ret = LB_STATUS_ERROR_NOT_EXIST;
4152 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4154 ErrPrint("Parameter is not matched\n");
4155 ret = LB_STATUS_ERROR_INVALID;
4159 ret = validate_request(pkgname, id, &inst, &pkg);
4160 if (ret != LB_STATUS_SUCCESS)
4163 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4164 struct buffer_info *buffer;
4165 struct slave_node *slave;
4167 buffer = instance_lb_buffer(inst);
4169 ErrPrint("Instance[%s] has no buffer\n", id);
4170 ret = LB_STATUS_ERROR_FAULT;
4174 slave = package_slave(pkg);
4176 ErrPrint("Package[%s] has no slave\n", pkgname);
4177 ret = LB_STATUS_ERROR_INVALID;
4181 packet_ref((struct packet *)packet);
4182 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4183 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4184 struct script_info *script;
4187 script = instance_lb_script(inst);
4189 ret = LB_STATUS_ERROR_FAULT;
4193 e = script_handler_evas(script);
4195 ret = LB_STATUS_ERROR_FAULT;
4199 script_handler_update_pointer(script, x, y, -1);
4202 * \TODO: Feed up this KEY_DOWN event
4206 ErrPrint("Unsupported package\n");
4207 ret = LB_STATUS_ERROR_INVALID;
4211 /*! \note No reply packet */
4215 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
4217 struct client_node *client;
4218 const char *pkgname;
4224 struct inst_info *inst;
4225 const struct pkg_info *pkg;
4227 client = client_find_by_pid(pid);
4229 ErrPrint("Client %d is not exists\n", pid);
4230 ret = LB_STATUS_ERROR_NOT_EXIST;
4234 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4236 ErrPrint("Parameter is not matched\n");
4237 ret = LB_STATUS_ERROR_INVALID;
4241 ret = validate_request(pkgname, id, &inst, &pkg);
4242 if (ret != LB_STATUS_SUCCESS)
4245 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4246 struct buffer_info *buffer;
4247 struct slave_node *slave;
4249 buffer = instance_lb_buffer(inst);
4251 ErrPrint("Instance[%s] has no buffer\n", id);
4252 ret = LB_STATUS_ERROR_FAULT;
4256 slave = package_slave(pkg);
4258 ErrPrint("Package[%s] has no slave\n", pkgname);
4259 ret = LB_STATUS_ERROR_INVALID;
4263 packet_ref((struct packet *)packet);
4264 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
4265 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4266 struct script_info *script;
4269 script = instance_lb_script(inst);
4271 ret = LB_STATUS_ERROR_FAULT;
4275 e = script_handler_evas(script);
4277 ret = LB_STATUS_ERROR_FAULT;
4281 script_handler_update_pointer(script, x, y, -1);
4284 * \TODO: Feed up this KEY_UP event
4288 ErrPrint("Unsupported package\n");
4289 ret = LB_STATUS_ERROR_INVALID;
4293 /*! \note No reply packet */
4297 static int release_pixmap_cb(struct client_node *client, void *canvas)
4299 DbgPrint("Forcely unref the \"buffer\"\n");
4300 buffer_handler_pixmap_unref(canvas);
4301 return -1; /* Delete this callback */
4304 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 */
4306 struct packet *result;
4307 const char *pkgname;
4309 struct client_node *client;
4310 struct inst_info *inst;
4314 struct buffer_info *buffer;
4316 client = client_find_by_pid(pid);
4318 ErrPrint("Client %d is not exists\n", pid);
4322 ret = packet_get(packet, "ss", &pkgname, &id);
4324 ErrPrint("Parameter is not matched\n");
4328 ret = validate_request(pkgname, id, &inst, NULL);
4329 if (ret != LB_STATUS_SUCCESS)
4332 buffer = instance_lb_buffer(inst);
4334 struct script_info *script_info;
4335 struct fb_info *fb_info;
4337 script_info = instance_lb_script(inst);
4339 ErrPrint("Unable to get LB buffer: %s\n", id);
4343 fb_info = script_handler_fb(script_info);
4345 ErrPrint("Unable to get fb_info: %s\n", id);
4349 buffer = fb_buffer_info(fb_info);
4351 ErrPrint("Unable to get buffer_info: %s\n", id);
4356 buf_ptr = buffer_handler_pixmap_ref(buffer);
4358 ErrPrint("Failed to ref pixmap\n");
4362 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
4364 ErrPrint("Failed to add a new client deactivate callback\n");
4365 buffer_handler_pixmap_unref(buf_ptr);
4367 pixmap = buffer_handler_pixmap(buffer);
4371 result = packet_create_reply(packet, "i", pixmap);
4373 ErrPrint("Failed to create a reply packet\n");
4378 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
4380 const char *pkgname;
4382 struct client_node *client;
4383 struct inst_info *inst;
4388 client = client_find_by_pid(pid);
4390 ErrPrint("Client %d is not exists\n", pid);
4394 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
4396 ErrPrint("Parameter is not matched\n");
4400 ret = validate_request(pkgname, id, &inst, NULL);
4401 if (ret != LB_STATUS_SUCCESS)
4404 buf_ptr = buffer_handler_pixmap_find(pixmap);
4406 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
4410 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
4411 buffer_handler_pixmap_unref(buf_ptr);
4414 /*! \note No reply packet */
4418 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 */
4420 struct packet *result;
4421 const char *pkgname;
4423 struct client_node *client;
4424 struct inst_info *inst;
4428 struct buffer_info *buffer;
4430 client = client_find_by_pid(pid);
4432 ErrPrint("Client %d is not exists\n", pid);
4436 ret = packet_get(packet, "ss", &pkgname, &id);
4438 ErrPrint("Parameter is not matched\n");
4442 ret = validate_request(pkgname, id, &inst, NULL);
4443 if (ret != LB_STATUS_SUCCESS)
4446 buffer = instance_pd_buffer(inst);
4448 struct script_info *script_info;
4449 struct fb_info *fb_info;
4451 script_info = instance_pd_script(inst);
4453 ErrPrint("Unable to get LB buffer: %s\n", id);
4457 fb_info = script_handler_fb(script_info);
4459 ErrPrint("Unable to get fb_info: %s\n", id);
4463 buffer = fb_buffer_info(fb_info);
4465 ErrPrint("Unable to get buffer_info: %s\n", id);
4470 buf_ptr = buffer_handler_pixmap_ref(buffer);
4472 ErrPrint("Failed to ref pixmap\n");
4476 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
4478 buffer_handler_pixmap_unref(buf_ptr);
4480 pixmap = buffer_handler_pixmap(buffer);
4482 result = packet_create_reply(packet, "i", pixmap);
4484 ErrPrint("Failed to create a reply packet\n");
4489 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
4491 const char *pkgname;
4493 struct client_node *client;
4498 client = client_find_by_pid(pid);
4500 ErrPrint("Client %d is not exists\n", pid);
4504 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
4506 ErrPrint("Parameter is not matched\n");
4510 ret = validate_request(pkgname, id, NULL, NULL);
4511 if (ret != LB_STATUS_SUCCESS)
4514 buf_ptr = buffer_handler_pixmap_find(pixmap);
4516 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
4520 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
4521 buffer_handler_pixmap_unref(buf_ptr);
4524 /*! \note No reply packet */
4528 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
4530 struct client_node *client;
4531 struct packet *result;
4532 const char *pkgname;
4536 struct inst_info *inst;
4538 client = client_find_by_pid(pid);
4540 ErrPrint("Client %d is not exists\n", pid);
4541 ret = LB_STATUS_ERROR_NOT_EXIST;
4546 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
4548 ErrPrint("Parameter is not matched\n");
4549 ret = LB_STATUS_ERROR_INVALID;
4554 ret = validate_request(pkgname, id, &inst, NULL);
4555 if (ret == LB_STATUS_SUCCESS)
4556 ret = instance_set_pinup(inst, pinup);
4559 result = packet_create_reply(packet, "i", ret);
4561 ErrPrint("Failed to create a packet\n");
4566 static Eina_Bool lazy_pd_created_cb(void *data)
4568 if (!!instance_del_data(data, "lazy,pd,open")) {
4570 * After unref instance first,
4571 * if the instance is not destroyed, try to notify the created PD event to the client.
4573 if (instance_unref(data)) {
4575 ret = instance_client_pd_created(data, LB_STATUS_SUCCESS);
4576 DbgPrint("Send PD Create event (%d) to client\n", ret);
4580 return ECORE_CALLBACK_CANCEL;
4583 static Eina_Bool lazy_pd_destroyed_cb(void *data)
4585 if (!!instance_del_data(data, "lazy,pd,close")) {
4586 if (instance_unref(data)) {
4588 ret = instance_client_pd_destroyed(data, LB_STATUS_SUCCESS);
4589 DbgPrint("Send PD Destroy event (%d) to client\n", ret);
4593 return ECORE_CALLBACK_CANCEL;
4596 static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
4598 struct client_node *client;
4599 struct inst_info *inst;
4600 const struct pkg_info *pkg;
4601 const char *pkgname;
4607 client = client_find_by_pid(pid);
4609 ErrPrint("Client %d is not exists\n", pid);
4610 ret = LB_STATUS_ERROR_NOT_EXIST;
4614 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
4616 ErrPrint("Parameter is not correct\n");
4617 ret = LB_STATUS_ERROR_INVALID;
4621 ret = validate_request(pkgname, id, &inst, &pkg);
4622 if (ret != LB_STATUS_SUCCESS)
4625 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
4626 instance_slave_set_pd_pos(inst, x, y);
4627 ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
4628 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
4632 instance_slave_set_pd_pos(inst, x, y);
4633 ix = x * instance_pd_width(inst);
4634 iy = y * instance_pd_height(inst);
4635 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
4636 ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
4638 ErrPrint("Invalid PD type\n");
4639 ret = LB_STATUS_ERROR_INVALID;
4642 DbgPrint("Update PD position: %d\n", ret);
4646 static Eina_Bool pd_open_monitor_cb(void *data)
4649 struct inst_info *inst = data;
4651 ret = instance_slave_close_pd(inst, instance_pd_owner(inst));
4652 ret = instance_client_pd_created(inst, LB_STATUS_ERROR_TIMEOUT);
4653 (void)instance_del_data(inst, "pd,open,monitor");
4654 (void)instance_unref(inst);
4655 ErrPrint("PD Open request is timed-out (%lf), ret: %d\n", PD_REQUEST_TIMEOUT, ret);
4656 return ECORE_CALLBACK_CANCEL;
4659 static Eina_Bool pd_close_monitor_cb(void *data)
4663 ret = instance_client_pd_destroyed(data, LB_STATUS_ERROR_TIMEOUT);
4664 (void)instance_del_data(data, "pd,close,monitor");
4665 (void)instance_unref(data);
4666 ErrPrint("PD Close request is not processed in %lf seconds (%d)\n", PD_REQUEST_TIMEOUT, ret);
4667 return ECORE_CALLBACK_CANCEL;
4670 static Eina_Bool pd_resize_monitor_cb(void *data)
4673 struct inst_info *inst = data;
4675 ret = instance_slave_close_pd(inst, instance_pd_owner(inst));
4676 ret = instance_client_pd_destroyed(inst, LB_STATUS_ERROR_TIMEOUT);
4677 (void)instance_del_data(inst, "pd,resize,monitor");
4678 (void)instance_unref(inst);
4679 ErrPrint("PD Resize request is not processed in %lf seconds (%d)\n", PD_REQUEST_TIMEOUT, ret);
4680 return ECORE_CALLBACK_CANCEL;
4683 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
4685 struct client_node *client;
4686 struct packet *result;
4687 const char *pkgname;
4690 struct inst_info *inst;
4694 DbgPrint("PERF_DBOX\n");
4696 client = client_find_by_pid(pid);
4698 ErrPrint("Client %d is not exists\n", pid);
4699 ret = LB_STATUS_ERROR_NOT_EXIST;
4703 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
4705 ErrPrint("Parameter is not matched\n");
4706 ret = LB_STATUS_ERROR_INVALID;
4710 ret = validate_request(pkgname, id, &inst, NULL);
4711 if (ret != LB_STATUS_SUCCESS)
4714 if (instance_pd_owner(inst)) {
4715 ErrPrint("PD is already owned\n");
4716 ret = LB_STATUS_ERROR_ALREADY;
4717 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4718 lazy_pd_destroyed_cb(inst);
4720 if (instance_get_data(inst, "pd,open,monitor")) {
4721 DbgPrint("PD Open request is already processed\n");
4722 ret = LB_STATUS_ERROR_ALREADY;
4726 if (instance_get_data(inst, "pd,close,monitor")) {
4727 DbgPrint("PD Close request is already in process\n");
4728 ret = LB_STATUS_ERROR_BUSY;
4732 if (instance_get_data(inst, "pd,resize,monitor")) {
4733 DbgPrint("PD resize request is already in process\n");
4734 ret = LB_STATUS_ERROR_BUSY;
4738 instance_slave_set_pd_pos(inst, x, y);
4741 * Send request to the slave.
4742 * The SLAVE must has to repsonse this via "release_buffer" method.
4744 ret = instance_slave_open_pd(inst, client);
4745 if (ret == LB_STATUS_SUCCESS) {
4746 ret = instance_signal_emit(inst, "pd,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
4747 if (ret != LB_STATUS_SUCCESS) {
4750 tmp_ret = instance_slave_close_pd(inst, client);
4751 ErrPrint("Unable to send script event for openning PD [%s], %d\n", pkgname, tmp_ret);
4753 Ecore_Timer *pd_monitor;
4755 pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_open_monitor_cb, instance_ref(inst));
4757 (void)instance_unref(inst);
4758 ErrPrint("Failed to create a timer for PD Open monitor\n");
4760 (void)instance_set_data(inst, "pd,open,monitor", pd_monitor);
4764 ErrPrint("Unable to send request for openning PD [%s]\n", pkgname);
4769 * PD craeted event will be send by the acquire_buffer function.
4770 * Because the slave will make request the acquire_buffer to
4773 * instance_client_pd_created(inst);
4775 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4779 lazy_pd_destroyed_cb(inst);
4783 * ret value should be cared but in this case,
4784 * we ignore this for this moment, so we have to handle this error later.
4786 * if ret is less than 0, the slave has some problem.
4787 * but the script mode doesn't need slave for rendering default view of PD
4788 * so we can hanle it later.
4790 instance_slave_set_pd_pos(inst, x, y);
4791 ix = x * instance_pd_width(inst);
4792 iy = y * instance_pd_height(inst);
4794 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
4796 ret = instance_slave_open_pd(inst, client);
4797 if (ret == LB_STATUS_SUCCESS) {
4798 ret = script_handler_load(instance_pd_script(inst), 1);
4802 * Send the PD created event to the clients,
4804 if (ret == LB_STATUS_SUCCESS) {
4809 * But the created event has to be send afte return
4810 * from this function or the viewer couldn't care
4811 * the event correctly.
4813 inst = instance_ref(inst); /* To guarantee the inst */
4817 * At here, we don't need to rememeber the timer object.
4818 * Even if the timer callback is called, after the instance is destroyed.
4819 * lazy_pd_created_cb will decrease the instance refcnt first.
4820 * At that time, if the instance is released, the timer callback will do nothing.
4823 * I change my mind. There is no requirements to keep the timer handler.
4824 * But I just add it to the tagged-data of the instance.
4825 * Just reserve for future-use.
4827 timer = ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst);
4829 struct inst_info *tmp_inst;
4831 tmp_inst = instance_unref(inst);
4832 ErrPrint("Instance: %p (%s)\n", tmp_inst, pkgname);
4834 ret = script_handler_unload(instance_pd_script(inst), 1);
4835 ErrPrint("Unload script: %d\n", ret);
4837 ret = instance_slave_close_pd(inst, client);
4838 ErrPrint("Close PD %d\n", ret);
4840 ret = LB_STATUS_ERROR_FAULT;
4842 (void)instance_set_data(inst, "lazy,pd,open", timer);
4846 tmp_ret = instance_slave_close_pd(inst, client);
4847 ErrPrint("Unable to load script: %d, (close: %d)\n", ret, tmp_ret);
4850 ErrPrint("Unable open PD(%s): %d\n", pkgname, ret);
4853 ErrPrint("Invalid PD TYPE\n");
4854 ret = LB_STATUS_ERROR_INVALID;
4858 result = packet_create_reply(packet, "i", ret);
4860 ErrPrint("Failed to create a packet\n");
4865 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
4867 struct client_node *client;
4868 struct packet *result;
4869 const char *pkgname;
4872 struct inst_info *inst;
4873 const struct pkg_info *pkg;
4874 Ecore_Timer *pd_monitor;
4876 DbgPrint("PERF_DBOX\n");
4878 client = client_find_by_pid(pid);
4880 ErrPrint("Client %d is not exists\n", pid);
4881 ret = LB_STATUS_ERROR_NOT_EXIST;
4885 ret = packet_get(packet, "ss", &pkgname, &id);
4887 ErrPrint("Parameter is not matched\n");
4888 ret = LB_STATUS_ERROR_INVALID;
4892 ret = validate_request(pkgname, id, &inst, &pkg);
4893 if (ret != LB_STATUS_SUCCESS)
4896 if (instance_pd_owner(inst) != client) {
4897 if (instance_pd_owner(inst) == NULL) {
4898 ErrPrint("PD looks already closed\n");
4899 ret = LB_STATUS_ERROR_ALREADY;
4901 ErrPrint("PD owner mimatched\n");
4902 ret = LB_STATUS_ERROR_PERMISSION;
4904 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
4905 int resize_aborted = 0;
4907 pd_monitor = instance_del_data(inst, "pd,open,monitor");
4909 ErrPrint("PD Open request is found. cancel it [%s]\n", pkgname);
4913 * We should return negative value
4914 * Or we have to send "destroyed" event to the client.
4915 * If we didn't send destroyed event after return SUCCESS from here,
4916 * The client will permanently waiting destroyed event.
4917 * Because they understand that the destroy request is successfully processed.
4919 ret = LB_STATUS_ERROR_CANCEL;
4920 ret = instance_client_pd_created(inst, ret);
4922 ErrPrint("PD client create event: %d\n", ret);
4924 ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
4926 ErrPrint("PD client destroy event: %d\n", ret);
4928 ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
4930 ErrPrint("PD close signal emit failed: %d\n", ret);
4932 ret = instance_slave_close_pd(inst, client);
4934 ErrPrint("PD close request failed: %d\n", ret);
4936 ecore_timer_del(pd_monitor);
4937 (void)instance_unref(inst);
4941 if (instance_get_data(inst, "lazy,pd,close") || instance_get_data(inst, "pd,close,monitor")) {
4942 ret = LB_STATUS_ERROR_ALREADY;
4946 pd_monitor = instance_del_data(inst, "pd,resize,monitor");
4948 ErrPrint("PD Resize request is found. clear it [%s]\n", pkgname);
4949 ecore_timer_del(pd_monitor);
4951 inst = instance_unref(inst);
4958 ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
4960 ErrPrint("PD close signal emit failed: %d\n", ret);
4962 ret = instance_slave_close_pd(inst, client);
4964 ErrPrint("PD close request failed: %d\n", ret);
4965 } else if (resize_aborted) {
4966 pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
4968 ErrPrint("Failed to create a timer: %s\n", pkgname);
4969 (void)instance_unref(inst);
4971 (void)instance_set_data(inst, "lazy,pd,close", pd_monitor);
4974 pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_close_monitor_cb, instance_ref(inst));
4976 (void)instance_unref(inst);
4977 ErrPrint("Failed to add pd close monitor\n");
4979 (void)instance_set_data(inst, "pd,close,monitor", pd_monitor);
4984 * release_buffer will be called by the slave after this.
4985 * Then it will send the "pd_destroyed" event to the client
4987 * instance_client_pd_destroyed(inst);
4989 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
4990 lazy_pd_created_cb(inst);
4992 ret = script_handler_unload(instance_pd_script(inst), 1);
4994 ErrPrint("Unable to unload the script: %s, %d\n", pkgname, ret);
4998 * Send request to the slave.
4999 * The SLAVE must has to repsonse this via "release_buffer" method.
5001 ret = instance_slave_close_pd(inst, client);
5003 ErrPrint("Unable to close the PD: %s, %d\n", pkgname, ret);
5007 * Send the destroyed PD event to the client
5009 if (ret == LB_STATUS_SUCCESS) {
5013 * I change my mind. There is no requirements to keep the timer handler.
5014 * But I just add it to the tagged-data of the instance.
5015 * Just reserve for future-use.
5017 pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
5019 ErrPrint("Failed to create a timer: %s\n", pkgname);
5020 (void)instance_unref(inst);
5022 (void)instance_set_data(inst, "lazy,pd,close", pd_monitor);
5026 ErrPrint("Invalid PD TYPE\n");
5027 ret = LB_STATUS_ERROR_INVALID;
5031 result = packet_create_reply(packet, "i", ret);
5033 ErrPrint("Failed to create a packet\n");
5038 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
5040 struct client_node *client;
5041 struct packet *result;
5042 const char *pkgname;
5044 struct pkg_info *info;
5046 client = client_find_by_pid(pid);
5048 ErrPrint("Client %d is not exists\n", pid);
5049 ret = LB_STATUS_ERROR_NOT_EXIST;
5054 ret = packet_get(packet, "s", &pkgname);
5056 ErrPrint("Parameter is not matched\n");
5057 ret = LB_STATUS_ERROR_INVALID;
5062 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
5066 * Validate the livebox package name.
5068 if (!package_is_lb_pkgname(pkgname)) {
5069 ErrPrint("%s is not a valid livebox package\n", pkgname);
5071 ret = LB_STATUS_ERROR_INVALID;
5075 info = package_find(pkgname);
5077 ret = LB_STATUS_ERROR_NOT_EXIST;
5079 ret = package_clear_fault(info);
5082 result = packet_create_reply(packet, "is", ret, pkgname);
5084 ErrPrint("Failed to create a packet\n");
5089 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
5091 const char *cluster;
5092 const char *category;
5093 struct client_node *client;
5096 client = client_find_by_pid(pid);
5098 ErrPrint("Client %d is not exists\n", pid);
5099 ret = LB_STATUS_ERROR_NOT_EXIST;
5103 ret = packet_get(packet, "ss", &cluster, &category);
5105 ErrPrint("Invalid argument\n");
5106 ret = LB_STATUS_ERROR_INVALID;
5110 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5111 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5112 ErrPrint("Invalid cluster name\n");
5118 * SUBSCRIBE cluster & sub-cluster for a client.
5120 ret = client_subscribe(client, cluster, category);
5122 package_alter_instances_to_client(client, ALTER_CREATE);
5125 /*! \note No reply packet */
5129 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
5131 const char *cluster;
5132 struct client_node *client;
5133 struct packet *result;
5136 client = client_find_by_pid(pid);
5138 ErrPrint("Client %d is not exists\n", pid);
5139 ret = LB_STATUS_ERROR_NOT_EXIST;
5143 ret = packet_get(packet, "s", &cluster);
5145 ErrPrint("Invalid parameters\n");
5146 ret = LB_STATUS_ERROR_INVALID;
5150 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
5152 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5153 ErrPrint("Invalid cluster: %s\n", cluster);
5154 ret = LB_STATUS_ERROR_INVALID;
5161 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
5164 result = packet_create_reply(packet, "i", ret);
5166 ErrPrint("Failed to create a packet\n");
5170 static inline int update_pkg_cb(struct category *category, const char *pkgname)
5175 c_name = group_cluster_name_by_category(category);
5176 s_name = group_category_name(category);
5178 if (!c_name || !s_name || !pkgname) {
5179 ErrPrint("Name is not valid\n");
5180 return EXIT_FAILURE;
5183 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
5184 slave_rpc_request_update(pkgname, "", c_name, s_name);
5186 /* Just try to create a new package */
5187 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
5189 struct inst_info *inst;
5191 timestamp = util_timestamp();
5194 * Don't need to check the subscribed clients.
5195 * Because this callback is called by the requests of clients.
5196 * It means. some clients wants to handle this instances ;)
5198 inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DEFAULT_PERIOD, 0, 0);
5200 ErrPrint("Failed to create a new instance\n");
5202 ErrPrint("Not enough space\n");
5204 return EXIT_SUCCESS;
5207 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
5209 struct inst_info *inst;
5210 struct client_node *client;
5211 const char *pkgname;
5215 client = client_find_by_pid(pid);
5217 ErrPrint("Cilent %d is not exists\n", pid);
5221 ret = packet_get(packet, "ss", &pkgname, &id);
5223 ErrPrint("Invalid argument\n");
5227 ret = validate_request(pkgname, id, &inst, NULL);
5228 if (ret != LB_STATUS_SUCCESS)
5231 if (instance_client(inst) != client) {
5233 ErrPrint("Insufficient permissions [%s] - %d\n", pkgname, pid);
5235 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
5239 /*! \note No reply packet */
5243 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
5245 const char *cluster_id;
5246 const char *category_id;
5247 struct client_node *client;
5249 struct cluster *cluster;
5250 struct category *category;
5251 struct context_info *info;
5252 Eina_List *info_list;
5255 client = client_find_by_pid(pid);
5257 ErrPrint("Cilent %d is not exists\n", pid);
5261 ret = packet_get(packet, "ss", &cluster_id, &category_id);
5263 ErrPrint("Invalid parameter\n");
5267 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
5269 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
5270 ErrPrint("Invalid cluster name: %s\n", cluster_id);
5274 cluster = group_find_cluster(cluster_id);
5276 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
5280 category = group_find_category(cluster, category_id);
5282 ErrPrint("Category [%s] is not registered\n", category_id);
5286 info_list = group_context_info_list(category);
5287 EINA_LIST_FOREACH(info_list, l, info) {
5288 update_pkg_cb(category, group_pkgname_from_context_info(info));
5292 /*! \note No reply packet */
5296 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
5298 const char *cluster;
5299 const char *category;
5300 struct client_node *client;
5301 struct packet *result;
5304 client = client_find_by_pid(pid);
5306 ErrPrint("Client %d is not exists\n", pid);
5307 ret = LB_STATUS_ERROR_NOT_EXIST;
5311 ret = packet_get(packet, "ss", &cluster, &category);
5313 ErrPrint("Invalid paramenters\n");
5314 ret = LB_STATUS_ERROR_INVALID;
5318 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5319 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5320 ErrPrint("Invalid cluster: %s\n", cluster);
5321 ret = LB_STATUS_ERROR_INVALID;
5328 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
5331 result = packet_create_reply(packet, "i", ret);
5333 ErrPrint("Failed to create a packet\n");
5337 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
5339 const char *cluster;
5340 const char *category;
5341 struct client_node *client;
5344 client = client_find_by_pid(pid);
5346 ErrPrint("Client %d is not exists\n", pid);
5347 ret = LB_STATUS_ERROR_NOT_EXIST;
5351 ret = packet_get(packet, "ss", &cluster, &category);
5353 ErrPrint("Invalid argument\n");
5354 ret = LB_STATUS_ERROR_INVALID;
5358 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
5360 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
5361 ErrPrint("Invalid cluster name: %s\n", cluster);
5367 * UNSUBSCRIBE cluster & sub-cluster for a client.
5369 ret = client_unsubscribe(client, cluster, category);
5371 package_alter_instances_to_client(client, ALTER_DESTROY);
5374 /*! \note No reply packet */
5378 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
5380 struct slave_node *slave;
5381 const char *slavename;
5384 ret = packet_get(packet, "s", &slavename);
5386 ErrPrint("Parameter is not matched\n");
5390 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
5392 slave = slave_find_by_name(slavename);
5394 if (!slave) /* Try again to find a slave using pid */
5395 slave = slave_find_by_pid(pid);
5399 char pkgname[pathconf("/", _PC_PATH_MAX)];
5402 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
5403 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
5404 slave = slave_find_by_name(slavename);
5405 pkgname[0] = '\0'; /* Reset the pkgname */
5407 slave = slave_find_by_pkgname(pkgname);
5411 abi = abi_find_by_pkgname(pkgname);
5414 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
5417 slave = slave_create(slavename, 1, abi, pkgname, 0);
5419 ErrPrint("Failed to create a new slave for %s\n", slavename);
5423 DbgPrint("New slave is created (net: 0)\n");
5425 DbgPrint("Registered slave is replaced with this new one\n");
5426 abi = slave_abi(slave);
5429 slave_set_pid(slave, pid);
5430 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
5432 ErrPrint("Slave[%d, %s] is not exists\n", pid, slavename);
5436 if (slave_pid(slave) != pid) {
5437 if (slave_pid(slave) > 0) {
5438 CRITICAL_LOG("Slave(%s) is already assigned to %d\n", slave_name(slave), slave_pid(slave));
5440 ret = aul_terminate_pid(pid);
5441 CRITICAL_LOG("Terminate %d (ret: %d)\n", pid, ret);
5445 CRITICAL_LOG("PID of slave(%s) is updated (%d -> %d)\n", slave_name(slave), slave_pid(slave), pid);
5446 slave_set_pid(slave, pid);
5452 * After updating handle,
5453 * slave activated callback will be called.
5455 slave_rpc_update_handle(slave, handle);
5461 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
5463 struct slave_node *slave;
5464 const char *slavename;
5467 slave = slave_find_by_pid(pid);
5469 ErrPrint("Slave %d is not exists\n", pid);
5473 ret = packet_get(packet, "s", &slavename);
5475 ErrPrint("Parameter is not matched\n");
5477 slave_rpc_ping(slave);
5483 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
5485 struct slave_node *slave;
5486 struct inst_info *inst;
5487 const char *pkgname;
5492 slave = slave_find_by_pid(pid);
5494 ErrPrint("Slave %d is not exists\n", pid);
5498 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5500 ErrPrint("Parameter is not matched\n");
5504 ret = fault_info_set(slave, pkgname, id, func);
5505 DbgPrint("Slave Faulted: %s (%d)\n", slave_name(slave), ret);
5507 inst = package_find_instance_by_id(pkgname, id);
5509 DbgPrint("There is a no such instance(%s)\n", id);
5510 } else if (instance_state(inst) == INST_DESTROYED) {
5511 ErrPrint("Instance(%s) is already destroyed\n", id);
5513 ret = instance_destroy(inst);
5520 static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
5522 struct slave_node *slave;
5523 struct inst_info *inst;
5524 const struct pkg_info *pkg;
5525 const char *pkgname;
5528 const char *content;
5532 slave = slave_find_by_pid(pid);
5534 ErrPrint("Slave %d is not exists\n", pid);
5538 ret = packet_get(packet, "ssdss", &pkgname, &id, &priority, &content, &title);
5540 ErrPrint("Invalid parameters\n");
5544 ret = validate_request(pkgname, id, &inst, &pkg);
5545 if (ret != LB_STATUS_SUCCESS)
5548 if (instance_state(inst) == INST_DESTROYED) {
5549 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5553 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5554 ret = instance_lb_update_begin(inst, priority, content, title);
5555 if (ret == LB_STATUS_SUCCESS)
5556 slave_freeze_ttl(slave);
5558 ErrPrint("Invalid request[%s]\n", id);
5565 static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct packet *packet)
5567 struct slave_node *slave;
5568 struct inst_info *inst;
5569 const struct pkg_info *pkg;
5570 const char *pkgname;
5574 slave = slave_find_by_pid(pid);
5576 ErrPrint("Slave %d is not exists\n", pid);
5580 ret = packet_get(packet, "ss", &pkgname, &id);
5582 ErrPrint("Invalid parameters\n");
5586 ret = validate_request(pkgname, id, &inst, &pkg);
5587 if (ret != LB_STATUS_SUCCESS)
5590 if (instance_state(inst) == INST_DESTROYED) {
5591 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5595 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5596 ret = instance_lb_update_end(inst);
5597 if (ret == LB_STATUS_SUCCESS)
5598 slave_thaw_ttl(slave);
5600 ErrPrint("Invalid request[%s]\n", id);
5607 static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
5609 struct slave_node *slave;
5610 const struct pkg_info *pkg;
5611 struct inst_info *inst;
5612 const char *pkgname;
5616 slave = slave_find_by_pid(pid);
5618 ErrPrint("Slave %d is not exists\n", pid);
5622 ret = packet_get(packet, "ss", &pkgname, &id);
5624 ErrPrint("Invalid parameters\n");
5628 ret = validate_request(pkgname, id, &inst, &pkg);
5629 if (ret != LB_STATUS_SUCCESS)
5632 if (instance_state(inst) == INST_DESTROYED) {
5633 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5637 if (package_pd_type(pkg) == PD_TYPE_BUFFER)
5638 (void)instance_pd_update_begin(inst);
5640 ErrPrint("Invalid request[%s]\n", id);
5646 static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
5648 struct slave_node *slave;
5649 struct inst_info *inst;
5650 const char *pkgname;
5655 slave = slave_find_by_pid(pid);
5657 ErrPrint("Slave %d is not exists\n", pid);
5661 ret = packet_get(packet, "ssi", &pkgname, &id, &status);
5663 ErrPrint("Invalid parameters\n");
5667 ret = validate_request(pkgname, id, &inst, NULL);
5668 if (ret == LB_STATUS_SUCCESS) {
5669 if (instance_state(inst) == INST_DESTROYED)
5670 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5672 (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
5679 static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
5681 struct slave_node *slave;
5682 const struct pkg_info *pkg;
5683 struct inst_info *inst;
5684 const char *pkgname;
5688 slave = slave_find_by_pid(pid);
5690 ErrPrint("Slave %d is not exists\n", pid);
5694 ret = packet_get(packet, "ss", &pkgname, &id);
5696 ErrPrint("Invalid parameters\n");
5700 ret = validate_request(pkgname, id, &inst, &pkg);
5701 if (ret != LB_STATUS_SUCCESS)
5704 if (instance_state(inst) == INST_DESTROYED) {
5705 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5709 if (package_pd_type(pkg) == PD_TYPE_BUFFER)
5710 (void)instance_pd_update_end(inst);
5712 ErrPrint("Invalid request[%s]\n", id);
5718 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
5720 struct slave_node *slave;
5721 const char *pkgname;
5726 slave = slave_find_by_pid(pid);
5728 ErrPrint("Slave %d is not exists\n", pid);
5732 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5734 ErrPrint("Parameter is not matched\n");
5738 ret = fault_func_call(slave, pkgname, id, func);
5739 slave_give_more_ttl(slave);
5745 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
5747 struct slave_node *slave;
5748 const char *pkgname;
5753 slave = slave_find_by_pid(pid);
5755 ErrPrint("Slave %d is not exists\n", pid);
5759 ret = packet_get(packet, "sss", &pkgname, &id, &func);
5761 ErrPrint("Parameter is not matched\n");
5765 ret = fault_func_ret(slave, pkgname, id, func);
5766 slave_give_more_ttl(slave);
5772 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
5774 struct slave_node *slave;
5775 const char *pkgname;
5777 const char *content_info;
5783 struct inst_info *inst;
5785 slave = slave_find_by_pid(pid);
5787 ErrPrint("Slave %d is not exists\n", pid);
5791 ret = packet_get(packet, "ssiidss", &pkgname, &id,
5793 &content_info, &title);
5795 ErrPrint("Parameter is not matched\n");
5799 ret = validate_request(pkgname, id, &inst, NULL);
5800 if (ret == LB_STATUS_SUCCESS) {
5803 if (instance_state(inst) == INST_DESTROYED) {
5804 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5808 instance_set_lb_info(inst, priority, content_info, title);
5810 switch (package_lb_type(instance_package(inst))) {
5811 case LB_TYPE_SCRIPT:
5812 script_handler_resize(instance_lb_script(inst), w, h);
5813 filename = util_get_file_kept_in_safe(id);
5815 (void)script_handler_parse_desc(pkgname, id, filename, 0);
5818 (void)script_handler_parse_desc(pkgname, id, util_uri_to_path(id), 0);
5821 case LB_TYPE_BUFFER:
5825 * text format (inst)
5827 instance_set_lb_size(inst, w, h);
5828 instance_lb_updated_by_instance(inst);
5832 slave_give_more_ttl(slave);
5839 static struct packet *slave_hold_scroll(pid_t pid, int handle, const struct packet *packet)
5841 struct slave_node *slave;
5842 struct inst_info *inst;
5843 const char *pkgname;
5848 slave = slave_find_by_pid(pid);
5850 ErrPrint("Slave %d is not exists\n", pid);
5854 ret = packet_get(packet, "ssi", &pkgname, &id, &seize);
5856 ErrPrint("Parameter is not matched\n");
5860 ret = validate_request(pkgname, id, &inst, NULL);
5861 if (ret == LB_STATUS_SUCCESS) {
5862 if (instance_state(inst) == INST_DESTROYED)
5863 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5865 (void)instance_hold_scroll(inst, seize);
5872 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
5874 struct slave_node *slave;
5875 const char *pkgname;
5877 const char *descfile;
5879 struct inst_info *inst;
5881 slave = slave_find_by_pid(pid);
5883 ErrPrint("Slave %d is not exists\n", pid);
5887 ret = packet_get(packet, "sss", &pkgname, &id, &descfile);
5889 ErrPrint("Parameter is not matched\n");
5893 ret = validate_request(pkgname, id, &inst, NULL);
5894 if (ret != LB_STATUS_SUCCESS)
5897 if (instance_state(inst) == INST_DESTROYED) {
5898 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5902 switch (package_pd_type(instance_package(inst))) {
5903 case PD_TYPE_SCRIPT:
5904 if (script_handler_is_loaded(instance_pd_script(inst))) {
5905 (void)script_handler_parse_desc(pkgname, id, descfile, 1);
5909 instance_set_pd_size(inst, 0, 0);
5910 case PD_TYPE_BUFFER:
5911 instance_pd_updated(pkgname, id, descfile);
5914 DbgPrint("Ignore updated DESC(%s)\n", pkgname);
5922 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
5924 struct slave_node *slave;
5925 const char *pkgname;
5928 struct inst_info *inst;
5930 slave = slave_find_by_pid(pid);
5932 ErrPrint("Slave %d is not exists\n", pid);
5936 ret = packet_get(packet, "ss", &pkgname, &id);
5938 ErrPrint("Parameter is not matched\n");
5942 ret = validate_request(pkgname, id, &inst, NULL);
5943 if (ret == LB_STATUS_SUCCESS) {
5944 ret = instance_destroyed(inst);
5952 * \note for the BUFFER Type slave
5954 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
5956 enum target_type target;
5957 const char *pkgname;
5962 struct packet *result;
5963 struct slave_node *slave;
5964 struct inst_info *inst;
5965 const struct pkg_info *pkg;
5968 slave = slave_find_by_pid(pid);
5970 ErrPrint("Failed to find a slave\n");
5972 ret = LB_STATUS_ERROR_NOT_EXIST;
5976 ret = packet_get(packet, "issiii", &target, &pkgname, &id, &w, &h, &pixel_size);
5978 ErrPrint("Invalid argument\n");
5980 ret = LB_STATUS_ERROR_INVALID;
5984 ret = validate_request(pkgname, id, &inst, &pkg);
5987 if (ret != LB_STATUS_SUCCESS)
5990 ret = LB_STATUS_ERROR_INVALID;
5992 if (instance_state(inst) == INST_DESTROYED) {
5993 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
5997 if (target == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
5998 struct buffer_info *info;
6000 info = instance_lb_buffer(inst);
6002 if (!instance_create_lb_buffer(inst)) {
6003 ErrPrint("Failed to create a LB buffer\n");
6004 ret = LB_STATUS_ERROR_FAULT;
6008 info = instance_lb_buffer(inst);
6010 ErrPrint("LB buffer is not valid\n");
6013 * ret value should not be changed.
6019 ret = buffer_handler_resize(info, w, h);
6020 ret = buffer_handler_load(info);
6022 instance_set_lb_size(inst, w, h);
6023 instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
6024 id = buffer_handler_id(info);
6026 ErrPrint("Failed to load a buffer(%d)\n", ret);
6028 } else if (target == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
6029 struct buffer_info *info;
6030 Ecore_Timer *pd_monitor;
6034 pd_monitor = instance_del_data(inst, "pd,open,monitor");
6036 pd_monitor = instance_del_data(inst, "pd,resize,monitor");
6037 is_resize = !!pd_monitor;
6042 ecore_timer_del(pd_monitor);
6043 inst = instance_unref(inst);
6045 ErrPrint("Instance refcnt is ZERO: %s\n", pkgname);
6049 info = instance_pd_buffer(inst);
6051 if (!instance_create_pd_buffer(inst)) {
6052 ErrPrint("Failed to create a PD buffer\n");
6053 ret = LB_STATUS_ERROR_FAULT;
6054 instance_client_pd_created(inst, ret);
6058 info = instance_pd_buffer(inst);
6060 ErrPrint("PD buffer is not valid\n");
6063 * ret value should not be changed.
6065 instance_client_pd_created(inst, ret);
6070 ret = buffer_handler_resize(info, w, h);
6071 ret = buffer_handler_load(info);
6073 instance_set_pd_size(inst, w, h);
6074 id = buffer_handler_id(info);
6076 ErrPrint("Failed to load a buffer (%d)\n", ret);
6080 * Send the PD created event to the client
6083 instance_client_pd_created(inst, ret);
6087 result = packet_create_reply(packet, "is", ret, id);
6089 ErrPrint("Failed to create a packet\n");
6094 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
6096 struct slave_node *slave;
6097 struct packet *result;
6098 enum target_type type;
6099 const char *pkgname;
6103 struct inst_info *inst;
6104 const struct pkg_info *pkg;
6107 slave = slave_find_by_pid(pid);
6109 ErrPrint("Failed to find a slave\n");
6110 ret = LB_STATUS_ERROR_NOT_EXIST;
6115 ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
6117 ErrPrint("Invalid argument\n");
6118 ret = LB_STATUS_ERROR_INVALID;
6123 ret = validate_request(pkgname, id, &inst, &pkg);
6125 if (ret != LB_STATUS_SUCCESS)
6128 ret = LB_STATUS_ERROR_INVALID;
6131 * Reset "id", It will be re-used from here
6134 if (instance_state(inst) == INST_DESTROYED) {
6135 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6139 if (type == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
6140 struct buffer_info *info;
6142 info = instance_lb_buffer(inst);
6146 ret = buffer_handler_resize(info, w, h);
6149 * id is resued for newly assigned ID
6151 if (ret == LB_STATUS_SUCCESS) {
6152 id = buffer_handler_id(info);
6153 instance_set_lb_size(inst, w, h);
6154 instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
6156 } else if (type == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
6157 struct buffer_info *info;
6159 info = instance_pd_buffer(inst);
6163 ret = buffer_handler_resize(info, w, h);
6166 * id is resued for newly assigned ID
6168 if (ret == LB_STATUS_SUCCESS) {
6169 id = buffer_handler_id(info);
6170 instance_set_pd_size(inst, w, h);
6175 result = packet_create_reply(packet, "is", ret, id);
6177 ErrPrint("Failed to create a packet\n");
6182 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
6184 enum target_type type;
6185 const char *pkgname;
6187 struct packet *result;
6188 struct slave_node *slave;
6189 struct inst_info *inst;
6190 const struct pkg_info *pkg;
6193 slave = slave_find_by_pid(pid);
6195 ErrPrint("Failed to find a slave\n");
6196 ret = LB_STATUS_ERROR_NOT_EXIST;
6200 if (packet_get(packet, "iss", &type, &pkgname, &id) != 3) {
6201 ErrPrint("Inavlid argument\n");
6202 ret = LB_STATUS_ERROR_INVALID;
6206 ret = validate_request(pkgname, id, &inst, &pkg);
6207 if (ret != LB_STATUS_SUCCESS)
6210 ret = LB_STATUS_ERROR_INVALID;
6212 if (type == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
6213 struct buffer_info *info;
6215 info = instance_lb_buffer(inst);
6216 ret = buffer_handler_unload(info);
6217 } else if (type == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
6218 struct buffer_info *info;
6219 Ecore_Timer *pd_monitor;
6221 pd_monitor = instance_del_data(inst, "pd,close,monitor");
6223 ErrPrint("Slave requests to release a buffer\n");
6226 * In this case just keep going to release buffer,
6227 * Even if a user(client) doesn't wants to destroy the PD.
6229 * If the slave tries to destroy PD buffer, it should be
6230 * released and reported to the client about its status.
6232 * Even if the pd is destroyed by timeout handler,
6233 * instance_client_pd_destroyed function will be ignored
6234 * by pd.need_to_send_close_event flag.
6235 * which will be checked by instance_client_pd_destroyed function.
6240 * provider can try to resize the buffer size.
6241 * in that case, it will release the buffer first.
6242 * Then even though the client doesn't request to close the PD,
6243 * the provider can release it.
6244 * If we send the close event to the client,
6245 * The client will not able to allocate PD again.
6246 * In this case, add the pd,monitor again. from here.
6247 * to wait the re-allocate buffer.
6248 * If the client doesn't request buffer reallocation,
6249 * Treat it as a fault. and close the PD.
6251 info = instance_pd_buffer(inst);
6252 ret = buffer_handler_unload(info);
6254 if (ret == LB_STATUS_SUCCESS) {
6255 pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_resize_monitor_cb, instance_ref(inst));
6257 (void)instance_unref(inst);
6258 ErrPrint("Failed to create a timer for PD Open monitor\n");
6260 (void)instance_set_data(inst, "pd,resize,monitor", pd_monitor);
6264 ecore_timer_del(pd_monitor);
6265 inst = instance_unref(inst);
6267 ErrPrint("Instance is released: %s\n", pkgname);
6268 ret = LB_STATUS_ERROR_FAULT;
6272 info = instance_pd_buffer(inst);
6273 ret = buffer_handler_unload(info);
6277 * Send the PD destroyed event to the client
6279 instance_client_pd_destroyed(inst, ret);
6285 result = packet_create_reply(packet, "i", ret);
6287 ErrPrint("Failed to create a packet\n");
6292 static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
6294 struct inst_info *inst;
6295 struct packet *result;
6296 const char *pkgname;
6301 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
6303 ErrPrint("Invalid packet\n");
6304 ret = LB_STATUS_ERROR_INVALID;
6309 struct pkg_info *pkg;
6311 pkg = package_find(pkgname);
6313 ret = LB_STATUS_ERROR_NOT_EXIST;
6314 } else if (package_is_fault(pkg)) {
6315 ret = LB_STATUS_ERROR_FAULT;
6317 Eina_List *inst_list;
6320 inst_list = package_instance_list(pkg);
6321 EINA_LIST_FOREACH(inst_list, l, inst) {
6322 ret = instance_set_period(inst, period);
6324 ErrPrint("Failed to change the period of %s to (%lf)\n", pkgname, period);
6328 ret = validate_request(pkgname, id, &inst, NULL);
6329 if (ret == LB_STATUS_SUCCESS) {
6330 if (instance_state(inst) == INST_DESTROYED) {
6331 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6332 ret = LB_STATUS_ERROR_INVALID;
6336 ret = instance_set_period(inst, period);
6340 DbgPrint("Change the update period: %s, %lf : %d\n", pkgname, period, ret);
6342 result = packet_create_reply(packet, "i", ret);
6344 ErrPrint("Failed to create a packet\n");
6349 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
6351 Eina_List *inst_list;
6352 struct pkg_info *pkg;
6353 struct packet *result;
6354 const char *pkgname;
6356 const char *cluster;
6357 const char *category;
6361 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
6363 ErrPrint("Invalid Packet\n");
6364 ret = LB_STATUS_ERROR_INVALID;
6368 lb_pkgname = package_lb_pkgname(pkgname);
6370 ErrPrint("Invalid package %s\n", pkgname);
6371 ret = LB_STATUS_ERROR_INVALID;
6375 pkg = package_find(lb_pkgname);
6377 ret = LB_STATUS_ERROR_NOT_EXIST;
6378 DbgFree(lb_pkgname);
6382 if (package_is_fault(pkg)) {
6383 ret = LB_STATUS_ERROR_FAULT;
6384 DbgFree(lb_pkgname);
6388 inst_list = package_instance_list(pkg);
6389 if (!eina_list_count(inst_list)) {
6390 ret = LB_STATUS_ERROR_NOT_EXIST;
6391 DbgFree(lb_pkgname);
6395 if (id && strlen(id)) {
6397 struct inst_info *inst;
6399 ret = LB_STATUS_ERROR_NOT_EXIST;
6400 EINA_LIST_FOREACH(inst_list, l, inst) {
6401 if (!strcmp(instance_id(inst), id)) {
6402 ret = LB_STATUS_SUCCESS;
6407 if (ret == LB_STATUS_ERROR_NOT_EXIST) {
6408 DbgFree(lb_pkgname);
6415 * Validate the update requstor.
6417 slave_rpc_request_update(lb_pkgname, id, cluster, category);
6418 DbgFree(lb_pkgname);
6419 ret = LB_STATUS_SUCCESS;
6422 result = packet_create_reply(packet, "i", ret);
6424 ErrPrint("Failed to create a packet\n");
6429 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
6431 struct liveinfo *info;
6432 struct packet *result;
6434 const char *fifo_name;
6437 DbgPrint("Request arrived from %d\n", pid);
6439 if (packet_get(packet, "d", ×tamp) != 1) {
6440 ErrPrint("Invalid packet\n");
6442 ret = LB_STATUS_ERROR_INVALID;
6446 info = liveinfo_create(pid, handle);
6448 ErrPrint("Failed to create a liveinfo object\n");
6450 ret = LB_STATUS_ERROR_INVALID;
6455 fifo_name = liveinfo_filename(info);
6456 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
6459 result = packet_create_reply(packet, "si", fifo_name, ret);
6461 ErrPrint("Failed to create a result packet\n");
6466 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
6470 struct liveinfo *info;
6471 struct slave_node *slave;
6475 if (packet_get(packet, "d", ×tamp) != 1) {
6476 ErrPrint("Invalid argument\n");
6480 info = liveinfo_find_by_pid(pid);
6482 ErrPrint("Invalid request\n");
6486 liveinfo_open_fifo(info);
6487 fp = liveinfo_fifo(info);
6489 liveinfo_close_fifo(info);
6493 list = (Eina_List *)slave_list();
6494 EINA_LIST_FOREACH(list, l, slave) {
6495 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
6498 slave_pkgname(slave),
6500 slave_is_secured(slave),
6501 slave_refcnt(slave),
6502 slave_fault_count(slave),
6503 slave_state_string(slave),
6504 slave_loaded_instance(slave),
6505 slave_loaded_package(slave),
6510 fprintf(fp, "EOD\n");
6511 liveinfo_close_fifo(info);
6516 static inline const char *visible_state_string(enum livebox_visible_state state)
6523 case LB_HIDE_WITH_PAUSE:
6532 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
6534 const char *pkgname;
6535 struct liveinfo *info;
6536 struct pkg_info *pkg;
6538 Eina_List *inst_list;
6539 struct inst_info *inst;
6542 if (packet_get(packet, "s", &pkgname) != 1) {
6543 ErrPrint("Invalid argument\n");
6547 info = liveinfo_find_by_pid(pid);
6549 ErrPrint("Invalid request\n");
6553 liveinfo_open_fifo(info);
6554 fp = liveinfo_fifo(info);
6556 ErrPrint("Invalid fp\n");
6557 liveinfo_close_fifo(info);
6561 if (!package_is_lb_pkgname(pkgname)) {
6562 ErrPrint("Invalid package name\n");
6566 pkg = package_find(pkgname);
6568 ErrPrint("Package is not exists\n");
6572 inst_list = package_instance_list(pkg);
6573 EINA_LIST_FOREACH(inst_list, l, inst) {
6574 fprintf(fp, "%s %s %s %lf %s %d %d\n",
6576 instance_cluster(inst),
6577 instance_category(inst),
6578 instance_period(inst),
6579 visible_state_string(instance_visible_state(inst)),
6580 instance_lb_width(inst),
6581 instance_lb_height(inst));
6585 fprintf(fp, "EOD\n");
6586 liveinfo_close_fifo(info);
6592 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
6596 Eina_List *inst_list;
6597 struct liveinfo *info;
6598 struct pkg_info *pkg;
6599 struct slave_node *slave;
6601 const char *slavename;
6604 if (packet_get(packet, "d", ×tamp) != 1) {
6605 ErrPrint("Invalid argument\n");
6609 info = liveinfo_find_by_pid(pid);
6611 ErrPrint("Invalid request\n");
6615 liveinfo_open_fifo(info);
6616 fp = liveinfo_fifo(info);
6618 liveinfo_close_fifo(info);
6622 list = (Eina_List *)package_list();
6623 EINA_LIST_FOREACH(list, l, pkg) {
6624 slave = package_slave(pkg);
6627 slavename = slave_name(slave);
6628 pid = slave_pid(slave);
6634 inst_list = (Eina_List *)package_instance_list(pkg);
6635 fprintf(fp, "%d %s %s %s %d %d %d\n",
6637 strlen(slavename) ? slavename : "(none)",
6640 package_refcnt(pkg),
6641 package_fault_count(pkg),
6642 eina_list_count(inst_list)
6646 fprintf(fp, "EOD\n");
6647 liveinfo_close_fifo(info);
6652 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
6657 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
6659 struct liveinfo *info;
6665 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
6666 ErrPrint("Invalid argument\n");
6670 info = liveinfo_find_by_pid(pid);
6672 ErrPrint("Invalid request\n");
6676 liveinfo_open_fifo(info);
6677 fp = liveinfo_fifo(info);
6679 liveinfo_close_fifo(info);
6683 if (!strcmp(cmd, "rmpack")) {
6684 fprintf(fp, "%d\n", ENOSYS);
6685 } else if (!strcmp(cmd, "rminst")) {
6686 struct inst_info *inst;
6687 inst = package_find_instance_by_id(pkgname, id);
6689 fprintf(fp, "%d\n", ENOENT);
6691 (void)instance_destroy(inst);
6692 fprintf(fp, "%d\n", 0);
6696 fprintf(fp, "EOD\n");
6697 liveinfo_close_fifo(info);
6703 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
6705 struct liveinfo *info;
6710 int ret = LB_STATUS_ERROR_INVALID;
6712 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
6713 ErrPrint("Invalid argument\n");
6717 info = liveinfo_find_by_pid(pid);
6719 ErrPrint("Invalid request\n");
6723 if (!strcasecmp(var, "debug")) {
6724 if (!strcasecmp(cmd, "set")) {
6725 g_conf.debug_mode = !strcasecmp(val, "on");
6726 } else if (!strcasecmp(cmd, "get")) {
6728 ret = g_conf.debug_mode;
6729 } else if (!strcasecmp(var, "slave_max_load")) {
6730 if (!strcasecmp(cmd, "set")) {
6731 g_conf.slave_max_load = atoi(val);
6732 } else if (!strcasecmp(cmd, "get")) {
6734 ret = g_conf.slave_max_load;
6737 liveinfo_open_fifo(info);
6738 fp = liveinfo_fifo(info);
6740 liveinfo_close_fifo(info);
6743 fprintf(fp, "%d\nEOD\n", ret);
6744 liveinfo_close_fifo(info);
6750 static struct method s_info_table[] = {
6752 .cmd = "liveinfo_hello",
6753 .handler = liveinfo_hello,
6756 .cmd = "slave_list",
6757 .handler = liveinfo_slave_list,
6761 .handler = liveinfo_pkg_list,
6765 .handler = liveinfo_inst_list,
6768 .cmd = "slave_ctrl",
6769 .handler = liveinfo_slave_ctrl,
6773 .handler = liveinfo_pkg_ctrl,
6776 .cmd = "master_ctrl",
6777 .handler = liveinfo_master_ctrl,
6785 static struct method s_client_table[] = {
6787 .cmd = "pd_mouse_move",
6788 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6791 .cmd = "lb_mouse_move",
6792 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6795 .cmd = "pd_mouse_down",
6796 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6799 .cmd = "pd_mouse_up",
6800 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6803 .cmd = "lb_mouse_down",
6804 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6807 .cmd = "lb_mouse_up",
6808 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6811 .cmd = "pd_mouse_enter",
6812 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6815 .cmd = "pd_mouse_leave",
6816 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
6819 .cmd = "lb_mouse_enter",
6820 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6823 .cmd = "lb_mouse_leave",
6824 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
6827 .cmd = "lb_mouse_set",
6828 .handler = client_lb_mouse_set,
6831 .cmd = "lb_mouse_unset",
6832 .handler = client_lb_mouse_unset,
6835 .cmd = "pd_mouse_set",
6836 .handler = client_pd_mouse_set,
6839 .cmd = "pd_mouse_unset",
6840 .handler = client_pd_mouse_unset,
6843 .cmd = "change,visibility",
6844 .handler = client_change_visibility,
6847 .cmd = "lb_acquire_pixmap",
6848 .handler = client_lb_acquire_pixmap,
6851 .cmd = "lb_release_pixmap",
6852 .handler = client_lb_release_pixmap,
6855 .cmd = "pd_acquire_pixmap",
6856 .handler = client_pd_acquire_pixmap,
6859 .cmd = "pd_release_pixmap",
6860 .handler = client_pd_release_pixmap,
6864 .handler = client_acquire, /*!< pid, ret */
6868 .handler = cilent_release, /*!< pid, ret */
6872 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
6875 .cmd = "text_signal",
6876 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
6880 .handler = client_delete, /* pid, pkgname, filename, ret */
6884 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
6888 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
6891 .cmd = "set_period",
6892 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
6895 .cmd = "change_group",
6896 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
6899 .cmd = "pinup_changed",
6900 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
6904 .handler = client_create_pd, /* pid, pkgname, filename, ret */
6908 .handler = client_pd_move, /* pkgname, id, x, y */
6911 .cmd = "destroy_pd",
6912 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
6915 .cmd = "activate_package",
6916 .handler = client_activate_package, /* pid, pkgname, ret */
6919 .cmd = "subscribe", /* pid, cluster, sub-cluster */
6920 .handler = client_subscribed,
6923 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
6924 .handler = client_unsubscribed,
6927 .cmd = "delete_cluster",
6928 .handler = client_delete_cluster,
6931 .cmd = "delete_category",
6932 .handler = client_delete_category,
6935 .cmd = "refresh_group",
6936 .handler = client_refresh_group,
6940 .handler = client_update,
6944 .cmd = "pd_access_hl",
6945 .handler = client_pd_access_hl,
6948 .cmd = "pd_access_hl_prev",
6949 .handler = client_pd_access_hl_prev,
6952 .cmd = "pd_access_hl_next",
6953 .handler = client_pd_access_hl_next,
6956 .cmd = "pd_access_activate",
6957 .handler = client_pd_access_activate,
6960 .cmd = "pd_access_action_up",
6961 .handler = client_pd_access_action_up,
6964 .cmd = "pd_access_action_down",
6965 .handler = client_pd_access_action_down,
6968 .cmd = "pd_access_unhighlight",
6969 .handler = client_pd_access_unhighlight,
6972 .cmd = "pd_access_scroll_down",
6973 .handler = client_pd_access_scroll_down,
6976 .cmd = "pd_access_scroll_move",
6977 .handler = client_pd_access_scroll_move,
6980 .cmd = "pd_access_scroll_up",
6981 .handler = client_pd_access_scroll_up,
6985 .cmd = "lb_access_hl",
6986 .handler = client_lb_access_hl,
6989 .cmd = "lb_access_hl_prev",
6990 .handler = client_lb_access_hl_prev,
6993 .cmd = "lb_access_hl_next",
6994 .handler = client_lb_access_hl_next,
6997 .cmd = "lb_access_activate",
6998 .handler = client_lb_access_activate,
7001 .cmd = "lb_access_action_up",
7002 .handler = client_lb_access_action_up,
7005 .cmd = "lb_access_action_down",
7006 .handler = client_lb_access_action_down,
7009 .cmd = "lb_access_unhighlight",
7010 .handler = client_lb_access_unhighlight,
7013 .cmd = "lb_access_scroll_down",
7014 .handler = client_lb_access_scroll_down,
7017 .cmd = "lb_access_scroll_move",
7018 .handler = client_lb_access_scroll_move,
7021 .cmd = "lb_access_scroll_up",
7022 .handler = client_lb_access_scroll_up,
7026 .cmd = "lb_key_down",
7027 .handler = client_lb_key_down,
7031 .handler = client_lb_key_up,
7035 .cmd = "pd_key_down",
7036 .handler = client_pd_key_down,
7040 .handler = client_pd_key_up,
7044 .cmd = "client_paused",
7045 .handler = client_pause_request,
7048 .cmd = "client_resumed",
7049 .handler = client_resume_request,
7053 .cmd = "update_mode",
7054 .handler = client_update_mode,
7063 static struct method s_service_table[] = {
7065 .cmd = "service_update",
7066 .handler = service_update,
7069 .cmd = "service_change_period",
7070 .handler = service_change_period,
7078 static struct method s_slave_table[] = {
7081 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
7085 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
7089 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
7092 .cmd = "desc_updated",
7093 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
7097 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
7100 .cmd = "acquire_buffer",
7101 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
7104 .cmd = "resize_buffer",
7105 .handler = slave_resize_buffer,
7108 .cmd = "release_buffer",
7109 .handler = slave_release_buffer, /* slave_name, id - ret */
7113 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
7117 .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
7121 .cmd = "lb_update_begin",
7122 .handler = slave_lb_update_begin,
7125 .cmd = "lb_update_end",
7126 .handler = slave_lb_update_end,
7129 .cmd = "pd_update_begin",
7130 .handler = slave_pd_update_begin,
7133 .cmd = "pd_update_end",
7134 .handler = slave_pd_update_end,
7138 .cmd = "access_status",
7139 .handler = slave_access_status,
7144 .handler = slave_hello, /* slave_name, ret */
7148 .handler = slave_ping, /* slave_name, ret */
7157 HAPI int server_init(void)
7159 com_core_packet_use_thread(COM_CORE_THREAD);
7161 if (unlink(INFO_SOCKET) < 0)
7162 ErrPrint("info socket: %s\n", strerror(errno));
7164 if (unlink(SLAVE_SOCKET) < 0)
7165 ErrPrint("slave socket: %s\n", strerror(errno));
7167 if (unlink(CLIENT_SOCKET) < 0)
7168 ErrPrint("client socket: %s\n", strerror(errno));
7170 if (unlink(SERVICE_SOCKET) < 0)
7171 ErrPrint("service socket: %s\n", strerror(errno));
7173 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
7174 if (s_info.info_fd < 0)
7175 ErrPrint("Failed to create a info socket\n");
7177 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
7178 if (s_info.slave_fd < 0)
7179 ErrPrint("Failed to create a slave socket\n");
7181 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
7182 if (s_info.client_fd < 0)
7183 ErrPrint("Failed to create a client socket\n");
7185 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
7186 if (s_info.service_fd < 0)
7187 ErrPrint("Faild to create a service socket\n");
7189 if (chmod(INFO_SOCKET, 0600) < 0)
7190 ErrPrint("info socket: %s\n", strerror(errno));
7192 if (chmod(SLAVE_SOCKET, 0666) < 0)
7193 ErrPrint("slave socket: %s\n", strerror(errno));
7195 if (chmod(CLIENT_SOCKET, 0666) < 0)
7196 ErrPrint("client socket: %s\n", strerror(errno));
7198 if (chmod(SERVICE_SOCKET, 0666) < 0)
7199 ErrPrint("service socket: %s\n", strerror(errno));
7204 HAPI int server_fini(void)
7206 if (s_info.info_fd > 0) {
7207 com_core_packet_server_fini(s_info.info_fd);
7208 s_info.info_fd = -1;
7211 if (s_info.slave_fd > 0) {
7212 com_core_packet_server_fini(s_info.slave_fd);
7213 s_info.slave_fd = -1;
7216 if (s_info.client_fd > 0) {
7217 com_core_packet_server_fini(s_info.client_fd);
7218 s_info.client_fd = -1;
7221 if (s_info.service_fd > 0) {
7222 com_core_packet_server_fini(s_info.service_fd);
7223 s_info.service_fd = -1;