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.
27 #include <com-core_packet.h>
28 #include <livebox-errno.h>
29 #include <livebox-service.h>
31 #include "critical_log.h"
35 #include "slave_life.h"
36 #include "slave_rpc.h"
37 #include "client_life.h"
39 #include "client_rpc.h"
41 #include "script_handler.h"
42 #include "buffer_handler.h"
44 #include "fault_manager.h"
52 #define PD_OPEN_MONITOR_TAG "pd,open,monitor"
53 #define PD_RESIZE_MONITOR_TAG "pd,resize,monitor"
54 #define PD_CLOSE_MONITOR_TAG "pd,close,monitor"
56 #define LAZY_PD_OPEN_TAG "lazy,pd,open"
57 #define LAZY_PD_CLOSE_TAG "lazy,pd,close"
70 .remote_client_fd = -1,
73 /* Share this with provider */
82 struct inst_info *inst;
86 struct client_node *client;
87 struct inst_info *inst;
90 static int forward_lb_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
92 struct buffer_info *buffer;
93 struct slave_node *slave;
96 buffer = instance_lb_buffer(inst);
98 ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
99 ret = LB_STATUS_ERROR_FAULT;
103 slave = package_slave(pkg);
105 ErrPrint("Package[%s] has no slave\n", package_name(pkg));
106 ret = LB_STATUS_ERROR_INVALID;
110 packet_ref((struct packet *)packet);
111 ret = slave_rpc_request_only(slave, package_name(pkg), (struct packet *)packet, 0);
117 static int forward_pd_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
119 struct buffer_info *buffer;
120 struct slave_node *slave;
123 buffer = instance_pd_buffer(inst);
125 ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
126 ret = LB_STATUS_ERROR_FAULT;
130 slave = package_slave(pkg);
132 ErrPrint("Package[%s] has no slave\n", package_name(pkg));
133 ret = LB_STATUS_ERROR_INVALID;
137 packet_ref((struct packet *)packet);
138 ret = slave_rpc_request_only(slave, package_name(pkg), (struct packet *)packet, 0);
144 static int forward_pd_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, int x, int y)
147 struct buffer_info *buffer;
148 struct slave_node *slave;
151 buffer = instance_pd_buffer(inst);
153 ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
154 ret = LB_STATUS_ERROR_FAULT;
158 slave = package_slave(pkg);
160 ErrPrint("Package[%s] has no slave\n", package_name(pkg));
161 ret = LB_STATUS_ERROR_INVALID;
165 p = packet_create_noack(command, "ssdii", package_name(pkg), instance_id(inst), timestamp, x, y);
166 ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
172 static int forward_lb_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, int x, int y)
175 struct buffer_info *buffer;
176 struct slave_node *slave;
179 buffer = instance_lb_buffer(inst);
181 ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
182 ret = LB_STATUS_ERROR_FAULT;
186 slave = package_slave(pkg);
188 ErrPrint("Package[%s] has no slave\n", package_name(pkg));
189 ret = LB_STATUS_ERROR_INVALID;
193 p = packet_create_noack(command, "ssdii", package_name(pkg), instance_id(inst), timestamp, x, y);
194 ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
200 static int forward_pd_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
203 struct buffer_info *buffer;
204 struct slave_node *slave;
207 buffer = instance_lb_buffer(inst);
209 ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
210 ret = LB_STATUS_ERROR_FAULT;
214 slave = package_slave(pkg);
216 ErrPrint("Package[%s] has no slave\n", package_name(pkg));
217 ret = LB_STATUS_ERROR_INVALID;
221 p = packet_create_noack(command, "ssdi", package_name(pkg), instance_id(inst), timestamp, keycode);
222 ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
228 static int forward_lb_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
231 struct buffer_info *buffer;
232 struct slave_node *slave;
235 buffer = instance_lb_buffer(inst);
237 ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
238 ret = LB_STATUS_ERROR_FAULT;
242 slave = package_slave(pkg);
244 ErrPrint("Package[%s] has no slave\n", package_name(pkg));
245 ret = LB_STATUS_ERROR_INVALID;
249 p = packet_create_noack(command, "ssdi", package_name(pkg), instance_id(inst), timestamp, keycode);
250 ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
256 static Eina_Bool lazy_key_status_cb(void *data)
258 struct event_cbdata *cbdata = data;
260 if (instance_unref(cbdata->inst)) {
261 instance_send_key_status(cbdata->inst, cbdata->status);
263 DbgPrint("Skip sending key status (%d)\n", cbdata->status);
266 * If instance_unref returns NULL,
267 * The instance is destroyed. it means, we don't need to send event to the viewer
270 return ECORE_CALLBACK_CANCEL;
273 static Eina_Bool lazy_access_status_cb(void *data)
275 struct event_cbdata *cbdata = data;
277 if (instance_unref(cbdata->inst)) {
278 instance_send_access_status(cbdata->inst, cbdata->status);
280 DbgPrint("Skip sending access status (%d)\n", cbdata->status);
283 * If instance_unref returns NULL,
284 * The instance is destroyed. it means, we don't need to send event to the viewer
287 return ECORE_CALLBACK_CANCEL;
290 static int slave_fault_open_script_cb(struct slave_node *slave, void *data)
294 (void)script_handler_unload(instance_pd_script(data), 1);
295 (void)instance_slave_close_pd(data, instance_pd_owner(data), LB_CLOSE_PD_FAULT);
296 (void)instance_client_pd_created(data, LB_STATUS_ERROR_FAULT);
298 timer = instance_del_data(data, LAZY_PD_OPEN_TAG);
300 ecore_timer_del(timer);
303 (void)instance_unref(data);
305 return -1; /* remove this handler */
308 static int slave_fault_open_buffer_cb(struct slave_node *slave, void *data)
312 (void)instance_slave_close_pd(data, instance_pd_owner(data), LB_CLOSE_PD_FAULT);
313 (void)instance_client_pd_created(data, LB_STATUS_ERROR_FAULT);
315 timer = instance_del_data(data, PD_OPEN_MONITOR_TAG);
317 ecore_timer_del(timer);
320 (void)instance_unref(data);
322 return -1; /* remove this handler */
325 static int slave_fault_close_script_cb(struct slave_node *slave, void *data)
329 (void)instance_client_pd_destroyed(data, LB_STATUS_ERROR_FAULT);
331 timer = instance_del_data(data, LAZY_PD_CLOSE_TAG);
333 ecore_timer_del(timer);
336 (void)instance_unref(data);
338 return -1; /* remove this handler */
341 static int slave_fault_close_buffer_cb(struct slave_node *slave, void *data)
345 (void)instance_client_pd_destroyed(data, LB_STATUS_ERROR_FAULT);
347 timer = instance_del_data(data, LAZY_PD_CLOSE_TAG);
349 timer = instance_del_data(data, PD_CLOSE_MONITOR_TAG);
353 ecore_timer_del(timer);
356 (void)instance_unref(data);
358 return -1; /* remove this handler */
361 static int slave_fault_resize_buffer_cb(struct slave_node *slave, void *data)
365 (void)instance_slave_close_pd(data, instance_pd_owner(data), LB_CLOSE_PD_FAULT);
366 (void)instance_client_pd_destroyed(data, LB_STATUS_ERROR_FAULT);
368 timer = instance_del_data(data, PD_RESIZE_MONITOR_TAG);
370 ecore_timer_del(timer);
373 (void)instance_unref(data);
375 return -1; /* remove this handler */
378 static int key_event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
380 struct inst_info *inst = data;
381 const struct pkg_info *pkg;
382 struct slave_node *slave;
383 struct packet *packet;
386 pkg = instance_package(inst);
388 return LB_STATUS_ERROR_INVALID;
391 slave = package_slave(pkg);
393 return LB_STATUS_ERROR_INVALID;
397 case EVENT_STATE_ACTIVATE:
398 cmdstr = "lb_key_down";
400 case EVENT_STATE_ACTIVATED:
401 cmdstr = "lb_key_down";
403 case EVENT_STATE_DEACTIVATE:
404 cmdstr = "lb_key_up";
407 return LB_STATUS_ERROR_INVALID;
410 packet = packet_create_noack(cmdstr, "ssdi", package_name(pkg), instance_id(inst), util_timestamp(), event_info->keycode);
412 return LB_STATUS_ERROR_FAULT;
415 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
418 static int mouse_event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
420 struct inst_info *inst = data;
421 const struct pkg_info *pkg;
422 struct slave_node *slave;
423 struct packet *packet;
426 pkg = instance_package(inst);
428 return LB_STATUS_ERROR_INVALID;
431 slave = package_slave(pkg);
433 return LB_STATUS_ERROR_INVALID;
437 case EVENT_STATE_ACTIVATE:
438 cmdstr = "lb_mouse_down";
440 case EVENT_STATE_ACTIVATED:
441 cmdstr = "lb_mouse_move";
443 case EVENT_STATE_DEACTIVATE:
444 cmdstr = "lb_mouse_up";
447 return LB_STATUS_ERROR_INVALID;
450 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
452 return LB_STATUS_ERROR_FAULT;
455 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
458 static int key_event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
460 struct script_info *script;
461 struct inst_info *inst = data;
462 const struct pkg_info *pkg;
465 pkg = instance_package(inst);
470 script = instance_lb_script(inst);
472 return LB_STATUS_ERROR_FAULT;
475 timestamp = util_timestamp();
478 case EVENT_STATE_ACTIVATE:
479 script_handler_update_keycode(script, event_info->keycode);
480 (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
482 case EVENT_STATE_ACTIVATED:
483 script_handler_update_keycode(script, event_info->keycode);
484 (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
486 case EVENT_STATE_DEACTIVATE:
487 script_handler_update_keycode(script, event_info->keycode);
488 (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
491 ErrPrint("Unknown event\n");
498 static int mouse_event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
500 struct script_info *script;
501 struct inst_info *inst = data;
502 const struct pkg_info *pkg;
505 pkg = instance_package(inst);
510 script = instance_lb_script(inst);
512 return LB_STATUS_ERROR_FAULT;
515 timestamp = util_timestamp();
518 case EVENT_STATE_ACTIVATE:
519 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
520 (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
522 case EVENT_STATE_ACTIVATED:
523 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
524 (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
526 case EVENT_STATE_DEACTIVATE:
527 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
528 (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
537 static int key_event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
539 struct inst_info *inst = data;
540 const struct pkg_info *pkg;
541 struct slave_node *slave;
542 struct packet *packet;
545 pkg = instance_package(inst);
547 return LB_STATUS_ERROR_INVALID;
550 slave = package_slave(pkg);
552 return LB_STATUS_ERROR_INVALID;
556 case EVENT_STATE_ACTIVATE:
557 cmdstr = "pd_key_down";
559 case EVENT_STATE_ACTIVATED:
560 cmdstr = "pd_key_down";
562 case EVENT_STATE_DEACTIVATE:
563 cmdstr = "pd_key_up";
566 return LB_STATUS_ERROR_INVALID;
569 packet = packet_create_noack(cmdstr, "ssdi", package_name(pkg), instance_id(inst), util_timestamp(), event_info->keycode);
571 return LB_STATUS_ERROR_FAULT;
574 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
577 static int mouse_event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
579 struct inst_info *inst = data;
580 const struct pkg_info *pkg;
581 struct slave_node *slave;
582 struct packet *packet;
585 pkg = instance_package(inst);
587 return LB_STATUS_ERROR_INVALID;
590 slave = package_slave(pkg);
592 return LB_STATUS_ERROR_INVALID;
596 case EVENT_STATE_ACTIVATE:
597 cmdstr = "pd_mouse_down";
599 case EVENT_STATE_ACTIVATED:
600 cmdstr = "pd_mouse_move";
602 case EVENT_STATE_DEACTIVATE:
603 cmdstr = "pd_mouse_up";
606 return LB_STATUS_ERROR_INVALID;
609 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
611 return LB_STATUS_ERROR_FAULT;
614 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
617 static int key_event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
619 struct script_info *script;
620 struct inst_info *inst = data;
621 const struct pkg_info *pkg;
624 pkg = instance_package(inst);
629 script = instance_pd_script(inst);
631 return LB_STATUS_ERROR_FAULT;
634 timestamp = util_timestamp();
637 case EVENT_STATE_ACTIVATE:
638 script_handler_update_keycode(script, event_info->keycode);
639 (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
641 case EVENT_STATE_ACTIVATED:
642 script_handler_update_keycode(script, event_info->keycode);
643 (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
645 case EVENT_STATE_DEACTIVATE:
646 script_handler_update_keycode(script, event_info->keycode);
647 (void)script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
650 ErrPrint("Unknown event\n");
657 static int mouse_event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
659 struct script_info *script;
660 struct inst_info *inst = data;
661 const struct pkg_info *pkg;
664 pkg = instance_package(inst);
669 script = instance_pd_script(inst);
671 return LB_STATUS_ERROR_FAULT;
674 timestamp = util_timestamp();
677 case EVENT_STATE_ACTIVATE:
678 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
679 (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
681 case EVENT_STATE_ACTIVATED:
682 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
683 (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
685 case EVENT_STATE_DEACTIVATE:
686 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
687 (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
695 static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
697 struct client_node *client;
698 struct packet *result;
702 client = client_find_by_rpc_handle(handle);
704 ErrPrint("Client is already exists %d\n", pid);
705 ret = LB_STATUS_ERROR_EXIST;
709 if (packet_get(packet, "d", ×tamp) != 1) {
710 ErrPrint("Invalid arguemnt\n");
711 ret = LB_STATUS_ERROR_INVALID;
718 * client_create will invoke the client created callback
720 client = client_create(pid, handle);
722 ErrPrint("Failed to create a new client for %d\n", pid);
723 ret = LB_STATUS_ERROR_FAULT;
727 result = packet_create_reply(packet, "i", ret);
729 ErrPrint("Failed to create a packet\n");
735 static struct packet *cilent_release(pid_t pid, int handle, const struct packet *packet) /*!< pid, ret */
737 struct client_node *client;
738 struct packet *result;
741 client = client_find_by_rpc_handle(handle);
743 ErrPrint("Client %d is not exists\n", pid);
744 ret = LB_STATUS_ERROR_NOT_EXIST;
748 client_destroy(client);
752 result = packet_create_reply(packet, "i", ret);
754 ErrPrint("Failed to create a packet\n");
760 static int validate_request(const char *pkgname, const char *id, struct inst_info **out_inst, const struct pkg_info **out_pkg)
762 struct inst_info *inst;
763 const struct pkg_info *pkg;
765 inst = package_find_instance_by_id(pkgname, id);
767 ErrPrint("Instance is not exists (%s)\n", id);
768 return LB_STATUS_ERROR_NOT_EXIST;
771 pkg = instance_package(inst);
773 ErrPrint("System error - instance has no package?\n");
774 return LB_STATUS_ERROR_INVALID;
777 if (package_is_fault(pkg)) {
778 ErrPrint("Faulted package: %s\n", pkgname);
779 return LB_STATUS_ERROR_FAULT;
790 return LB_STATUS_SUCCESS;
793 /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
794 static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
796 struct client_node *client;
804 struct inst_info *inst;
806 client = client_find_by_rpc_handle(handle);
808 ErrPrint("Client %d is not exists\n", pid);
812 ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
814 ErrPrint("Parameter is not matched\n");
820 * Trust the package name which are sent by the client.
821 * The package has to be a livebox package name.
823 ret = validate_request(pkgname, id, &inst, NULL);
824 if (ret == (int)LB_STATUS_SUCCESS) {
825 (void)instance_clicked(inst, event, timestamp, x, y);
829 /*! \note No reply packet */
833 static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet)
835 struct packet *result;
836 struct client_node *client;
841 struct inst_info *inst;
843 client = client_find_by_rpc_handle(handle);
845 ErrPrint("Client %d is not exists\n", pid);
846 ret = LB_STATUS_ERROR_INVALID;
850 ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
852 ErrPrint("Invalid argument\n");
853 ret = LB_STATUS_ERROR_INVALID;
857 ret = validate_request(pkgname, id, &inst, NULL);
858 if (ret == (int)LB_STATUS_SUCCESS) {
861 * Send change update mode request to a slave
863 ret = instance_set_update_mode(inst, active_update);
867 result = packet_create_reply(packet, "i", ret);
869 ErrPrint("Failed to create a packet\n");
875 /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
876 static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
878 struct client_node *client;
879 struct packet *result;
882 const char *emission;
888 struct inst_info *inst = NULL;
891 client = client_find_by_rpc_handle(handle);
893 ErrPrint("Client %d is not exists\n", pid);
894 ret = LB_STATUS_ERROR_NOT_EXIST;
898 ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
900 ErrPrint("Parameter is not matched\n");
901 ret = LB_STATUS_ERROR_INVALID;
907 * Trust the package name which are sent by the client.
908 * The package has to be a livebox package name.
910 ret = validate_request(pkgname, id, &inst, NULL);
911 if (ret == (int)LB_STATUS_SUCCESS) {
912 ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
916 result = packet_create_reply(packet, "i", ret);
918 ErrPrint("Failed to create a packet\n");
924 static Eina_Bool lazy_delete_cb(void *data)
926 struct deleted_item *item = data;
928 DbgPrint("Lazy delete callback called\n");
930 * Before invoke this callback, the instance is able to already remove this client
933 if (instance_has_client(item->inst, item->client)) {
934 (void)instance_unicast_deleted_event(item->inst, item->client, LB_STATUS_SUCCESS);
935 (void)instance_del_client(item->inst, item->client);
938 (void)client_unref(item->client);
939 (void)instance_unref(item->inst);
941 return ECORE_CALLBACK_CANCEL;
944 static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
946 struct client_node *client;
947 struct packet *result;
950 struct inst_info *inst;
951 const struct pkg_info *pkg;
956 client = client_find_by_rpc_handle(handle);
958 ErrPrint("Client %d is not exists\n", pid);
959 ret = LB_STATUS_ERROR_NOT_EXIST;
963 ret = packet_get(packet, "ssid", &pkgname, &id, &type, ×tamp);
965 ErrPrint("Parameter is not matched\n");
966 ret = LB_STATUS_ERROR_INVALID;
971 * Below two types must has to be sync'd with livebox-viewer
973 * LB_DELETE_PERMANENTLY = 0x01,
974 * LB_DELETE_TEMPORARY = 0x02,
980 * Trust the package name which are sent by the client.
981 * The package has to be a livebox package name.
983 ret = validate_request(pkgname, id, &inst, &pkg);
984 if (ret != LB_STATUS_SUCCESS) {
985 DbgPrint("Failed to find by id(%s), try to find it using timestamp(%lf)\n", id, timestamp);
986 inst = package_find_instance_by_timestamp(pkgname, timestamp);
991 pkg = instance_package(inst);
993 ErrPrint("Package info is not valid: %s\n", id);
998 if (package_is_fault(pkg)) {
999 DbgPrint("Faulted package. will be deleted soon: %s\n", id);
1000 ret = LB_STATUS_ERROR_FAULT;
1004 if (instance_client(inst) != client) {
1005 if (instance_has_client(inst, client)) {
1006 struct deleted_item *item;
1008 item = malloc(sizeof(*item));
1010 ErrPrint("Heap: %s\n", strerror(errno));
1011 ret = LB_STATUS_ERROR_MEMORY;
1015 * Send DELETED EVENT to the client.
1016 * after return from this function.
1018 * Client will prepare the deleted event after get this function's return value.
1019 * So We have to make a delay to send a deleted event.
1022 item->client = client_ref(client);
1023 item->inst = instance_ref(inst);
1025 if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
1026 ErrPrint("Failed to add a delayzed delete callback\n");
1027 (void)client_unref(client);
1028 (void)instance_unref(inst);
1030 ret = LB_STATUS_ERROR_FAULT;
1032 ret = LB_STATUS_SUCCESS;
1036 ErrPrint("Client has no permission\n");
1037 ret = LB_STATUS_ERROR_PERMISSION;
1041 case LB_DELETE_PERMANENTLY:
1042 ret = instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
1044 case LB_DELETE_TEMPORARY:
1045 ret = instance_destroy(inst, INSTANCE_DESTROY_TEMPORARY);
1053 result = packet_create_reply(packet, "i", ret);
1055 ErrPrint("Failed to create a packet\n");
1061 static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
1063 struct client_node *client;
1064 struct packet *result;
1065 const char *pkgname;
1069 struct inst_info *inst = NULL;
1072 client = client_find_by_rpc_handle(handle);
1074 ErrPrint("Client %d is not exists\n", pid);
1075 ret = LB_STATUS_ERROR_NOT_EXIST;
1079 ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
1081 ErrPrint("Parameter is not matched\n");
1082 ret = LB_STATUS_ERROR_INVALID;
1086 DbgPrint("RESIZE: Client request resize to %dx%d (pid: %d, pkgname: %s)\n", w, h, pid, pkgname);
1090 * Trust the package name which are sent by the client.
1091 * The package has to be a livebox package name.
1093 ret = validate_request(pkgname, id, &inst, NULL);
1094 if (ret != LB_STATUS_SUCCESS) {
1098 if (instance_client(inst) != client) {
1099 ret = LB_STATUS_ERROR_PERMISSION;
1101 ret = instance_resize(inst, w, h);
1105 result = packet_create_reply(packet, "i", ret);
1107 ErrPrint("Failed to create a packet\n");
1113 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
1115 struct client_node *client;
1116 struct packet *result;
1117 const char *pkgname;
1118 const char *content;
1119 const char *cluster;
1120 const char *category;
1124 struct pkg_info *info;
1130 client = client_find_by_rpc_handle(handle);
1132 ErrPrint("Client %d is not exists\n", pid);
1133 ret = LB_STATUS_ERROR_NOT_EXIST;
1137 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
1139 ErrPrint("Parameter is not matched\n");
1140 ret = LB_STATUS_ERROR_INVALID;
1144 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
1145 pid, timestamp, pkgname, content, cluster, category, period);
1147 lbid = package_lb_pkgname(pkgname);
1149 ErrPrint("This %s has no livebox package\n", pkgname);
1150 ret = LB_STATUS_ERROR_INVALID;
1154 mainappid = livebox_service_mainappid(lbid);
1155 if (!package_is_enabled(mainappid)) {
1158 ret = LB_STATUS_ERROR_DISABLED;
1163 info = package_find(lbid);
1166 pkgid = livebox_service_appid(lbid);
1170 ret = LB_STATUS_ERROR_FAULT;
1174 info = package_create(pkgid, lbid);
1179 ret = LB_STATUS_ERROR_FAULT;
1180 } else if (package_is_fault(info)) {
1181 ret = LB_STATUS_ERROR_FAULT;
1182 } else if (util_free_space(IMAGE_PATH) <= MINIMUM_SPACE) {
1183 ErrPrint("Not enough space\n");
1184 ret = LB_STATUS_ERROR_NO_SPACE;
1186 struct inst_info *inst;
1188 if (period > 0.0f && period < MINIMUM_PERIOD) {
1189 period = MINIMUM_PERIOD;
1192 inst = instance_create(client, timestamp, lbid, content, cluster, category, period, width, height);
1195 * Using the "inst" without validate its value is at my disposal. ;)
1197 ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
1203 result = packet_create_reply(packet, "i", ret);
1205 ErrPrint("Failed to create a packet\n");
1211 static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
1213 struct client_node *client;
1214 const char *pkgname;
1216 enum livebox_visible_state state;
1218 struct inst_info *inst;
1220 client = client_find_by_rpc_handle(handle);
1222 ErrPrint("Client %d is not exists\n", pid);
1223 ret = LB_STATUS_ERROR_NOT_EXIST;
1227 ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
1229 ErrPrint("Parameter is not matched\n");
1230 ret = LB_STATUS_ERROR_INVALID;
1236 * Trust the package name which are sent by the client.
1237 * The package has to be a livebox package name.
1239 ret = validate_request(pkgname, id, &inst, NULL);
1240 if (ret != LB_STATUS_SUCCESS) {
1244 if (instance_client(inst) != client) {
1245 ret = LB_STATUS_ERROR_PERMISSION;
1247 ret = instance_set_visible_state(inst, state);
1251 /*! \note No reply packet */
1255 static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
1257 struct client_node *client;
1258 struct packet *result;
1259 const char *pkgname;
1263 struct inst_info *inst = NULL;
1265 client = client_find_by_rpc_handle(handle);
1267 ErrPrint("Client %d is not exists\n", pid);
1268 ret = LB_STATUS_ERROR_NOT_EXIST;
1272 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
1274 ErrPrint("Parameter is not matched\n");
1275 ret = LB_STATUS_ERROR_INVALID;
1279 DbgPrint("pid[%d] pkgname[%s] period[%lf]\n", pid, pkgname, period);
1283 * Trust the package name which are sent by the client.
1284 * The package has to be a livebox package name.
1286 ret = validate_request(pkgname, id, &inst, NULL);
1287 if (ret != LB_STATUS_SUCCESS) {
1291 if (instance_client(inst) != client) {
1292 ret = LB_STATUS_ERROR_PERMISSION;
1294 ret = instance_set_period(inst, period);
1298 result = packet_create_reply(packet, "i", ret);
1300 ErrPrint("Failed to create a packet\n");
1306 static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
1308 struct client_node *client;
1309 struct packet *result;
1310 const char *pkgname;
1312 const char *cluster;
1313 const char *category;
1314 struct inst_info *inst = NULL;
1317 client = client_find_by_rpc_handle(handle);
1319 ErrPrint("Client %d is not exists\n", pid);
1320 ret = LB_STATUS_ERROR_NOT_EXIST;
1324 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
1326 ErrPrint("Parameter is not matched\n");
1327 ret = LB_STATUS_ERROR_INVALID;
1331 DbgPrint("pid[%d] pkgname[%s] cluster[%s] category[%s]\n", pid, pkgname, cluster, category);
1335 * Trust the package name which are sent by the client.
1336 * The package has to be a livebox package name.
1338 ret = validate_request(pkgname, id, &inst, NULL);
1339 if (ret != LB_STATUS_SUCCESS) {
1343 if (instance_client(inst) != client) {
1344 ret = LB_STATUS_ERROR_PERMISSION;
1346 ret = instance_change_group(inst, cluster, category);
1350 result = packet_create_reply(packet, "i", ret);
1352 ErrPrint("Failed to create a packet\n");
1358 static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
1360 struct client_node *client;
1361 const char *pkgname;
1367 struct inst_info *inst;
1368 const struct pkg_info *pkg;
1370 client = client_find_by_rpc_handle(handle);
1372 ErrPrint("Client %d is not exists\n", pid);
1373 ret = LB_STATUS_ERROR_NOT_EXIST;
1377 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1379 ErrPrint("Invalid parameter\n");
1380 ret = LB_STATUS_ERROR_INVALID;
1384 ret = validate_request(pkgname, id, &inst, &pkg);
1385 if (ret != LB_STATUS_SUCCESS) {
1389 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1390 ret = forward_pd_event_packet(pkg, inst, packet);
1391 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1392 struct script_info *script;
1394 script = instance_pd_script(inst);
1396 ret = LB_STATUS_ERROR_FAULT;
1400 script_handler_update_pointer(script, x, y, -1);
1401 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
1404 ErrPrint("Unsupported package\n");
1405 ret = LB_STATUS_ERROR_INVALID;
1409 /*! \note No reply packet */
1413 static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
1415 struct client_node *client;
1416 const char *pkgname;
1422 struct inst_info *inst;
1423 const struct pkg_info *pkg;
1425 client = client_find_by_rpc_handle(handle);
1427 ErrPrint("Client %d is not exists\n", pid);
1428 ret = LB_STATUS_ERROR_NOT_EXIST;
1432 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1434 ErrPrint("Parameter is not matched\n");
1435 ret = LB_STATUS_ERROR_INVALID;
1439 ret = validate_request(pkgname, id, &inst, &pkg);
1440 if (ret != LB_STATUS_SUCCESS) {
1444 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1445 ret = forward_pd_event_packet(pkg, inst, packet);
1446 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1447 struct script_info *script;
1449 script = instance_pd_script(inst);
1451 ret = LB_STATUS_ERROR_FAULT;
1455 script_handler_update_pointer(script, x, y, -1);
1456 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
1459 ErrPrint("Unsupported package\n");
1460 ret = LB_STATUS_ERROR_INVALID;
1464 /*! \note No reply packet */
1468 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 */
1470 struct client_node *client;
1471 const char *pkgname;
1477 struct inst_info *inst;
1478 const struct pkg_info *pkg;
1480 client = client_find_by_rpc_handle(handle);
1482 ErrPrint("Client %d is not exists\n", pid);
1483 ret = LB_STATUS_ERROR_NOT_EXIST;
1487 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1489 ErrPrint("Parameter is not matched\n");
1490 ret = LB_STATUS_ERROR_INVALID;
1494 ret = validate_request(pkgname, id, &inst, &pkg);
1495 if (ret != LB_STATUS_SUCCESS) {
1499 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1500 ret = forward_pd_event_packet(pkg, inst, packet);
1501 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1502 struct script_info *script;
1504 script = instance_pd_script(inst);
1506 ret = LB_STATUS_ERROR_FAULT;
1510 script_handler_update_pointer(script, x, y, 1);
1511 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
1514 ErrPrint("Unsupported package\n");
1515 ret = LB_STATUS_ERROR_INVALID;
1519 /*! \note No reply packet */
1523 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 */
1525 struct client_node *client;
1526 const char *pkgname;
1532 struct inst_info *inst;
1533 const struct pkg_info *pkg;
1535 client = client_find_by_rpc_handle(handle);
1537 ErrPrint("Client %d is not exists\n", pid);
1538 ret = LB_STATUS_ERROR_NOT_EXIST;
1542 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1544 ErrPrint("Parameter is not matched\n");
1545 ret = LB_STATUS_ERROR_INVALID;
1549 ret = validate_request(pkgname, id, &inst, &pkg);
1550 if (ret != LB_STATUS_SUCCESS) {
1554 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1555 ret = forward_pd_event_packet(pkg, inst, packet);
1556 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1557 struct script_info *script;
1559 script = instance_pd_script(inst);
1561 ret = LB_STATUS_ERROR_FAULT;
1565 script_handler_update_pointer(script, x, y, 0);
1566 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
1569 ErrPrint("Unsupported package\n");
1570 ret = LB_STATUS_ERROR_INVALID;
1574 /*! \note No reply packet */
1578 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 */
1580 struct client_node *client;
1581 const char *pkgname;
1587 struct inst_info *inst;
1588 const struct pkg_info *pkg;
1590 client = client_find_by_rpc_handle(handle);
1592 ErrPrint("Client %d is not exists\n", pid);
1593 ret = LB_STATUS_ERROR_NOT_EXIST;
1597 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1599 ErrPrint("Parameter is not matched\n");
1600 ret = LB_STATUS_ERROR_INVALID;
1604 ret = validate_request(pkgname, id, &inst, &pkg);
1605 if (ret != LB_STATUS_SUCCESS) {
1609 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1610 ret = forward_pd_event_packet(pkg, inst, packet);
1611 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1612 struct script_info *script;
1614 script = instance_pd_script(inst);
1616 ret = LB_STATUS_ERROR_FAULT;
1620 script_handler_update_pointer(script, x, y, -1);
1621 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1624 ErrPrint("Unsupported package\n");
1625 ret = LB_STATUS_ERROR_INVALID;
1629 /*! \note No reply packet */
1633 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 */
1635 struct client_node *client;
1636 const char *pkgname;
1642 struct inst_info *inst;
1643 const struct pkg_info *pkg;
1645 client = client_find_by_rpc_handle(handle);
1647 ErrPrint("Client %d is not exists\n", pid);
1648 ret = LB_STATUS_ERROR_NOT_EXIST;
1652 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1654 ErrPrint("Parameter is not matched\n");
1655 ret = LB_STATUS_ERROR_INVALID;
1659 ret = validate_request(pkgname, id, &inst, &pkg);
1660 if (ret != LB_STATUS_SUCCESS) {
1664 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1665 ret = forward_lb_event_packet(pkg, inst, packet);
1666 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1667 struct script_info *script;
1669 script = instance_lb_script(inst);
1671 ret = LB_STATUS_ERROR_FAULT;
1675 script_handler_update_pointer(script, x, y, -1);
1676 script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
1679 ErrPrint("Unsupported package\n");
1680 ret = LB_STATUS_ERROR_INVALID;
1684 /*! \note No reply packet */
1688 static int inst_del_cb(struct inst_info *inst, void *data)
1690 (void)event_deactivate(data, inst);
1691 return -1; /* Delete this callback */
1695 static struct packet *client_pd_key_set(pid_t pid, int handle, const struct packet *packet)
1697 struct client_node *client;
1698 const char *pkgname;
1702 unsigned int keycode;
1703 struct inst_info *inst;
1704 const struct pkg_info *pkg;
1705 struct packet *result;
1707 client = client_find_by_rpc_handle(handle);
1709 ErrPrint("Client %d is not exists\n", pid);
1710 ret = LB_STATUS_ERROR_NOT_EXIST;
1714 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
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) {
1726 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1727 ret = event_activate(0, 0, key_event_pd_route_cb, inst);
1729 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_route_cb);
1731 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1732 ret = event_activate(0, 0, key_event_pd_consume_cb, inst);
1734 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_consume_cb);
1737 ErrPrint("Unsupported package\n");
1738 ret = LB_STATUS_ERROR_INVALID;
1742 result = packet_create_reply(packet, "i", ret);
1744 ErrPrint("Failed to create a reply packet\n");
1750 static struct packet *client_pd_key_unset(pid_t pid, int handle, const struct packet *packet)
1752 struct client_node *client;
1753 const char *pkgname;
1757 unsigned int keycode;
1758 struct inst_info *inst;
1759 const struct pkg_info *pkg;
1760 struct packet *result;
1762 client = client_find_by_rpc_handle(handle);
1764 ErrPrint("Client %d is not exists\n", pid);
1765 ret = LB_STATUS_ERROR_NOT_EXIST;
1769 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
1771 ErrPrint("Parameter is not matched\n");
1772 ret = LB_STATUS_ERROR_INVALID;
1776 ret = validate_request(pkgname, id, &inst, &pkg);
1777 if (ret != LB_STATUS_SUCCESS) {
1781 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1782 ret = event_deactivate(key_event_pd_route_cb, inst);
1784 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_route_cb);
1786 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1787 ret = event_deactivate(key_event_pd_consume_cb, inst);
1789 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_consume_cb);
1792 ErrPrint("Unsupported package\n");
1793 ret = LB_STATUS_ERROR_INVALID;
1797 result = packet_create_reply(packet, "i", ret);
1799 ErrPrint("Failed to create a reply packet\n");
1805 static struct packet *client_lb_key_set(pid_t pid, int handle, const struct packet *packet)
1807 struct client_node *client;
1808 const char *pkgname;
1812 unsigned int keycode;
1813 struct inst_info *inst;
1814 const struct pkg_info *pkg;
1815 struct packet *result;
1817 client = client_find_by_rpc_handle(handle);
1819 ErrPrint("Client %d is not exists\n", pid);
1820 ret = LB_STATUS_ERROR_NOT_EXIST;
1824 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
1826 ErrPrint("Parameter is not matched\n");
1827 ret = LB_STATUS_ERROR_INVALID;
1831 ret = validate_request(pkgname, id, &inst, &pkg);
1832 if (ret != LB_STATUS_SUCCESS) {
1836 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1837 ret = event_activate(0, 0, key_event_lb_route_cb, inst);
1839 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_route_cb);
1841 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1842 ret = event_activate(0, 0, key_event_lb_consume_cb, inst);
1844 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_consume_cb);
1847 ErrPrint("Unsupported package\n");
1848 ret = LB_STATUS_ERROR_INVALID;
1852 result = packet_create_reply(packet, "i", ret);
1854 ErrPrint("Failed to create a reply packet\n");
1860 static struct packet *client_lb_key_unset(pid_t pid, int handle, const struct packet *packet)
1862 struct client_node *client;
1863 const char *pkgname;
1867 unsigned int keycode;
1868 struct inst_info *inst;
1869 const struct pkg_info *pkg;
1870 struct packet *result;
1872 client = client_find_by_rpc_handle(handle);
1874 ErrPrint("Client %d is not exists\n", pid);
1875 ret = LB_STATUS_ERROR_NOT_EXIST;
1879 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
1881 ErrPrint("Parameter is not matched\n");
1882 ret = LB_STATUS_ERROR_INVALID;
1886 ret = validate_request(pkgname, id, &inst, &pkg);
1887 if (ret != LB_STATUS_SUCCESS) {
1891 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1892 ret = event_deactivate(key_event_lb_route_cb, inst);
1894 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_route_cb);
1896 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1897 ret = event_deactivate(key_event_lb_consume_cb, inst);
1899 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_consume_cb);
1902 ErrPrint("Unsupported package\n");
1903 ret = LB_STATUS_ERROR_INVALID;
1907 result = packet_create_reply(packet, "i", ret);
1909 ErrPrint("Failed to create a reply packet\n");
1915 static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
1917 struct client_node *client;
1918 const char *pkgname;
1924 struct inst_info *inst;
1925 const struct pkg_info *pkg;
1927 client = client_find_by_rpc_handle(handle);
1929 ErrPrint("Client %d is not exists\n", pid);
1930 ret = LB_STATUS_ERROR_NOT_EXIST;
1934 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1936 ErrPrint("Parameter is not matched\n");
1937 ret = LB_STATUS_ERROR_INVALID;
1941 ret = validate_request(pkgname, id, &inst, &pkg);
1942 if (ret != LB_STATUS_SUCCESS) {
1946 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1947 ret = event_activate(x, y, mouse_event_lb_route_cb, inst);
1949 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_route_cb);
1951 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1952 ret = event_activate(x, y, mouse_event_lb_consume_cb, inst);
1954 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_consume_cb);
1957 ErrPrint("Unsupported package\n");
1958 ret = LB_STATUS_ERROR_INVALID;
1964 static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1966 struct client_node *client;
1967 const char *pkgname;
1973 struct inst_info *inst;
1974 const struct pkg_info *pkg;
1976 client = client_find_by_rpc_handle(handle);
1978 ErrPrint("Client %d is not exists\n", pid);
1979 ret = LB_STATUS_ERROR_NOT_EXIST;
1983 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1985 ErrPrint("Parameter is not matched\n");
1986 ret = LB_STATUS_ERROR_INVALID;
1990 ret = validate_request(pkgname, id, &inst, &pkg);
1991 if (ret != LB_STATUS_SUCCESS) {
1995 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1996 ret = event_deactivate(mouse_event_lb_route_cb, inst);
1998 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_route_cb);
2000 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2001 ret = event_deactivate(mouse_event_lb_consume_cb, inst);
2003 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_consume_cb);
2006 ErrPrint("Unsupported package\n");
2007 ret = LB_STATUS_ERROR_INVALID;
2013 static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
2015 struct client_node *client;
2016 const char *pkgname;
2022 struct inst_info *inst;
2023 const struct pkg_info *pkg;
2025 client = client_find_by_rpc_handle(handle);
2027 ErrPrint("Client %d is not exists\n", pid);
2028 ret = LB_STATUS_ERROR_NOT_EXIST;
2032 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2034 ErrPrint("Parameter is not matched\n");
2035 ret = LB_STATUS_ERROR_INVALID;
2039 ret = validate_request(pkgname, id, &inst, &pkg);
2040 if (ret != LB_STATUS_SUCCESS) {
2044 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2045 ret = event_activate(x, y, mouse_event_pd_route_cb, inst);
2047 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_route_cb);
2049 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2050 ret = event_activate(x, y, mouse_event_pd_consume_cb, inst);
2052 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_consume_cb);
2055 ErrPrint("Unsupported package\n");
2056 ret = LB_STATUS_ERROR_INVALID;
2063 static struct packet *client_lb_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
2065 struct client_node *client;
2066 const char *pkgname;
2072 struct inst_info *inst;
2073 const struct pkg_info *pkg;
2075 client = client_find_by_rpc_handle(handle);
2077 ErrPrint("Client %d is not exists\n", pid);
2078 ret = LB_STATUS_ERROR_NOT_EXIST;
2082 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2084 ErrPrint("Parameter is not matched\n");
2085 ret = LB_STATUS_ERROR_INVALID;
2089 ret = validate_request(pkgname, id, &inst, &pkg);
2090 if (ret != LB_STATUS_SUCCESS) {
2094 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2095 ret = forward_lb_event_packet(pkg, inst, packet);
2096 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2097 struct script_info *script;
2099 script = instance_lb_script(inst);
2101 ret = LB_STATUS_ERROR_FAULT;
2105 script_handler_update_pointer(script, x, y, -1);
2106 script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_SCROLL, timestamp);
2109 ErrPrint("Unsupported package\n");
2110 ret = LB_STATUS_ERROR_INVALID;
2114 /*! \note No reply packet */
2118 static struct packet *client_lb_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
2120 struct client_node *client;
2121 const char *pkgname;
2127 struct inst_info *inst;
2128 const struct pkg_info *pkg;
2130 client = client_find_by_rpc_handle(handle);
2132 ErrPrint("Client %d is not exists\n", pid);
2133 ret = LB_STATUS_ERROR_NOT_EXIST;
2137 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2139 ErrPrint("Parameter is not matched\n");
2140 ret = LB_STATUS_ERROR_INVALID;
2144 ret = validate_request(pkgname, id, &inst, &pkg);
2145 if (ret != LB_STATUS_SUCCESS) {
2149 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2150 ret = forward_lb_event_packet(pkg, inst, packet);
2151 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2152 struct script_info *script;
2154 script = instance_lb_script(inst);
2156 ret = LB_STATUS_ERROR_FAULT;
2160 script_handler_update_pointer(script, x, y, -1);
2161 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
2164 ErrPrint("Unsupported package\n");
2165 ret = LB_STATUS_ERROR_INVALID;
2169 /*! \note No reply packet */
2173 static struct packet *client_lb_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
2175 struct client_node *client;
2176 const char *pkgname;
2182 struct inst_info *inst;
2183 const struct pkg_info *pkg;
2185 client = client_find_by_rpc_handle(handle);
2187 ErrPrint("Client %d is not exists\n", pid);
2188 ret = LB_STATUS_ERROR_NOT_EXIST;
2192 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2194 ErrPrint("Parameter is not matched\n");
2195 ret = LB_STATUS_ERROR_INVALID;
2199 ret = validate_request(pkgname, id, &inst, &pkg);
2200 if (ret != LB_STATUS_SUCCESS) {
2204 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2205 ret = forward_lb_event_packet(pkg, inst, packet);
2206 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2207 struct script_info *script;
2209 script = instance_lb_script(inst);
2211 ret = LB_STATUS_ERROR_FAULT;
2215 script_handler_update_pointer(script, x, y, -1);
2216 script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_HOLD, timestamp);
2219 ErrPrint("Unsupported package\n");
2220 ret = LB_STATUS_ERROR_INVALID;
2224 /*! \note No reply packet */
2228 static struct packet *client_lb_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
2230 struct client_node *client;
2231 const char *pkgname;
2237 struct inst_info *inst;
2238 const struct pkg_info *pkg;
2240 client = client_find_by_rpc_handle(handle);
2242 ErrPrint("Client %d is not exists\n", pid);
2243 ret = LB_STATUS_ERROR_NOT_EXIST;
2247 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2249 ErrPrint("Parameter is not matched\n");
2250 ret = LB_STATUS_ERROR_INVALID;
2254 ret = validate_request(pkgname, id, &inst, &pkg);
2255 if (ret != LB_STATUS_SUCCESS) {
2259 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2260 ret = forward_lb_event_packet(pkg, inst, packet);
2261 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2262 struct script_info *script;
2264 script = instance_lb_script(inst);
2266 ret = LB_STATUS_ERROR_FAULT;
2270 script_handler_update_pointer(script, x, y, -1);
2271 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_HOLD, timestamp);
2274 ErrPrint("Unsupported package\n");
2275 ret = LB_STATUS_ERROR_INVALID;
2279 /*! \note No reply packet */
2283 static struct packet *client_pd_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
2285 struct client_node *client;
2286 const char *pkgname;
2292 struct inst_info *inst;
2293 const struct pkg_info *pkg;
2295 client = client_find_by_rpc_handle(handle);
2297 ErrPrint("Client %d is not exists\n", pid);
2298 ret = LB_STATUS_ERROR_NOT_EXIST;
2302 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2304 ErrPrint("Parameter is not matched\n");
2305 ret = LB_STATUS_ERROR_INVALID;
2309 ret = validate_request(pkgname, id, &inst, &pkg);
2310 if (ret != LB_STATUS_SUCCESS) {
2314 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2315 ret = forward_pd_event_packet(pkg, inst, packet);
2316 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2317 struct script_info *script;
2319 script = instance_pd_script(inst);
2321 ret = LB_STATUS_ERROR_FAULT;
2325 script_handler_update_pointer(script, x, y, -1);
2326 script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_SCROLL, timestamp);
2329 ErrPrint("Unsupported package\n");
2330 ret = LB_STATUS_ERROR_INVALID;
2334 /*! \note No reply packet */
2338 static struct packet *client_pd_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
2340 struct client_node *client;
2341 const char *pkgname;
2347 struct inst_info *inst;
2348 const struct pkg_info *pkg;
2350 client = client_find_by_rpc_handle(handle);
2352 ErrPrint("Client %d is not exists\n", pid);
2353 ret = LB_STATUS_ERROR_NOT_EXIST;
2357 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2359 ErrPrint("Parameter is not matched\n");
2360 ret = LB_STATUS_ERROR_INVALID;
2364 ret = validate_request(pkgname, id, &inst, &pkg);
2365 if (ret != LB_STATUS_SUCCESS) {
2369 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2370 ret = forward_pd_event_packet(pkg, inst, packet);
2371 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2372 struct script_info *script;
2374 script = instance_pd_script(inst);
2376 ret = LB_STATUS_ERROR_FAULT;
2380 script_handler_update_pointer(script, x, y, -1);
2381 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
2384 ErrPrint("Unsupported package\n");
2385 ret = LB_STATUS_ERROR_INVALID;
2389 /*! \note No reply packet */
2393 static struct packet *client_pd_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
2395 struct client_node *client;
2396 const char *pkgname;
2402 struct inst_info *inst;
2403 const struct pkg_info *pkg;
2405 client = client_find_by_rpc_handle(handle);
2407 ErrPrint("Client %d is not exists\n", pid);
2408 ret = LB_STATUS_ERROR_NOT_EXIST;
2412 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2414 ErrPrint("Parameter is not matched\n");
2415 ret = LB_STATUS_ERROR_INVALID;
2419 ret = validate_request(pkgname, id, &inst, &pkg);
2420 if (ret != LB_STATUS_SUCCESS) {
2424 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2425 ret = forward_pd_event_packet(pkg, inst, packet);
2426 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2427 struct script_info *script;
2429 script = instance_pd_script(inst);
2431 ret = LB_STATUS_ERROR_FAULT;
2435 script_handler_update_pointer(script, x, y, -1);
2436 script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_HOLD, timestamp);
2439 ErrPrint("Unsupported package\n");
2440 ret = LB_STATUS_ERROR_INVALID;
2444 /*! \note No reply packet */
2448 static struct packet *client_pd_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
2450 struct client_node *client;
2451 const char *pkgname;
2457 struct inst_info *inst;
2458 const struct pkg_info *pkg;
2460 client = client_find_by_rpc_handle(handle);
2462 ErrPrint("Client %d is not exists\n", pid);
2463 ret = LB_STATUS_ERROR_NOT_EXIST;
2467 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2469 ErrPrint("Parameter is not matched\n");
2470 ret = LB_STATUS_ERROR_INVALID;
2474 ret = validate_request(pkgname, id, &inst, &pkg);
2475 if (ret != LB_STATUS_SUCCESS) {
2479 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2480 ret = forward_pd_event_packet(pkg, inst, packet);
2481 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2482 struct script_info *script;
2484 script = instance_pd_script(inst);
2486 ret = LB_STATUS_ERROR_FAULT;
2490 script_handler_update_pointer(script, x, y, -1);
2491 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_HOLD, timestamp);
2494 ErrPrint("Unsupported package\n");
2495 ret = LB_STATUS_ERROR_INVALID;
2499 /*! \note No reply packet */
2503 static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
2505 struct client_node *client;
2506 const char *pkgname;
2512 struct inst_info *inst;
2513 const struct pkg_info *pkg;
2515 client = client_find_by_rpc_handle(handle);
2517 ErrPrint("Client %d is not exists\n", pid);
2518 ret = LB_STATUS_ERROR_NOT_EXIST;
2522 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2524 ErrPrint("Parameter is not matched\n");
2525 ret = LB_STATUS_ERROR_INVALID;
2529 ret = validate_request(pkgname, id, &inst, &pkg);
2530 if (ret != LB_STATUS_SUCCESS) {
2534 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2535 ret = event_deactivate(mouse_event_pd_route_cb, inst);
2537 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_route_cb);
2539 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2540 ret = event_deactivate(mouse_event_pd_consume_cb, inst);
2542 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_consume_cb);
2545 ErrPrint("Unsupported package\n");
2546 ret = LB_STATUS_ERROR_INVALID;
2552 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 */
2554 struct client_node *client;
2555 const char *pkgname;
2561 struct inst_info *inst;
2562 const struct pkg_info *pkg;
2564 client = client_find_by_rpc_handle(handle);
2566 ErrPrint("Client %d is not exists\n", pid);
2567 ret = LB_STATUS_ERROR_NOT_EXIST;
2571 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2573 ErrPrint("Parameter is not matched\n");
2574 ret = LB_STATUS_ERROR_INVALID;
2578 ret = validate_request(pkgname, id, &inst, &pkg);
2579 if (ret != LB_STATUS_SUCCESS) {
2583 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2584 ret = forward_lb_event_packet(pkg, inst, packet);
2585 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2586 struct script_info *script;
2588 script = instance_lb_script(inst);
2590 ret = LB_STATUS_ERROR_FAULT;
2594 script_handler_update_pointer(script, x, y, -1);
2595 script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
2598 ErrPrint("Unsupported package\n");
2599 ret = LB_STATUS_ERROR_INVALID;
2603 /*! \note No reply packet */
2607 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 */
2609 struct client_node *client;
2610 const char *pkgname;
2616 struct inst_info *inst;
2617 const struct pkg_info *pkg;
2619 client = client_find_by_rpc_handle(handle);
2621 ErrPrint("Client %d is not exists\n", pid);
2622 ret = LB_STATUS_ERROR_NOT_EXIST;
2626 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2628 ErrPrint("Parameter is not matched\n");
2629 ret = LB_STATUS_ERROR_INVALID;
2633 ret = validate_request(pkgname, id, &inst, &pkg);
2634 if (ret != LB_STATUS_SUCCESS) {
2638 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2639 ret = forward_lb_event_packet(pkg, inst, packet);
2640 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2641 struct script_info *script;
2643 script = instance_lb_script(inst);
2645 ret = LB_STATUS_ERROR_FAULT;
2649 script_handler_update_pointer(script, x, y, -1);
2650 script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
2653 ErrPrint("Unsupported package\n");
2654 ret = LB_STATUS_ERROR_INVALID;
2658 /*! \note No reply packet */
2662 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 */
2664 struct client_node *client;
2665 const char *pkgname;
2671 struct inst_info *inst;
2672 const struct pkg_info *pkg;
2674 client = client_find_by_rpc_handle(handle);
2676 ErrPrint("Client %d is not exists\n", pid);
2677 ret = LB_STATUS_ERROR_NOT_EXIST;
2681 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2683 ErrPrint("Parameter is not matched\n");
2684 ret = LB_STATUS_ERROR_INVALID;
2688 ret = validate_request(pkgname, id, &inst, &pkg);
2689 if (ret != LB_STATUS_SUCCESS) {
2693 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2694 ret = forward_lb_event_packet(pkg, inst, packet);
2695 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2696 struct script_info *script;
2698 script = instance_lb_script(inst);
2700 ret = LB_STATUS_ERROR_FAULT;
2704 script_handler_update_pointer(script, x, y, 1);
2705 script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
2708 ErrPrint("Unsupported package\n");
2709 ret = LB_STATUS_ERROR_INVALID;
2713 /*! \note No reply packet */
2717 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 */
2719 struct client_node *client;
2720 const char *pkgname;
2726 struct inst_info *inst;
2727 const struct pkg_info *pkg;
2729 client = client_find_by_rpc_handle(handle);
2731 ErrPrint("Client %d is not exists\n", pid);
2732 ret = LB_STATUS_ERROR_NOT_EXIST;
2736 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2738 ErrPrint("Parameter is not matched\n");
2739 ret = LB_STATUS_ERROR_INVALID;
2743 ret = validate_request(pkgname, id, &inst, &pkg);
2744 if (ret != LB_STATUS_SUCCESS) {
2748 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2749 ret = forward_lb_event_packet(pkg, inst, packet);
2750 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2751 struct script_info *script;
2753 script = instance_lb_script(inst);
2755 ret = LB_STATUS_ERROR_FAULT;
2759 script_handler_update_pointer(script, x, y, 0);
2760 script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
2763 ErrPrint("Unsupported package\n");
2764 ret = LB_STATUS_ERROR_INVALID;
2768 /*! \note No reply packet */
2772 static struct packet *client_pd_access_action_up(pid_t pid, int handle, const struct packet *packet)
2774 struct packet *result;
2775 struct client_node *client;
2776 const char *pkgname;
2782 struct inst_info *inst = NULL;
2783 const struct pkg_info *pkg = NULL;
2785 client = client_find_by_rpc_handle(handle);
2787 ErrPrint("Client %d is not exists\n", pid);
2788 ret = LB_STATUS_ERROR_NOT_EXIST;
2792 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2794 ErrPrint("Invalid parameter\n");
2795 ret = LB_STATUS_ERROR_INVALID;
2799 ret = validate_request(pkgname, id, &inst, &pkg);
2800 if (ret != LB_STATUS_SUCCESS) {
2804 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2805 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
2806 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2807 struct script_info *script;
2809 script = instance_pd_script(inst);
2811 ret = LB_STATUS_ERROR_FAULT;
2815 script_handler_update_pointer(script, x, y, 0);
2816 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
2818 struct event_cbdata *cbdata;
2820 cbdata = malloc(sizeof(*cbdata));
2822 ret = LB_STATUS_ERROR_MEMORY;
2824 cbdata->inst = instance_ref(inst);
2825 cbdata->status = ret;
2827 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2828 (void)instance_unref(cbdata->inst);
2830 ret = LB_STATUS_ERROR_FAULT;
2832 ret = LB_STATUS_SUCCESS;
2837 ErrPrint("Unsupported package\n");
2838 ret = LB_STATUS_ERROR_INVALID;
2842 result = packet_create_reply(packet, "i", ret);
2844 ErrPrint("Failed to create a reply packet\n");
2850 static struct packet *client_pd_access_action_down(pid_t pid, int handle, const struct packet *packet)
2852 struct packet *result;
2853 struct client_node *client;
2854 const char *pkgname;
2860 struct inst_info *inst = NULL;
2861 const struct pkg_info *pkg = NULL;
2863 client = client_find_by_rpc_handle(handle);
2865 ErrPrint("Client %d is not exists\n", pid);
2866 ret = LB_STATUS_ERROR_NOT_EXIST;
2870 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2872 ErrPrint("Invalid parameter\n");
2873 ret = LB_STATUS_ERROR_INVALID;
2877 ret = validate_request(pkgname, id, &inst, &pkg);
2878 if (ret != LB_STATUS_SUCCESS) {
2882 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2883 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
2884 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2885 struct script_info *script;
2887 script = instance_pd_script(inst);
2889 ret = LB_STATUS_ERROR_FAULT;
2893 script_handler_update_pointer(script, x, y, 1);
2894 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
2896 struct event_cbdata *cbdata;
2898 cbdata = malloc(sizeof(*cbdata));
2900 ret = LB_STATUS_ERROR_MEMORY;
2902 cbdata->inst = instance_ref(inst);
2903 cbdata->status = ret;
2905 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2906 (void)instance_unref(cbdata->inst);
2908 ret = LB_STATUS_ERROR_FAULT;
2910 ret = LB_STATUS_SUCCESS;
2915 ErrPrint("Unsupported package\n");
2916 ret = LB_STATUS_ERROR_INVALID;
2920 result = packet_create_reply(packet, "i", ret);
2922 ErrPrint("Failed to create a reply packet\n");
2928 static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
2930 struct packet *result;
2931 struct client_node *client;
2932 const char *pkgname;
2938 struct inst_info *inst = NULL;
2939 const struct pkg_info *pkg = NULL;
2941 client = client_find_by_rpc_handle(handle);
2943 ErrPrint("Client %d is not exists\n", pid);
2944 ret = LB_STATUS_ERROR_NOT_EXIST;
2948 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2950 ErrPrint("Invalid parameter\n");
2951 ret = LB_STATUS_ERROR_INVALID;
2955 ret = validate_request(pkgname, id, &inst, &pkg);
2956 if (ret != LB_STATUS_SUCCESS) {
2960 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2961 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
2962 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2963 struct script_info *script;
2965 script = instance_pd_script(inst);
2967 ret = LB_STATUS_ERROR_FAULT;
2971 script_handler_update_pointer(script, x, y, 1);
2972 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
2974 struct event_cbdata *cbdata;
2976 cbdata = malloc(sizeof(*cbdata));
2978 ret = LB_STATUS_ERROR_MEMORY;
2980 cbdata->inst = instance_ref(inst);
2981 cbdata->status = ret;
2983 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
2984 (void)instance_unref(cbdata->inst);
2986 ret = LB_STATUS_ERROR_FAULT;
2988 ret = LB_STATUS_SUCCESS;
2993 ErrPrint("Unsupported package\n");
2994 ret = LB_STATUS_ERROR_INVALID;
2998 result = packet_create_reply(packet, "i", ret);
3000 ErrPrint("Failed to create a reply packet\n");
3006 static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
3008 struct packet *result;
3009 struct client_node *client;
3010 const char *pkgname;
3016 struct inst_info *inst = NULL;
3017 const struct pkg_info *pkg = NULL;
3019 client = client_find_by_rpc_handle(handle);
3021 ErrPrint("Client %d is not exists\n", pid);
3022 ret = LB_STATUS_ERROR_NOT_EXIST;
3026 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3028 ErrPrint("Invalid parameter\n");
3029 ret = LB_STATUS_ERROR_INVALID;
3033 ret = validate_request(pkgname, id, &inst, &pkg);
3034 if (ret != LB_STATUS_SUCCESS) {
3038 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3039 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3040 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3041 struct script_info *script;
3043 script = instance_pd_script(inst);
3045 ret = LB_STATUS_ERROR_FAULT;
3049 script_handler_update_pointer(script, x, y, -1);
3050 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
3052 struct event_cbdata *cbdata;
3054 cbdata = malloc(sizeof(*cbdata));
3056 ret = LB_STATUS_ERROR_MEMORY;
3058 cbdata->inst = instance_ref(inst);
3059 cbdata->status = ret;
3061 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3062 (void)instance_unref(cbdata->inst);
3064 ret = LB_STATUS_ERROR_FAULT;
3066 ret = LB_STATUS_SUCCESS;
3071 ErrPrint("Unsupported package\n");
3072 ret = LB_STATUS_ERROR_INVALID;
3076 result = packet_create_reply(packet, "i", ret);
3078 ErrPrint("Failed to create a reply packet\n");
3084 static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
3086 struct packet *result;
3087 struct client_node *client;
3088 const char *pkgname;
3094 struct inst_info *inst = NULL;
3095 const struct pkg_info *pkg = NULL;
3097 client = client_find_by_rpc_handle(handle);
3099 ErrPrint("Client %d is not exists\n", pid);
3100 ret = LB_STATUS_ERROR_NOT_EXIST;
3104 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3106 ErrPrint("Invalid parameter\n");
3107 ret = LB_STATUS_ERROR_INVALID;
3111 ret = validate_request(pkgname, id, &inst, &pkg);
3112 if (ret != LB_STATUS_SUCCESS) {
3116 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3117 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3118 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3119 struct script_info *script;
3121 script = instance_pd_script(inst);
3123 ret = LB_STATUS_ERROR_FAULT;
3127 script_handler_update_pointer(script, x, y, 0);
3128 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
3130 struct event_cbdata *cbdata;
3132 cbdata = malloc(sizeof(*cbdata));
3134 ret = LB_STATUS_ERROR_MEMORY;
3136 cbdata->inst = instance_ref(inst);
3137 cbdata->status = ret;
3139 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3140 (void)instance_unref(cbdata->inst);
3142 ret = LB_STATUS_ERROR_FAULT;
3144 ret = LB_STATUS_SUCCESS;
3149 ErrPrint("Unsupported package\n");
3150 ret = LB_STATUS_ERROR_INVALID;
3154 result = packet_create_reply(packet, "i", ret);
3156 ErrPrint("Failed to create a reply packet\n");
3162 static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
3164 struct packet *result;
3165 struct client_node *client;
3166 const char *pkgname;
3170 struct inst_info *inst = NULL;
3171 const struct pkg_info *pkg = NULL;
3175 client = client_find_by_rpc_handle(handle);
3177 ErrPrint("Client %d is not exists\n", pid);
3178 ret = LB_STATUS_ERROR_NOT_EXIST;
3182 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3184 ErrPrint("Invalid parameter\n");
3185 ret = LB_STATUS_ERROR_INVALID;
3189 ret = validate_request(pkgname, id, &inst, &pkg);
3190 if (ret != LB_STATUS_SUCCESS) {
3194 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3195 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3196 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3197 struct script_info *script;
3199 script = instance_pd_script(inst);
3201 ret = LB_STATUS_ERROR_FAULT;
3205 script_handler_update_pointer(script, x, y, -1);
3206 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
3208 struct event_cbdata *cbdata;
3210 cbdata = malloc(sizeof(*cbdata));
3212 ret = LB_STATUS_ERROR_MEMORY;
3214 cbdata->inst = instance_ref(inst);
3215 cbdata->status = ret;
3217 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3218 (void)instance_unref(cbdata->inst);
3220 ret = LB_STATUS_ERROR_FAULT;
3222 ret = LB_STATUS_SUCCESS;
3227 ErrPrint("Unsupported package\n");
3228 ret = LB_STATUS_ERROR_INVALID;
3231 result = packet_create_reply(packet, "i", ret);
3233 ErrPrint("Failed to create a reply packet\n");
3239 static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct packet *packet)
3241 struct packet *result;
3242 struct client_node *client;
3243 const char *pkgname;
3249 struct inst_info *inst = NULL;
3250 const struct pkg_info *pkg = NULL;
3252 client = client_find_by_rpc_handle(handle);
3254 ErrPrint("Client %d is not exists\n", pid);
3255 ret = LB_STATUS_ERROR_NOT_EXIST;
3259 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3261 ErrPrint("Invalid parameter\n");
3262 ret = LB_STATUS_ERROR_INVALID;
3266 ret = validate_request(pkgname, id, &inst, &pkg);
3267 if (ret != LB_STATUS_SUCCESS) {
3271 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3272 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3273 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3274 struct script_info *script;
3276 script = instance_pd_script(inst);
3278 ret = LB_STATUS_ERROR_FAULT;
3282 script_handler_update_pointer(script, x, y, -1);
3283 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
3285 struct event_cbdata *cbdata;
3287 cbdata = malloc(sizeof(*cbdata));
3289 ret = LB_STATUS_ERROR_MEMORY;
3291 cbdata->inst = instance_ref(inst);
3292 cbdata->status = ret;
3294 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3295 (void)instance_unref(cbdata->inst);
3297 ret = LB_STATUS_ERROR_FAULT;
3299 ret = LB_STATUS_SUCCESS;
3304 ErrPrint("Unsupported package\n");
3305 ret = LB_STATUS_ERROR_INVALID;
3309 result = packet_create_reply(packet, "i", ret);
3311 ErrPrint("Failed to create a reply packet\n");
3317 static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
3319 struct packet *result;
3320 struct client_node *client;
3321 const char *pkgname;
3327 struct inst_info *inst = NULL;
3328 const struct pkg_info *pkg = NULL;
3330 client = client_find_by_rpc_handle(handle);
3332 ErrPrint("Client %d is not exists\n", pid);
3333 ret = LB_STATUS_ERROR_NOT_EXIST;
3337 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3339 ErrPrint("Invalid parameter\n");
3340 ret = LB_STATUS_ERROR_INVALID;
3344 ret = validate_request(pkgname, id, &inst, &pkg);
3345 if (ret != LB_STATUS_SUCCESS) {
3349 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3350 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3351 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3352 struct script_info *script;
3354 script = instance_pd_script(inst);
3356 ret = LB_STATUS_ERROR_FAULT;
3360 script_handler_update_pointer(script, x, y, -1);
3361 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
3363 struct event_cbdata *cbdata;
3365 cbdata = malloc(sizeof(*cbdata));
3367 ret = LB_STATUS_ERROR_MEMORY;
3369 cbdata->inst = instance_ref(inst);
3370 cbdata->status = ret;
3372 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3373 (void)instance_unref(cbdata->inst);
3375 ret = LB_STATUS_ERROR_FAULT;
3377 ret = LB_STATUS_SUCCESS;
3382 ErrPrint("Unsupported package\n");
3383 ret = LB_STATUS_ERROR_INVALID;
3387 result = packet_create_reply(packet, "i", ret);
3389 ErrPrint("Failed to create a reply packet\n");
3395 static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const struct packet *packet)
3397 struct packet *result;
3398 struct client_node *client;
3399 const char *pkgname;
3405 struct inst_info *inst = NULL;
3406 const struct pkg_info *pkg = NULL;
3408 client = client_find_by_rpc_handle(handle);
3410 ErrPrint("Client %d is not exists\n", pid);
3411 ret = LB_STATUS_ERROR_NOT_EXIST;
3415 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3417 ErrPrint("Invalid parameter\n");
3418 ret = LB_STATUS_ERROR_INVALID;
3422 ret = validate_request(pkgname, id, &inst, &pkg);
3423 if (ret != LB_STATUS_SUCCESS) {
3427 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3428 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3429 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3430 struct script_info *script;
3432 script = instance_pd_script(inst);
3434 ErrPrint("Script is not created yet\n");
3435 ret = LB_STATUS_ERROR_FAULT;
3439 script_handler_update_pointer(script, x, y, -1);
3440 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
3442 struct event_cbdata *cbdata;
3444 cbdata = malloc(sizeof(*cbdata));
3446 ErrPrint("Heap: %s\n", strerror(errno));
3447 ret = LB_STATUS_ERROR_MEMORY;
3449 cbdata->inst = instance_ref(inst);
3450 cbdata->status = ret;
3452 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3453 ErrPrint("Failed to add timer\n");
3454 (void)instance_unref(cbdata->inst);
3456 ret = LB_STATUS_ERROR_FAULT;
3458 ret = LB_STATUS_SUCCESS;
3462 DbgPrint("Returns: %d\n", ret);
3465 ErrPrint("Unsupported package\n");
3466 ret = LB_STATUS_ERROR_INVALID;
3470 result = packet_create_reply(packet, "i", ret);
3472 ErrPrint("Failed to create a reply packet\n");
3478 static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
3480 struct packet *result;
3481 struct client_node *client;
3482 const char *pkgname;
3488 struct inst_info *inst = NULL;
3489 const struct pkg_info *pkg = NULL;
3491 client = client_find_by_rpc_handle(handle);
3493 ErrPrint("Client %d is not exists\n", pid);
3494 ret = LB_STATUS_ERROR_NOT_EXIST;
3498 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3500 ErrPrint("Invalid parameter\n");
3501 ret = LB_STATUS_ERROR_INVALID;
3505 ret = validate_request(pkgname, id, &inst, &pkg);
3506 if (ret != LB_STATUS_SUCCESS) {
3510 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3511 ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3512 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3513 struct script_info *script;
3515 script = instance_pd_script(inst);
3517 ret = LB_STATUS_ERROR_FAULT;
3521 script_handler_update_pointer(script, x, y, -1);
3522 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
3524 struct event_cbdata *cbdata;
3526 cbdata = malloc(sizeof(*cbdata));
3528 ret = LB_STATUS_ERROR_MEMORY;
3530 cbdata->inst = instance_ref(inst);
3531 cbdata->status = ret;
3533 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3534 (void)instance_unref(cbdata->inst);
3536 ret = LB_STATUS_ERROR_FAULT;
3538 ret = LB_STATUS_SUCCESS;
3543 ErrPrint("Unsupported package\n");
3544 ret = LB_STATUS_ERROR_INVALID;
3548 result = packet_create_reply(packet, "i", ret);
3550 ErrPrint("Failed to create a reply packet\n");
3556 static struct packet *client_pd_key_focus_in(pid_t pid, int handle, const struct packet *packet)
3558 struct client_node *client;
3559 const char *pkgname;
3563 unsigned int keycode;
3564 struct inst_info *inst;
3565 const struct pkg_info *pkg;
3566 struct packet *result;
3568 client = client_find_by_rpc_handle(handle);
3570 ErrPrint("Client %d is not exists\n", pid);
3571 ret = LB_STATUS_ERROR_NOT_EXIST;
3575 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
3577 ErrPrint("Invalid parameter\n");
3578 ret = LB_STATUS_ERROR_INVALID;
3582 ret = validate_request(pkgname, id, &inst, &pkg);
3583 if (ret != LB_STATUS_SUCCESS) {
3587 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3588 ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
3589 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3590 struct script_info *script;
3592 script = instance_pd_script(inst);
3594 ret = LB_STATUS_ERROR_FAULT;
3598 script_handler_update_keycode(script, keycode);
3599 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_IN, timestamp);
3601 struct event_cbdata *cbdata;
3603 cbdata = malloc(sizeof(*cbdata));
3605 ret = LB_STATUS_ERROR_MEMORY;
3607 cbdata->inst = instance_ref(inst);
3608 cbdata->status = ret;
3610 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
3611 (void)instance_unref(cbdata->inst);
3613 ret = LB_STATUS_ERROR_FAULT;
3615 ret = LB_STATUS_SUCCESS;
3620 ErrPrint("Unsupported package\n");
3621 ret = LB_STATUS_ERROR_INVALID;
3625 result = packet_create_reply(packet, "i", ret);
3627 ErrPrint("Failed to create a reply packet\n");
3633 static struct packet *client_pd_key_focus_out(pid_t pid, int handle, const struct packet *packet)
3635 struct client_node *client;
3636 const char *pkgname;
3640 unsigned int keycode;
3641 struct inst_info *inst;
3642 const struct pkg_info *pkg;
3643 struct packet *result;
3645 client = client_find_by_rpc_handle(handle);
3647 ErrPrint("Client %d is not exists\n", pid);
3648 ret = LB_STATUS_ERROR_NOT_EXIST;
3652 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
3654 ErrPrint("Invalid parameter\n");
3655 ret = LB_STATUS_ERROR_INVALID;
3659 ret = validate_request(pkgname, id, &inst, &pkg);
3660 if (ret != LB_STATUS_SUCCESS) {
3664 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3665 ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
3666 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3667 struct script_info *script;
3669 script = instance_pd_script(inst);
3671 ret = LB_STATUS_ERROR_FAULT;
3675 script_handler_update_keycode(script, keycode);
3676 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_OUT, timestamp);
3678 struct event_cbdata *cbdata;
3680 cbdata = malloc(sizeof(*cbdata));
3682 ret = LB_STATUS_ERROR_MEMORY;
3684 cbdata->inst = instance_ref(inst);
3685 cbdata->status = ret;
3687 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
3688 (void)instance_unref(cbdata->inst);
3690 ret = LB_STATUS_ERROR_FAULT;
3692 ret = LB_STATUS_SUCCESS;
3697 ErrPrint("Unsupported package\n");
3698 ret = LB_STATUS_ERROR_INVALID;
3702 result = packet_create_reply(packet, "i", ret);
3704 ErrPrint("Failed to create a reply packet\n");
3710 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
3712 struct client_node *client;
3713 const char *pkgname;
3717 unsigned int keycode;
3718 struct inst_info *inst;
3719 const struct pkg_info *pkg;
3720 struct packet *result;
3722 client = client_find_by_rpc_handle(handle);
3724 ErrPrint("Client %d is not exists\n", pid);
3725 ret = LB_STATUS_ERROR_NOT_EXIST;
3729 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
3731 ErrPrint("Invalid parameter\n");
3732 ret = LB_STATUS_ERROR_INVALID;
3736 ret = validate_request(pkgname, id, &inst, &pkg);
3737 if (ret != LB_STATUS_SUCCESS) {
3741 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3742 ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
3743 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3744 struct script_info *script;
3746 script = instance_pd_script(inst);
3748 ret = LB_STATUS_ERROR_FAULT;
3752 script_handler_update_keycode(script, keycode);
3753 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
3755 struct event_cbdata *cbdata;
3757 cbdata = malloc(sizeof(*cbdata));
3759 ret = LB_STATUS_ERROR_MEMORY;
3761 cbdata->inst = instance_ref(inst);
3762 cbdata->status = ret;
3764 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
3765 (void)instance_unref(cbdata->inst);
3767 ret = LB_STATUS_ERROR_FAULT;
3769 ret = LB_STATUS_SUCCESS;
3774 ErrPrint("Unsupported package\n");
3775 ret = LB_STATUS_ERROR_INVALID;
3779 result = packet_create_reply(packet, "i", ret);
3781 ErrPrint("Failed to create a reply packet\n");
3787 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
3789 struct client_node *client;
3793 client = client_find_by_rpc_handle(handle);
3795 ErrPrint("Client %d is paused - manually reported\n", pid);
3796 ret = LB_STATUS_ERROR_NOT_EXIST;
3800 ret = packet_get(packet, "d", ×tamp);
3802 ErrPrint("Invalid parameter\n");
3803 ret = LB_STATUS_ERROR_INVALID;
3808 DbgPrint("XMONITOR enabled. ignore client paused request\n");
3810 xmonitor_pause(client);
3817 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
3819 struct client_node *client;
3823 client = client_find_by_rpc_handle(handle);
3825 ErrPrint("Client %d is not exists\n", pid);
3829 ret = packet_get(packet, "d", ×tamp);
3831 ErrPrint("Invalid parameter\n");
3836 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
3838 xmonitor_resume(client);
3845 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
3847 struct client_node *client;
3848 const char *pkgname;
3852 unsigned int keycode;
3853 struct inst_info *inst;
3854 const struct pkg_info *pkg;
3855 struct packet *result;
3857 client = client_find_by_rpc_handle(handle);
3859 ErrPrint("Client %d is not exists\n", pid);
3860 ret = LB_STATUS_ERROR_NOT_EXIST;
3864 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
3866 ErrPrint("Invalid parameter\n");
3867 ret = LB_STATUS_ERROR_INVALID;
3871 ret = validate_request(pkgname, id, &inst, &pkg);
3872 if (ret != LB_STATUS_SUCCESS) {
3876 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
3877 ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
3878 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
3879 struct script_info *script;
3881 script = instance_pd_script(inst);
3883 ret = LB_STATUS_ERROR_FAULT;
3887 script_handler_update_keycode(script, keycode);
3888 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
3890 struct event_cbdata *cbdata;
3892 cbdata = malloc(sizeof(*cbdata));
3894 ret = LB_STATUS_ERROR_MEMORY;
3896 cbdata->inst = instance_ref(inst);
3897 cbdata->status = ret;
3899 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
3900 (void)instance_unref(cbdata->inst);
3902 ret = LB_STATUS_ERROR_FAULT;
3904 ret = LB_STATUS_SUCCESS;
3909 ErrPrint("Unsupported package\n");
3910 ret = LB_STATUS_ERROR_INVALID;
3914 result = packet_create_reply(packet, "i", ret);
3916 ErrPrint("Failed to create a reply packet\n");
3922 static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
3924 struct packet *result;
3925 struct client_node *client;
3926 const char *pkgname;
3932 struct inst_info *inst = NULL;
3933 const struct pkg_info *pkg = NULL;
3935 client = client_find_by_rpc_handle(handle);
3937 ErrPrint("Client %d is not exists\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) {
3954 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3955 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
3956 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3957 struct script_info *script;
3959 script = instance_lb_script(inst);
3961 ret = LB_STATUS_ERROR_FAULT;
3965 script_handler_update_pointer(script, x, y, -1);
3966 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
3968 struct event_cbdata *cbdata;
3970 cbdata = malloc(sizeof(*cbdata));
3972 ret = LB_STATUS_ERROR_MEMORY;
3974 cbdata->inst = instance_ref(inst);
3975 cbdata->status = ret;
3977 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
3978 (void)instance_unref(cbdata->inst);
3980 ret = LB_STATUS_ERROR_FAULT;
3982 ret = LB_STATUS_SUCCESS;
3987 ErrPrint("Unsupported package\n");
3988 ret = LB_STATUS_ERROR_INVALID;
3992 result = packet_create_reply(packet, "i", ret);
3994 ErrPrint("Failed to create a reply packet\n");
4000 static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
4002 struct packet *result;
4003 struct client_node *client;
4004 const char *pkgname;
4010 struct inst_info *inst;
4011 const struct pkg_info *pkg;
4013 client = client_find_by_rpc_handle(handle);
4015 ErrPrint("Client %d is not exists\n", pid);
4016 ret = LB_STATUS_ERROR_NOT_EXIST;
4020 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4022 ErrPrint("Parameter is not matched\n");
4023 ret = LB_STATUS_ERROR_INVALID;
4027 ret = validate_request(pkgname, id, &inst, &pkg);
4028 if (ret != LB_STATUS_SUCCESS) {
4032 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4033 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4034 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4035 struct script_info *script;
4037 script = instance_lb_script(inst);
4039 ret = LB_STATUS_ERROR_FAULT;
4043 script_handler_update_pointer(script, x, y, -1);
4044 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
4046 struct event_cbdata *cbdata;
4048 cbdata = malloc(sizeof(*cbdata));
4050 ret = LB_STATUS_ERROR_MEMORY;
4052 cbdata->inst = instance_ref(inst);
4053 cbdata->status = ret;
4055 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4056 (void)instance_unref(cbdata->inst);
4058 ret = LB_STATUS_ERROR_FAULT;
4060 ret = LB_STATUS_SUCCESS;
4065 ErrPrint("Unsupported package\n");
4066 ret = LB_STATUS_ERROR_INVALID;
4070 result = packet_create_reply(packet, "i", ret);
4072 ErrPrint("Failed to create a reply packet\n");
4078 static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet)
4080 struct packet *result;
4081 struct client_node *client;
4082 const char *pkgname;
4088 struct inst_info *inst = NULL;
4089 const struct pkg_info *pkg = NULL;
4091 client = client_find_by_rpc_handle(handle);
4093 ErrPrint("Client %d is not exists\n", pid);
4094 ret = LB_STATUS_ERROR_NOT_EXIST;
4098 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4100 ErrPrint("Parameter is not matched\n");
4101 ret = LB_STATUS_ERROR_INVALID;
4105 ret = validate_request(pkgname, id, &inst, &pkg);
4106 if (ret != LB_STATUS_SUCCESS) {
4110 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4111 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4112 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4113 struct script_info *script;
4115 script = instance_lb_script(inst);
4117 ret = LB_STATUS_ERROR_FAULT;
4121 script_handler_update_pointer(script, x, y, -1);
4122 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
4124 struct event_cbdata *cbdata;
4126 cbdata = malloc(sizeof(*cbdata));
4128 ret = LB_STATUS_ERROR_MEMORY;
4130 cbdata->inst = instance_ref(inst);
4131 cbdata->status = ret;
4133 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4134 (void)instance_unref(cbdata->inst);
4136 ret = LB_STATUS_ERROR_FAULT;
4138 ret = LB_STATUS_SUCCESS;
4143 ErrPrint("Unsupported package\n");
4144 ret = LB_STATUS_ERROR_INVALID;
4148 result = packet_create_reply(packet, "i", ret);
4150 ErrPrint("Failed to create a reply packet\n");
4156 static struct packet *client_lb_access_action_up(pid_t pid, int handle, const struct packet *packet)
4158 struct packet *result;
4159 struct client_node *client;
4160 const char *pkgname;
4164 struct inst_info *inst = NULL;
4165 const struct pkg_info *pkg = NULL;
4169 client = client_find_by_rpc_handle(handle);
4171 ErrPrint("Client %d is not exist\n", pid);
4172 ret = LB_STATUS_ERROR_NOT_EXIST;
4176 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4178 ErrPrint("Parameter is not matched\n");
4179 ret = LB_STATUS_ERROR_INVALID;
4183 ret = validate_request(pkgname, id, &inst, &pkg);
4184 if (ret != LB_STATUS_SUCCESS) {
4188 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4189 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4191 * Enen if it fails to send packet,
4192 * The packet will be unref'd
4193 * So we don't need to check the ret value.
4195 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4196 struct script_info *script;
4198 script = instance_lb_script(inst);
4200 ErrPrint("Instance has no script\n");
4201 ret = LB_STATUS_ERROR_FAULT;
4205 script_handler_update_pointer(script, x, y, 0);
4206 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
4208 struct event_cbdata *cbdata;
4210 cbdata = malloc(sizeof(*cbdata));
4212 ret = LB_STATUS_ERROR_MEMORY;
4214 cbdata->inst = instance_ref(inst);
4215 cbdata->status = ret;
4217 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4218 (void)instance_unref(cbdata->inst);
4220 ret = LB_STATUS_ERROR_FAULT;
4222 ret = LB_STATUS_SUCCESS;
4227 ErrPrint("Unsupported package\n");
4228 ret = LB_STATUS_ERROR_INVALID;
4232 result = packet_create_reply(packet, "i", ret);
4234 ErrPrint("Failed to create a reply packet\n");
4240 static struct packet *client_lb_access_action_down(pid_t pid, int handle, const struct packet *packet)
4242 struct packet *result;
4243 struct client_node *client;
4244 const char *pkgname;
4248 struct inst_info *inst;
4249 const struct pkg_info *pkg;
4253 client = client_find_by_rpc_handle(handle);
4255 ErrPrint("Client %d is not exist\n", pid);
4256 ret = LB_STATUS_ERROR_NOT_EXIST;
4260 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4262 ErrPrint("Parameter is not matched\n");
4263 ret = LB_STATUS_ERROR_INVALID;
4267 ret = validate_request(pkgname, id, &inst, &pkg);
4268 if (ret != LB_STATUS_SUCCESS) {
4272 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4273 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4275 * Enen if it fails to send packet,
4276 * The packet will be unref'd
4277 * So we don't need to check the ret value.
4279 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4280 struct script_info *script;
4282 script = instance_lb_script(inst);
4284 ErrPrint("Instance has no script\n");
4285 ret = LB_STATUS_ERROR_FAULT;
4289 script_handler_update_pointer(script, x, y, 1);
4290 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
4292 struct event_cbdata *cbdata;
4294 cbdata = malloc(sizeof(*cbdata));
4296 ret = LB_STATUS_ERROR_MEMORY;
4298 cbdata->inst = instance_ref(inst);
4299 cbdata->status = ret;
4301 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4302 (void)instance_unref(cbdata->inst);
4304 ret = LB_STATUS_ERROR_FAULT;
4306 ret = LB_STATUS_SUCCESS;
4311 ErrPrint("Unsupported package\n");
4312 ret = LB_STATUS_ERROR_INVALID;
4316 result = packet_create_reply(packet, "i", ret);
4318 ErrPrint("Failed to create a reply packet\n");
4324 static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
4326 struct packet *result;
4327 struct client_node *client;
4328 const char *pkgname;
4334 struct inst_info *inst = NULL;
4335 const struct pkg_info *pkg = NULL;
4337 client = client_find_by_rpc_handle(handle);
4339 ErrPrint("Client %d is not exists\n", pid);
4340 ret = LB_STATUS_ERROR_NOT_EXIST;
4344 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4346 ErrPrint("Parameter is not matched\n");
4347 ret = LB_STATUS_ERROR_INVALID;
4351 ret = validate_request(pkgname, id, &inst, &pkg);
4352 if (ret != LB_STATUS_SUCCESS) {
4356 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4357 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4358 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4359 struct script_info *script;
4361 script = instance_lb_script(inst);
4363 ret = LB_STATUS_ERROR_FAULT;
4367 script_handler_update_pointer(script, x, y, -1);
4368 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
4370 struct event_cbdata *cbdata;
4372 cbdata = malloc(sizeof(*cbdata));
4374 ret = LB_STATUS_ERROR_MEMORY;
4376 cbdata->inst = instance_ref(inst);
4377 cbdata->status = ret;
4379 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4380 (void)instance_unref(cbdata->inst);
4382 ret = LB_STATUS_ERROR_FAULT;
4384 ret = LB_STATUS_SUCCESS;
4389 ErrPrint("Unsupported package\n");
4390 ret = LB_STATUS_ERROR_INVALID;
4394 result = packet_create_reply(packet, "i", ret);
4396 ErrPrint("Failed to create a reply packet\n");
4402 static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
4404 struct packet *result;
4405 struct client_node *client;
4406 const char *pkgname;
4410 struct inst_info *inst = NULL;
4411 const struct pkg_info *pkg = NULL;
4415 client = client_find_by_rpc_handle(handle);
4417 ErrPrint("Client %d is not exist\n", pid);
4418 ret = LB_STATUS_ERROR_NOT_EXIST;
4422 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4424 ErrPrint("Parameter is not matched\n");
4425 ret = LB_STATUS_ERROR_INVALID;
4429 ret = validate_request(pkgname, id, &inst, &pkg);
4430 if (ret != LB_STATUS_SUCCESS) {
4434 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4435 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4437 * Enen if it fails to send packet,
4438 * The packet will be unref'd
4439 * So we don't need to check the ret value.
4441 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4442 struct script_info *script;
4444 script = instance_lb_script(inst);
4446 ErrPrint("Instance has no script\n");
4447 ret = LB_STATUS_ERROR_FAULT;
4451 script_handler_update_pointer(script, x, y, 1);
4452 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
4454 struct event_cbdata *cbdata;
4456 cbdata = malloc(sizeof(*cbdata));
4458 ret = LB_STATUS_ERROR_MEMORY;
4460 cbdata->inst = instance_ref(inst);
4461 cbdata->status = ret;
4463 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4464 (void)instance_unref(cbdata->inst);
4466 ret = LB_STATUS_ERROR_FAULT;
4468 ret = LB_STATUS_SUCCESS;
4473 ErrPrint("Unsupported package\n");
4474 ret = LB_STATUS_ERROR_INVALID;
4478 result = packet_create_reply(packet, "i", ret);
4480 ErrPrint("Failed to create a reply packet\n");
4486 static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
4488 struct packet *result;
4489 struct client_node *client;
4490 const char *pkgname;
4494 struct inst_info *inst = NULL;
4495 const struct pkg_info *pkg = NULL;
4499 client = client_find_by_rpc_handle(handle);
4501 ErrPrint("Client %d is not exist\n", pid);
4502 ret = LB_STATUS_ERROR_NOT_EXIST;
4506 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4508 ErrPrint("Parameter is not matched\n");
4509 ret = LB_STATUS_ERROR_INVALID;
4513 ret = validate_request(pkgname, id, &inst, &pkg);
4514 if (ret != LB_STATUS_SUCCESS) {
4518 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4519 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4521 * Enen if it fails to send packet,
4522 * The packet will be unref'd
4523 * So we don't need to check the ret value.
4525 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4526 struct script_info *script;
4528 script = instance_lb_script(inst);
4530 ErrPrint("Instance has no script\n");
4531 ret = LB_STATUS_ERROR_FAULT;
4535 script_handler_update_pointer(script, x, y, -1);
4536 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
4538 struct event_cbdata *cbdata;
4540 cbdata = malloc(sizeof(*cbdata));
4542 ret = LB_STATUS_ERROR_MEMORY;
4544 cbdata->inst = instance_ref(inst);
4545 cbdata->status = ret;
4547 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4548 (void)instance_unref(cbdata->inst);
4550 ret = LB_STATUS_ERROR_FAULT;
4552 ret = LB_STATUS_SUCCESS;
4557 ErrPrint("Unsupported package\n");
4558 ret = LB_STATUS_ERROR_INVALID;
4562 result = packet_create_reply(packet, "i", ret);
4564 ErrPrint("Failed to create a reply packet\n");
4570 static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
4572 struct packet *result;
4573 struct client_node *client;
4574 const char *pkgname;
4578 struct inst_info *inst;
4579 const struct pkg_info *pkg;
4583 client = client_find_by_rpc_handle(handle);
4585 ErrPrint("Client %d is not exist\n", pid);
4586 ret = LB_STATUS_ERROR_NOT_EXIST;
4590 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4592 ErrPrint("Parameter is not matched\n");
4593 ret = LB_STATUS_ERROR_INVALID;
4597 ret = validate_request(pkgname, id, &inst, &pkg);
4598 if (ret != LB_STATUS_SUCCESS) {
4602 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4603 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4605 * Enen if it fails to send packet,
4606 * The packet will be unref'd
4607 * So we don't need to check the ret value.
4609 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4610 struct script_info *script;
4612 script = instance_lb_script(inst);
4614 ErrPrint("Instance has no script\n");
4615 ret = LB_STATUS_ERROR_FAULT;
4619 script_handler_update_pointer(script, x, y, 0);
4620 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
4622 struct event_cbdata *cbdata;
4624 cbdata = malloc(sizeof(*cbdata));
4626 ret = LB_STATUS_ERROR_MEMORY;
4628 cbdata->inst = instance_ref(inst);
4629 cbdata->status = ret;
4631 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4632 (void)instance_unref(cbdata->inst);
4634 ret = LB_STATUS_ERROR_FAULT;
4636 ret = LB_STATUS_SUCCESS;
4641 ErrPrint("Unsupported package\n");
4642 ret = LB_STATUS_ERROR_INVALID;
4646 result = packet_create_reply(packet, "i", ret);
4648 ErrPrint("Failed to create a reply packet\n");
4654 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
4656 struct packet *result;
4657 struct client_node *client;
4658 const char *pkgname;
4664 struct inst_info *inst = NULL;
4665 const struct pkg_info *pkg = NULL;
4667 client = client_find_by_rpc_handle(handle);
4669 ErrPrint("Client %d is not exists\n", pid);
4670 ret = LB_STATUS_ERROR_NOT_EXIST;
4674 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
4676 ErrPrint("Parameter is not matched\n");
4677 ret = LB_STATUS_ERROR_INVALID;
4681 ret = validate_request(pkgname, id, &inst, &pkg);
4682 if (ret != LB_STATUS_SUCCESS) {
4686 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4687 ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
4688 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4689 struct script_info *script;
4691 script = instance_lb_script(inst);
4693 ErrPrint("Instance has no script\n");
4694 ret = LB_STATUS_ERROR_FAULT;
4698 script_handler_update_pointer(script, x, y, -1);
4699 ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
4701 struct event_cbdata *cbdata;
4703 cbdata = malloc(sizeof(*cbdata));
4705 ret = LB_STATUS_ERROR_MEMORY;
4707 cbdata->inst = instance_ref(inst);
4708 cbdata->status = ret;
4710 if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
4711 (void)instance_unref(cbdata->inst);
4713 ret = LB_STATUS_ERROR_FAULT;
4715 ret = LB_STATUS_SUCCESS;
4720 ErrPrint("Unsupported package\n");
4721 ret = LB_STATUS_ERROR_INVALID;
4725 result = packet_create_reply(packet, "i", ret);
4727 ErrPrint("Failed to create a reply packet\n");
4733 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
4735 struct client_node *client;
4736 const char *pkgname;
4740 unsigned int keycode;
4741 struct inst_info *inst;
4742 const struct pkg_info *pkg;
4743 struct packet *result;
4745 client = client_find_by_rpc_handle(handle);
4747 ErrPrint("Client %d is not exists\n", pid);
4748 ret = LB_STATUS_ERROR_NOT_EXIST;
4752 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
4754 ErrPrint("Parameter is not matched\n");
4755 ret = LB_STATUS_ERROR_INVALID;
4759 ret = validate_request(pkgname, id, &inst, &pkg);
4760 if (ret != LB_STATUS_SUCCESS) {
4764 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4765 ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
4766 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4767 struct script_info *script;
4769 script = instance_lb_script(inst);
4771 ret = LB_STATUS_ERROR_FAULT;
4775 script_handler_update_keycode(script, keycode);
4776 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
4778 struct event_cbdata *cbdata;
4780 cbdata = malloc(sizeof(*cbdata));
4782 ret = LB_STATUS_ERROR_MEMORY;
4784 cbdata->inst = instance_ref(inst);
4785 cbdata->status = ret;
4787 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
4788 (void)instance_unref(cbdata->inst);
4790 ret = LB_STATUS_ERROR_FAULT;
4792 ret = LB_STATUS_SUCCESS;
4797 ErrPrint("Unsupported package\n");
4798 ret = LB_STATUS_ERROR_INVALID;
4802 result = packet_create_reply(packet, "i", ret);
4804 ErrPrint("Failed to create a reply packet\n");
4810 static struct packet *client_lb_key_focus_in(pid_t pid, int handle, const struct packet *packet)
4812 struct client_node *client;
4813 const char *pkgname;
4817 unsigned int keycode;
4818 struct inst_info *inst;
4819 const struct pkg_info *pkg;
4820 struct packet *result;
4822 client = client_find_by_rpc_handle(handle);
4824 ErrPrint("Client %d is not exists\n", pid);
4825 ret = LB_STATUS_ERROR_NOT_EXIST;
4829 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
4831 ErrPrint("Parameter is not matched\n");
4832 ret = LB_STATUS_ERROR_INVALID;
4836 ret = validate_request(pkgname, id, &inst, &pkg);
4837 if (ret != LB_STATUS_SUCCESS) {
4841 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4842 ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
4843 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4844 struct script_info *script;
4846 script = instance_lb_script(inst);
4848 ret = LB_STATUS_ERROR_FAULT;
4852 script_handler_update_keycode(script, keycode);
4853 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_IN, timestamp);
4855 struct event_cbdata *cbdata;
4857 cbdata = malloc(sizeof(*cbdata));
4859 ret = LB_STATUS_ERROR_MEMORY;
4861 cbdata->inst = instance_ref(inst);
4862 cbdata->status = ret;
4864 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
4865 (void)instance_unref(cbdata->inst);
4867 ret = LB_STATUS_ERROR_FAULT;
4869 ret = LB_STATUS_SUCCESS;
4874 ErrPrint("Unsupported package\n");
4875 ret = LB_STATUS_ERROR_INVALID;
4879 result = packet_create_reply(packet, "i", ret);
4881 ErrPrint("Failed to create a reply packet\n");
4887 static struct packet *client_lb_key_focus_out(pid_t pid, int handle, const struct packet *packet)
4889 struct client_node *client;
4890 const char *pkgname;
4894 unsigned int keycode;
4895 struct inst_info *inst;
4896 const struct pkg_info *pkg;
4897 struct packet *result;
4899 client = client_find_by_rpc_handle(handle);
4901 ErrPrint("Client %d is not exists\n", pid);
4902 ret = LB_STATUS_ERROR_NOT_EXIST;
4906 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
4908 ErrPrint("Parameter is not matched\n");
4909 ret = LB_STATUS_ERROR_INVALID;
4913 ret = validate_request(pkgname, id, &inst, &pkg);
4914 if (ret != LB_STATUS_SUCCESS) {
4918 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4919 ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
4920 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4921 struct script_info *script;
4923 script = instance_lb_script(inst);
4925 ret = LB_STATUS_ERROR_FAULT;
4929 script_handler_update_keycode(script, keycode);
4930 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_OUT, timestamp);
4932 struct event_cbdata *cbdata;
4934 cbdata = malloc(sizeof(*cbdata));
4936 ret = LB_STATUS_ERROR_MEMORY;
4938 cbdata->inst = instance_ref(inst);
4939 cbdata->status = ret;
4941 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
4942 (void)instance_unref(cbdata->inst);
4944 ret = LB_STATUS_ERROR_FAULT;
4946 ret = LB_STATUS_SUCCESS;
4951 ErrPrint("Unsupported package\n");
4952 ret = LB_STATUS_ERROR_INVALID;
4956 result = packet_create_reply(packet, "i", ret);
4958 ErrPrint("Failed to create a reply packet\n");
4964 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
4966 struct client_node *client;
4967 const char *pkgname;
4971 unsigned int keycode;
4972 struct inst_info *inst;
4973 const struct pkg_info *pkg;
4974 struct packet *result;
4976 client = client_find_by_rpc_handle(handle);
4978 ErrPrint("Client %d is not exists\n", pid);
4979 ret = LB_STATUS_ERROR_NOT_EXIST;
4983 ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
4985 ErrPrint("Parameter is not matched\n");
4986 ret = LB_STATUS_ERROR_INVALID;
4990 ret = validate_request(pkgname, id, &inst, &pkg);
4991 if (ret != LB_STATUS_SUCCESS) {
4995 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4996 ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
4997 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
4998 struct script_info *script;
5000 script = instance_lb_script(inst);
5002 ret = LB_STATUS_ERROR_FAULT;
5006 script_handler_update_keycode(script, keycode);
5007 ret = script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
5009 struct event_cbdata *cbdata;
5011 cbdata = malloc(sizeof(*cbdata));
5013 ret = LB_STATUS_ERROR_MEMORY;
5015 cbdata->inst = instance_ref(inst);
5016 cbdata->status = ret;
5018 if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
5019 (void)instance_unref(cbdata->inst);
5021 ret = LB_STATUS_ERROR_FAULT;
5023 ret = LB_STATUS_SUCCESS;
5028 ErrPrint("Unsupported package\n");
5029 ret = LB_STATUS_ERROR_INVALID;
5033 result = packet_create_reply(packet, "i", ret);
5035 ErrPrint("Failed to create a reply packet\n");
5041 static int release_pixmap_cb(struct client_node *client, void *canvas)
5043 DbgPrint("Forcely unref the \"buffer\"\n");
5044 buffer_handler_pixmap_unref(canvas);
5045 return -1; /* Delete this callback */
5048 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 */
5050 struct packet *result;
5051 const char *pkgname;
5053 struct client_node *client;
5054 struct inst_info *inst;
5058 struct buffer_info *buffer;
5060 client = client_find_by_rpc_handle(handle);
5062 ErrPrint("Client %d is not exists\n", pid);
5063 ret = LB_STATUS_ERROR_INVALID;
5067 ret = packet_get(packet, "ss", &pkgname, &id);
5069 ErrPrint("Parameter is not matched\n");
5070 ret = LB_STATUS_ERROR_INVALID;
5074 ret = validate_request(pkgname, id, &inst, NULL);
5075 if (ret != LB_STATUS_SUCCESS) {
5079 buffer = instance_lb_buffer(inst);
5081 struct script_info *script_info;
5083 script_info = instance_lb_script(inst);
5085 ErrPrint("Unable to get LB buffer: %s\n", id);
5086 ret = LB_STATUS_ERROR_FAULT;
5090 buffer = script_handler_buffer_info(script_info);
5092 ErrPrint("Unable to get buffer_info: %s\n", id);
5093 ret = LB_STATUS_ERROR_FAULT;
5098 buf_ptr = buffer_handler_pixmap_ref(buffer);
5100 ErrPrint("Failed to ref pixmap\n");
5101 ret = LB_STATUS_ERROR_FAULT;
5105 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
5107 ErrPrint("Failed to add a new client deactivate callback\n");
5108 buffer_handler_pixmap_unref(buf_ptr);
5110 pixmap = buffer_handler_pixmap(buffer);
5111 ret = LB_STATUS_SUCCESS;
5115 result = packet_create_reply(packet, "ii", pixmap, ret);
5117 ErrPrint("Failed to create a reply packet\n");
5123 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
5125 const char *pkgname;
5127 struct client_node *client;
5132 client = client_find_by_rpc_handle(handle);
5134 ErrPrint("Client %d is not exists\n", pid);
5138 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
5140 ErrPrint("Parameter is not matched\n");
5144 ret = validate_request(pkgname, id, NULL, NULL);
5145 if (ret != LB_STATUS_SUCCESS) {
5146 DbgPrint("It seems that the instance is already deleted: %s\n", id);
5149 buf_ptr = buffer_handler_pixmap_find(pixmap);
5151 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
5155 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
5156 buffer_handler_pixmap_unref(buf_ptr);
5160 /*! \note No reply packet */
5164 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 */
5166 struct packet *result;
5167 const char *pkgname;
5169 struct client_node *client;
5170 struct inst_info *inst;
5174 struct buffer_info *buffer;
5176 client = client_find_by_rpc_handle(handle);
5178 ret = LB_STATUS_ERROR_INVALID;
5179 ErrPrint("Client %d is not exists\n", pid);
5183 ret = packet_get(packet, "ss", &pkgname, &id);
5185 ret = LB_STATUS_ERROR_INVALID;
5186 ErrPrint("Parameter is not matched\n");
5190 ret = validate_request(pkgname, id, &inst, NULL);
5191 if (ret != LB_STATUS_SUCCESS) {
5195 if (instance_get_data(inst, PD_RESIZE_MONITOR_TAG)) {
5196 ret = LB_STATUS_ERROR_BUSY;
5200 buffer = instance_pd_buffer(inst);
5202 struct script_info *script_info;
5204 script_info = instance_pd_script(inst);
5206 ErrPrint("Unable to get LB buffer: %s\n", id);
5207 ret = LB_STATUS_ERROR_FAULT;
5211 buffer = script_handler_buffer_info(script_info);
5213 ErrPrint("Unable to get buffer_info: %s\n", id);
5214 ret = LB_STATUS_ERROR_FAULT;
5219 buf_ptr = buffer_handler_pixmap_ref(buffer);
5221 ErrPrint("Failed to ref pixmap\n");
5222 ret = LB_STATUS_ERROR_FAULT;
5226 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
5228 ErrPrint("Failed to add a new client deactivate callback\n");
5229 buffer_handler_pixmap_unref(buf_ptr);
5231 pixmap = buffer_handler_pixmap(buffer);
5232 ret = LB_STATUS_SUCCESS;
5236 result = packet_create_reply(packet, "ii", pixmap, ret);
5238 ErrPrint("Failed to create a reply packet\n");
5244 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
5246 const char *pkgname;
5248 struct client_node *client;
5253 client = client_find_by_rpc_handle(handle);
5255 ErrPrint("Client %d is not exists\n", pid);
5259 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
5261 ErrPrint("Parameter is not matched\n");
5265 ret = validate_request(pkgname, id, NULL, NULL);
5266 if (ret != LB_STATUS_SUCCESS) {
5267 DbgPrint("It seems that the instance is already deleted: %s\n", id);
5270 buf_ptr = buffer_handler_pixmap_find(pixmap);
5272 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
5276 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
5277 buffer_handler_pixmap_unref(buf_ptr);
5281 /*! \note No reply packet */
5285 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
5287 struct client_node *client;
5288 struct packet *result;
5289 const char *pkgname;
5293 struct inst_info *inst;
5295 client = client_find_by_rpc_handle(handle);
5297 ErrPrint("Client %d is not exists\n", pid);
5298 ret = LB_STATUS_ERROR_NOT_EXIST;
5303 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
5305 ErrPrint("Parameter is not matched\n");
5306 ret = LB_STATUS_ERROR_INVALID;
5311 ret = validate_request(pkgname, id, &inst, NULL);
5312 if (ret == (int)LB_STATUS_SUCCESS) {
5313 ret = instance_set_pinup(inst, pinup);
5317 result = packet_create_reply(packet, "i", ret);
5319 ErrPrint("Failed to create a packet\n");
5325 static Eina_Bool lazy_pd_created_cb(void *inst)
5327 struct pkg_info *pkg;
5329 if (!instance_del_data(inst, LAZY_PD_OPEN_TAG)) {
5330 ErrPrint("lazy,pd,open is already deleted.\n");
5331 return ECORE_CALLBACK_CANCEL;
5334 pkg = instance_package(inst);
5336 struct slave_node *slave;
5338 slave = package_slave(pkg);
5340 slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_script_cb, inst);
5345 * After unref instance first,
5346 * if the instance is not destroyed, try to notify the created PD event to the client.
5348 if (instance_unref(inst)) {
5350 ret = instance_client_pd_created(inst, LB_STATUS_SUCCESS);
5352 DbgPrint("Send PD Create event (%d) to client\n", ret);
5356 return ECORE_CALLBACK_CANCEL;
5359 static Eina_Bool lazy_pd_destroyed_cb(void *inst)
5361 struct pkg_info *pkg;
5362 struct slave_node *slave;
5364 if (!instance_del_data(inst, LAZY_PD_CLOSE_TAG)) {
5365 ErrPrint("lazy,pd,close is already deleted.\n");
5366 return ECORE_CALLBACK_CANCEL;
5369 pkg = instance_package(inst);
5371 slave = package_slave(pkg);
5373 if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
5374 DbgPrint("Delete script type close callback\n");
5375 (void)slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_script_cb, inst);
5376 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5377 DbgPrint("Delete buffer type close callback\n");
5378 (void)slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
5383 if (instance_unref(inst)) {
5387 * If the instance is not deleted, we should send pd-destroy event from here.
5389 ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
5391 ErrPrint("Failed sending PD Destroy event (%d)\n", ret);
5395 return ECORE_CALLBACK_CANCEL;
5398 static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
5400 struct client_node *client;
5401 struct inst_info *inst;
5402 const struct pkg_info *pkg;
5403 const char *pkgname;
5409 client = client_find_by_rpc_handle(handle);
5411 ErrPrint("Client %d is not exists\n", pid);
5412 ret = LB_STATUS_ERROR_NOT_EXIST;
5416 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
5418 ErrPrint("Parameter is not correct\n");
5419 ret = LB_STATUS_ERROR_INVALID;
5423 ret = validate_request(pkgname, id, &inst, &pkg);
5424 if (ret != LB_STATUS_SUCCESS) {
5428 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5429 instance_slave_set_pd_pos(inst, x, y);
5430 ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
5431 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
5435 instance_slave_set_pd_pos(inst, x, y);
5436 ix = x * instance_pd_width(inst);
5437 iy = y * instance_pd_height(inst);
5438 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
5439 ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
5441 ErrPrint("Invalid PD type\n");
5442 ret = LB_STATUS_ERROR_INVALID;
5445 DbgPrint("Update PD position: %d\n", ret);
5449 static Eina_Bool pd_open_monitor_cb(void *inst)
5451 struct pkg_info *pkg;
5453 pkg = instance_package(inst);
5455 struct slave_node *slave;
5457 slave = package_slave(pkg);
5459 slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst);
5463 (void)instance_slave_close_pd(inst, instance_pd_owner(inst), LB_CLOSE_PD_TIMEOUT);
5464 (void)instance_client_pd_created(inst, LB_STATUS_ERROR_TIMEOUT);
5465 (void)instance_del_data(inst, PD_OPEN_MONITOR_TAG);
5466 (void)instance_unref(inst);
5467 ErrPrint("PD Open request is timed-out (%lf)\n", PD_REQUEST_TIMEOUT);
5468 return ECORE_CALLBACK_CANCEL;
5471 static Eina_Bool pd_close_monitor_cb(void *inst)
5473 struct pkg_info *pkg;
5475 pkg = instance_package(inst);
5477 struct slave_node *slave;
5479 slave = package_slave(pkg);
5481 slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
5485 (void)instance_client_pd_destroyed(inst, LB_STATUS_ERROR_TIMEOUT);
5486 (void)instance_del_data(inst, PD_CLOSE_MONITOR_TAG);
5487 (void)instance_unref(inst);
5488 ErrPrint("PD Close request is not processed in %lf seconds\n", PD_REQUEST_TIMEOUT);
5489 return ECORE_CALLBACK_CANCEL;
5492 static Eina_Bool pd_resize_monitor_cb(void *inst)
5494 struct pkg_info *pkg;
5496 pkg = instance_package(inst);
5498 struct slave_node *slave;
5499 slave = package_slave(pkg);
5501 slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst);
5505 (void)instance_slave_close_pd(inst, instance_pd_owner(inst), LB_CLOSE_PD_TIMEOUT);
5506 (void)instance_client_pd_destroyed(inst, LB_STATUS_ERROR_TIMEOUT);
5507 (void)instance_del_data(inst, PD_RESIZE_MONITOR_TAG);
5508 (void)instance_unref(inst);
5509 ErrPrint("PD Resize request is not processed in %lf seconds\n", PD_REQUEST_TIMEOUT);
5510 return ECORE_CALLBACK_CANCEL;
5513 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
5515 struct client_node *client;
5516 struct packet *result;
5517 const char *pkgname;
5520 struct inst_info *inst = NULL;
5521 const struct pkg_info *pkg = NULL;
5522 Ecore_Timer *pd_monitor;
5526 DbgPrint("PERF_DBOX\n");
5528 client = client_find_by_rpc_handle(handle);
5530 ErrPrint("Client %d is not exists\n", pid);
5531 ret = LB_STATUS_ERROR_NOT_EXIST;
5535 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
5537 ErrPrint("Parameter is not matched\n");
5538 ret = LB_STATUS_ERROR_INVALID;
5542 ret = validate_request(pkgname, id, &inst, &pkg);
5543 if (ret != LB_STATUS_SUCCESS) {
5547 if (instance_pd_owner(inst)) {
5548 ErrPrint("PD is already owned\n");
5549 ret = LB_STATUS_ERROR_ALREADY;
5550 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
5551 pd_monitor = instance_get_data(inst, LAZY_PD_CLOSE_TAG);
5553 ecore_timer_del(pd_monitor);
5554 /* This timer attribute will be deleted */
5555 lazy_pd_destroyed_cb(inst);
5558 if (instance_get_data(inst, PD_OPEN_MONITOR_TAG)) {
5559 DbgPrint("PD Open request is already processed\n");
5560 ret = LB_STATUS_ERROR_ALREADY;
5564 if (instance_get_data(inst, PD_CLOSE_MONITOR_TAG)) {
5565 DbgPrint("PD Close request is already in process\n");
5566 ret = LB_STATUS_ERROR_BUSY;
5570 if (instance_get_data(inst, PD_RESIZE_MONITOR_TAG)) {
5571 DbgPrint("PD resize request is already in process\n");
5572 ret = LB_STATUS_ERROR_BUSY;
5576 instance_slave_set_pd_pos(inst, x, y);
5579 * Send request to the slave.
5580 * The SLAVE must has to repsonse this via "release_buffer" method.
5582 ret = instance_slave_open_pd(inst, client);
5583 if (ret == (int)LB_STATUS_SUCCESS) {
5584 ret = instance_signal_emit(inst, "pd,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
5585 if (ret != LB_STATUS_SUCCESS) {
5588 tmp_ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_FAULT);
5590 ErrPrint("Unable to send script event for openning PD [%s], %d\n", pkgname, tmp_ret);
5593 pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_open_monitor_cb, instance_ref(inst));
5595 (void)instance_unref(inst);
5596 ErrPrint("Failed to create a timer for PD Open monitor\n");
5598 struct slave_node *slave;
5600 (void)instance_set_data(inst, PD_OPEN_MONITOR_TAG, pd_monitor);
5602 slave = package_slave(pkg);
5604 ErrPrint("Failed to get slave(%s)\n", pkgname);
5608 if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst) != LB_STATUS_SUCCESS) {
5609 ErrPrint("Failed to add fault handler: %s\n");
5614 ErrPrint("Unable to send request for openning PD [%s]\n", pkgname);
5619 * PD craeted event will be send by the acquire_buffer function.
5620 * Because the slave will make request the acquire_buffer to
5623 * instance_client_pd_created(inst);
5625 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
5629 pd_monitor = instance_get_data(inst, LAZY_PD_CLOSE_TAG);
5631 ecore_timer_del(pd_monitor);
5632 /* lazy,pd,close will be deleted */
5633 lazy_pd_destroyed_cb(inst);
5638 * ret value should be cared but in this case,
5639 * we ignore this for this moment, so we have to handle this error later.
5641 * if ret is less than 0, the slave has some problem.
5642 * but the script mode doesn't need slave for rendering default view of PD
5643 * so we can hanle it later.
5645 instance_slave_set_pd_pos(inst, x, y);
5646 ix = x * instance_pd_width(inst);
5647 iy = y * instance_pd_height(inst);
5649 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
5651 ret = instance_slave_open_pd(inst, client);
5652 if (ret == (int)LB_STATUS_SUCCESS) {
5653 ret = script_handler_load(instance_pd_script(inst), 1);
5657 * Send the PD created event to the clients,
5659 if (ret == (int)LB_STATUS_SUCCESS) {
5663 * But the created event has to be send afte return
5664 * from this function or the viewer couldn't care
5665 * the event correctly.
5667 inst = instance_ref(inst); /* To guarantee the inst */
5671 * At here, we don't need to rememeber the timer object.
5672 * Even if the timer callback is called, after the instance is destroyed.
5673 * lazy_pd_created_cb will decrease the instance refcnt first.
5674 * At that time, if the instance is released, the timer callback will do nothing.
5677 * I change my mind. There is no requirements to keep the timer handler.
5678 * But I just add it to the tagged-data of the instance.
5679 * Just reserve for future-use.
5681 pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst);
5683 ret = script_handler_unload(instance_pd_script(inst), 1);
5684 ErrPrint("Unload script: %d\n", ret);
5686 ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_NORMAL);
5687 ErrPrint("Close PD %d\n", ret);
5689 inst = instance_unref(inst);
5691 DbgPrint("Instance destroyed\n");
5694 ErrPrint("Instance: %s\n", pkgname);
5696 ret = LB_STATUS_ERROR_FAULT;
5698 struct slave_node *slave;
5700 (void)instance_set_data(inst, LAZY_PD_OPEN_TAG, pd_monitor);
5702 slave = package_slave(pkg);
5704 ErrPrint("Failed to get slave: %s\n", pkgname);
5708 if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_script_cb, inst) != LB_STATUS_SUCCESS) {
5709 ErrPrint("Failed to add fault callback: %s\n", pkgname);
5714 tmp_ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_FAULT);
5716 ErrPrint("Unable to load script: %d, (close: %d)\n", ret, tmp_ret);
5720 ErrPrint("Unable open PD(%s): %d\n", pkgname, ret);
5723 ErrPrint("Invalid PD TYPE\n");
5724 ret = LB_STATUS_ERROR_INVALID;
5728 result = packet_create_reply(packet, "i", ret);
5730 ErrPrint("Failed to create a packet\n");
5736 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
5738 struct client_node *client;
5739 struct packet *result;
5740 const char *pkgname;
5743 struct inst_info *inst = NULL;
5744 const struct pkg_info *pkg = NULL;
5745 Ecore_Timer *pd_monitor;
5746 struct slave_node *slave;
5748 DbgPrint("PERF_DBOX\n");
5750 client = client_find_by_rpc_handle(handle);
5752 ErrPrint("Client %d is not exists\n", pid);
5753 ret = LB_STATUS_ERROR_NOT_EXIST;
5757 ret = packet_get(packet, "ss", &pkgname, &id);
5759 ErrPrint("Parameter is not matched\n");
5760 ret = LB_STATUS_ERROR_INVALID;
5764 ret = validate_request(pkgname, id, &inst, &pkg);
5765 if (ret != LB_STATUS_SUCCESS) {
5769 slave = package_slave(pkg);
5771 ret = LB_STATUS_ERROR_INVALID;
5775 if (instance_pd_owner(inst) != client) {
5776 if (instance_pd_owner(inst) == NULL) {
5777 ErrPrint("PD looks already closed\n");
5778 ret = LB_STATUS_ERROR_ALREADY;
5780 ErrPrint("PD owner mimatched\n");
5781 ret = LB_STATUS_ERROR_PERMISSION;
5783 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5784 DbgPrint("Buffer type PD\n");
5785 pd_monitor = instance_del_data(inst, PD_OPEN_MONITOR_TAG);
5787 ErrPrint("PD Open request is found. cancel it [%s]\n", pkgname);
5789 if (slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst) < 0) {
5790 DbgPrint("Failed to delete a deactivate callback\n");
5795 * We should return negative value
5796 * Or we have to send "destroyed" event to the client.
5797 * If we didn't send destroyed event after return SUCCESS from here,
5798 * The client will permanently waiting destroyed event.
5799 * Because they understand that the destroy request is successfully processed.
5801 ret = instance_client_pd_created(inst, LB_STATUS_ERROR_CANCEL);
5803 ErrPrint("PD client create event: %d\n", ret);
5806 ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
5808 ErrPrint("PD client destroy event: %d\n", ret);
5811 ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
5813 ErrPrint("PD close signal emit failed: %d\n", ret);
5816 ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_NORMAL);
5818 ErrPrint("PD close request failed: %d\n", ret);
5821 ecore_timer_del(pd_monitor);
5822 inst = instance_unref(inst);
5824 DbgPrint("Instance is deleted\n");
5826 } else if (instance_get_data(inst, LAZY_PD_CLOSE_TAG) || instance_get_data(inst, PD_CLOSE_MONITOR_TAG)) {
5827 DbgPrint("Close monitor is already fired\n");
5828 ret = LB_STATUS_ERROR_ALREADY;
5830 int resize_aborted = 0;
5832 pd_monitor = instance_del_data(inst, PD_RESIZE_MONITOR_TAG);
5834 ErrPrint("PD Resize request is found. clear it [%s]\n", pkgname);
5835 if (slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst) < 0) {
5836 DbgPrint("Failed to delete a deactivate callback\n");
5839 ecore_timer_del(pd_monitor);
5841 inst = instance_unref(inst);
5843 DbgPrint("Instance is destroyed while resizing\n");
5850 ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
5852 ErrPrint("PD close signal emit failed: %d\n", ret);
5855 ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_NORMAL);
5857 ErrPrint("PD close request failed: %d\n", ret);
5858 } else if (resize_aborted) {
5859 pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
5861 ErrPrint("Failed to create a timer: %s\n", pkgname);
5862 inst = instance_unref(inst);
5864 DbgPrint("Instance is deleted\n");
5867 DbgPrint("Resize is aborted\n");
5868 (void)instance_set_data(inst, LAZY_PD_CLOSE_TAG, pd_monitor);
5869 if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst) < 0) {
5870 ErrPrint("Failed to add a slave event callback\n");
5874 pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_close_monitor_cb, instance_ref(inst));
5876 ErrPrint("Failed to add pd close monitor\n");
5877 inst = instance_unref(inst);
5879 ErrPrint("Instance is deleted while closing PD\n");
5882 DbgPrint("Add close monitor\n");
5883 (void)instance_set_data(inst, PD_CLOSE_MONITOR_TAG, pd_monitor);
5884 if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst) < 0) {
5885 ErrPrint("Failed to add SLAVE EVENT callback\n");
5892 * release_buffer will be called by the slave after this routine.
5893 * It will send the "pd_destroyed" event to the client
5895 * instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
5897 * Or the "pd_close_monitor_cb" or "lazy_pd_destroyed_cb" will be called.
5900 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
5901 DbgPrint("Script TYPE PD\n");
5902 pd_monitor = instance_get_data(inst, LAZY_PD_OPEN_TAG);
5904 ecore_timer_del(pd_monitor);
5905 (void)lazy_pd_created_cb(inst);
5908 ret = script_handler_unload(instance_pd_script(inst), 1);
5910 ErrPrint("Unable to unload the script: %s, %d\n", pkgname, ret);
5915 * Send request to the slave.
5916 * The SLAVE must has to repsonse this via "release_buffer" method.
5918 ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_NORMAL);
5920 ErrPrint("Unable to close the PD: %s, %d\n", pkgname, ret);
5925 * Send the destroyed PD event to the client
5927 if (ret == (int)LB_STATUS_SUCCESS) {
5931 * I've changed my mind. There is no requirements to keep the timer handler.
5932 * But I just add it to the tagged-data of the instance.
5933 * Just reserve for future-use.
5935 DbgPrint("Add lazy PD destroy timer\n");
5936 pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
5938 ErrPrint("Failed to create a timer: %s\n", pkgname);
5939 inst = instance_unref(inst);
5941 DbgPrint("instance is deleted\n");
5944 (void)instance_set_data(inst, LAZY_PD_CLOSE_TAG, pd_monitor);
5945 if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_script_cb, inst) < 0) {
5946 ErrPrint("Failed to add a event callback for slave\n");
5951 ErrPrint("Invalid PD TYPE\n");
5952 ret = LB_STATUS_ERROR_INVALID;
5956 result = packet_create_reply(packet, "i", ret);
5958 ErrPrint("Failed to create a packet\n");
5964 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
5966 struct client_node *client;
5967 struct packet *result;
5968 const char *pkgname;
5970 struct pkg_info *info;
5972 client = client_find_by_rpc_handle(handle);
5974 ErrPrint("Client %d is not exists\n", pid);
5975 ret = LB_STATUS_ERROR_NOT_EXIST;
5980 ret = packet_get(packet, "s", &pkgname);
5982 ErrPrint("Parameter is not matched\n");
5983 ret = LB_STATUS_ERROR_INVALID;
5988 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
5992 * Validate the livebox package name.
5994 if (!package_is_lb_pkgname(pkgname)) {
5995 ErrPrint("%s is not a valid livebox package\n", pkgname);
5997 ret = LB_STATUS_ERROR_INVALID;
6001 info = package_find(pkgname);
6003 ret = LB_STATUS_ERROR_NOT_EXIST;
6005 ret = package_clear_fault(info);
6009 result = packet_create_reply(packet, "is", ret, pkgname);
6011 ErrPrint("Failed to create a packet\n");
6017 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
6019 const char *cluster;
6020 const char *category;
6021 struct client_node *client;
6024 client = client_find_by_rpc_handle(handle);
6026 ErrPrint("Client %d is not exists\n", pid);
6027 ret = LB_STATUS_ERROR_NOT_EXIST;
6031 ret = packet_get(packet, "ss", &cluster, &category);
6033 ErrPrint("Invalid argument\n");
6034 ret = LB_STATUS_ERROR_INVALID;
6038 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
6039 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
6040 ErrPrint("Invalid cluster name\n");
6046 * SUBSCRIBE cluster & sub-cluster for a client.
6048 ret = client_subscribe(client, cluster, category);
6050 package_alter_instances_to_client(client, ALTER_CREATE);
6054 /*! \note No reply packet */
6058 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
6060 const char *cluster;
6061 struct client_node *client;
6062 struct packet *result;
6065 client = client_find_by_rpc_handle(handle);
6067 ErrPrint("Client %d is not exists\n", pid);
6068 ret = LB_STATUS_ERROR_NOT_EXIST;
6072 ret = packet_get(packet, "s", &cluster);
6074 ErrPrint("Invalid parameters\n");
6075 ret = LB_STATUS_ERROR_INVALID;
6079 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
6081 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
6082 ErrPrint("Invalid cluster: %s\n", cluster);
6083 ret = LB_STATUS_ERROR_INVALID;
6090 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
6093 result = packet_create_reply(packet, "i", ret);
6095 ErrPrint("Failed to create a packet\n");
6101 static inline int update_pkg_cb(struct category *category, const char *pkgname, int force)
6106 c_name = group_cluster_name_by_category(category);
6107 s_name = group_category_name(category);
6109 if (!c_name || !s_name || !pkgname) {
6110 ErrPrint("Name is not valid\n");
6111 return EXIT_FAILURE;
6114 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
6115 slave_rpc_request_update(pkgname, "", c_name, s_name, NULL, force);
6117 /* Just try to create a new package */
6118 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
6120 struct inst_info *inst;
6122 timestamp = util_timestamp();
6125 * Don't need to check the subscribed clients.
6126 * Because this callback is called by the requests of clients.
6127 * It means. some clients wants to handle this instances ;)
6129 inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DEFAULT_PERIOD, 0, 0);
6131 ErrPrint("Failed to create a new instance\n");
6135 return EXIT_SUCCESS;
6138 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
6140 struct inst_info *inst;
6141 struct client_node *client;
6142 const char *pkgname;
6147 client = client_find_by_rpc_handle(handle);
6149 ErrPrint("Cilent %d is not exists\n", pid);
6153 ret = packet_get(packet, "ssi", &pkgname, &id, &force);
6155 ErrPrint("Invalid argument\n");
6159 ret = validate_request(pkgname, id, &inst, NULL);
6160 if (ret != LB_STATUS_SUCCESS) {
6164 if (instance_client(inst) != client) {
6166 ErrPrint("Insufficient permissions [%s] - %d\n", pkgname, pid);
6168 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst), NULL, force);
6172 /*! \note No reply packet */
6176 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
6178 const char *cluster_id;
6179 const char *category_id;
6180 struct client_node *client;
6182 struct cluster *cluster;
6183 struct category *category;
6184 struct context_info *info;
6185 Eina_List *info_list;
6189 client = client_find_by_rpc_handle(handle);
6191 ErrPrint("Cilent %d is not exists\n", pid);
6195 ret = packet_get(packet, "ssi", &cluster_id, &category_id, &force);
6197 ErrPrint("Invalid parameter\n");
6201 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
6203 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
6204 ErrPrint("Invalid cluster name: %s\n", cluster_id);
6208 cluster = group_find_cluster(cluster_id);
6210 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
6214 category = group_find_category(cluster, category_id);
6216 ErrPrint("Category [%s] is not registered\n", category_id);
6220 info_list = group_context_info_list(category);
6221 EINA_LIST_FOREACH(info_list, l, info) {
6222 update_pkg_cb(category, group_pkgname_from_context_info(info), force);
6226 /*! \note No reply packet */
6230 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
6232 const char *cluster;
6233 const char *category;
6234 struct client_node *client;
6235 struct packet *result;
6238 client = client_find_by_rpc_handle(handle);
6240 ErrPrint("Client %d is not exists\n", pid);
6241 ret = LB_STATUS_ERROR_NOT_EXIST;
6245 ret = packet_get(packet, "ss", &cluster, &category);
6247 ErrPrint("Invalid paramenters\n");
6248 ret = LB_STATUS_ERROR_INVALID;
6252 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
6253 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
6254 ErrPrint("Invalid cluster: %s\n", cluster);
6255 ret = LB_STATUS_ERROR_INVALID;
6262 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
6265 result = packet_create_reply(packet, "i", ret);
6267 ErrPrint("Failed to create a packet\n");
6273 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
6275 const char *cluster;
6276 const char *category;
6277 struct client_node *client;
6280 client = client_find_by_rpc_handle(handle);
6282 ErrPrint("Client %d is not exists\n", pid);
6283 ret = LB_STATUS_ERROR_NOT_EXIST;
6287 ret = packet_get(packet, "ss", &cluster, &category);
6289 ErrPrint("Invalid argument\n");
6290 ret = LB_STATUS_ERROR_INVALID;
6294 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
6296 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
6297 ErrPrint("Invalid cluster name: %s\n", cluster);
6303 * UNSUBSCRIBE cluster & sub-cluster for a client.
6305 ret = client_unsubscribe(client, cluster, category);
6307 package_alter_instances_to_client(client, ALTER_DESTROY);
6311 /*! \note No reply packet */
6315 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
6317 struct slave_node *slave;
6318 const char *slavename;
6321 ret = packet_get(packet, "s", &slavename);
6323 ErrPrint("Parameter is not matched\n");
6327 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
6329 slave = slave_find_by_name(slavename);
6331 if (!slave) { /* Try again to find a slave using pid */
6332 slave = slave_find_by_pid(pid);
6337 char pkgname[pathconf("/", _PC_PATH_MAX)];
6340 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
6341 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
6342 slave = slave_find_by_name(slavename);
6343 pkgname[0] = '\0'; /* Reset the pkgname */
6345 slave = slave_find_by_pkgname(pkgname);
6349 abi = abi_find_by_pkgname(pkgname);
6352 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
6355 slave = slave_create(slavename, 1, abi, pkgname, 0);
6357 ErrPrint("Failed to create a new slave for %s\n", slavename);
6361 DbgPrint("New slave is created (net: 0)\n");
6363 DbgPrint("Registered slave is replaced with this new one\n");
6364 abi = slave_abi(slave);
6366 ErrPrint("ABI is not valid: %s\n", slavename);
6371 slave_set_pid(slave, pid);
6372 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
6374 ErrPrint("Slave[%d, %s] is not exists\n", pid, slavename);
6378 if (slave_pid(slave) != pid) {
6379 if (slave_pid(slave) > 0) {
6380 CRITICAL_LOG("Slave(%s) is already assigned to %d\n", slave_name(slave), slave_pid(slave));
6382 ret = aul_terminate_pid(pid);
6383 CRITICAL_LOG("Terminate %d (ret: %d)\n", pid, ret);
6387 CRITICAL_LOG("PID of slave(%s) is updated (%d -> %d)\n", slave_name(slave), slave_pid(slave), pid);
6388 slave_set_pid(slave, pid);
6394 * After updating handle,
6395 * slave activated callback will be called.
6397 slave_rpc_update_handle(slave, handle);
6403 static struct packet *slave_ctrl(pid_t pid, int handle, const struct packet *packet)
6405 struct slave_node *slave;
6409 slave = slave_find_by_pid(pid);
6411 ErrPrint("Slave %d is not exists\n", pid);
6415 ret = packet_get(packet, "i", &ctrl);
6417 ErrPrint("Parameter is not matched\n");
6419 slave_set_control_option(slave, ctrl);
6426 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
6428 struct slave_node *slave;
6429 const char *slavename;
6432 slave = slave_find_by_pid(pid);
6434 ErrPrint("Slave %d is not exists\n", pid);
6438 ret = packet_get(packet, "s", &slavename);
6440 ErrPrint("Parameter is not matched\n");
6442 slave_rpc_ping(slave);
6449 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
6451 struct slave_node *slave;
6452 struct pkg_info *pkg;
6453 const char *pkgname;
6458 slave = slave_find_by_pid(pid);
6460 ErrPrint("Slave %d is not exists\n", pid);
6464 ret = packet_get(packet, "sss", &pkgname, &id, &func);
6466 ErrPrint("Parameter is not matched\n");
6470 ret = fault_info_set(slave, pkgname, id, func);
6471 DbgPrint("Slave Faulted: %s (%d)\n", slave_name(slave), ret);
6473 pkg = package_find(pkgname);
6475 ErrPrint("There is no package info found: %s\n", pkgname);
6477 package_faulted(pkg, 0);
6484 static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
6486 struct slave_node *slave;
6487 struct inst_info *inst;
6488 const struct pkg_info *pkg;
6489 const char *pkgname;
6492 const char *content;
6496 slave = slave_find_by_pid(pid);
6498 ErrPrint("Slave %d is not exists\n", pid);
6502 ret = packet_get(packet, "ssdss", &pkgname, &id, &priority, &content, &title);
6504 ErrPrint("Invalid parameters\n");
6508 ret = validate_request(pkgname, id, &inst, &pkg);
6509 if (ret != LB_STATUS_SUCCESS) {
6513 if (instance_state(inst) == INST_DESTROYED) {
6514 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6518 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
6519 ret = instance_lb_update_begin(inst, priority, content, title);
6520 if (ret == (int)LB_STATUS_SUCCESS) {
6521 slave_freeze_ttl(slave);
6524 ErrPrint("Invalid request[%s]\n", id);
6531 static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct packet *packet)
6533 struct slave_node *slave;
6534 struct inst_info *inst;
6535 const struct pkg_info *pkg;
6536 const char *pkgname;
6540 slave = slave_find_by_pid(pid);
6542 ErrPrint("Slave %d is not exists\n", pid);
6546 ret = packet_get(packet, "ss", &pkgname, &id);
6548 ErrPrint("Invalid parameters\n");
6552 ret = validate_request(pkgname, id, &inst, &pkg);
6553 if (ret != LB_STATUS_SUCCESS) {
6557 if (instance_state(inst) == INST_DESTROYED) {
6558 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6562 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
6563 ret = instance_lb_update_end(inst);
6564 if (ret == (int)LB_STATUS_SUCCESS) {
6565 slave_thaw_ttl(slave);
6568 ErrPrint("Invalid request[%s]\n", id);
6575 static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
6577 struct slave_node *slave;
6578 const struct pkg_info *pkg;
6579 struct inst_info *inst;
6580 const char *pkgname;
6584 slave = slave_find_by_pid(pid);
6586 ErrPrint("Slave %d is not exists\n", pid);
6590 ret = packet_get(packet, "ss", &pkgname, &id);
6592 ErrPrint("Invalid parameters\n");
6596 ret = validate_request(pkgname, id, &inst, &pkg);
6597 if (ret != LB_STATUS_SUCCESS) {
6601 if (instance_state(inst) == INST_DESTROYED) {
6602 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6606 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
6607 (void)instance_pd_update_begin(inst);
6609 ErrPrint("Invalid request[%s]\n", id);
6616 static struct packet *slave_key_status(pid_t pid, int handle, const struct packet *packet)
6618 struct slave_node *slave;
6619 struct inst_info *inst;
6620 const char *pkgname;
6625 slave = slave_find_by_pid(pid);
6627 ErrPrint("Slave %d is not exists\n", pid);
6631 ret = packet_get(packet, "ssi", &pkgname, &id, &status);
6633 ErrPrint("Invalid parameters\n");
6637 ret = validate_request(pkgname, id, &inst, NULL);
6638 if (ret == (int)LB_STATUS_SUCCESS) {
6639 if (instance_state(inst) == INST_DESTROYED) {
6640 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6642 (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
6650 static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
6652 struct slave_node *slave;
6653 struct inst_info *inst;
6654 const char *pkgname;
6659 slave = slave_find_by_pid(pid);
6661 ErrPrint("Slave %d is not exists\n", pid);
6665 ret = packet_get(packet, "ssi", &pkgname, &id, &status);
6667 ErrPrint("Invalid parameters\n");
6671 ret = validate_request(pkgname, id, &inst, NULL);
6672 if (ret == (int)LB_STATUS_SUCCESS) {
6673 if (instance_state(inst) == INST_DESTROYED) {
6674 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6676 (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
6684 static struct packet *slave_close_pd(pid_t pid, int handle, const struct packet *packet)
6686 struct slave_node *slave;
6687 struct inst_info *inst;
6688 const char *pkgname;
6693 slave = slave_find_by_pid(pid);
6695 ErrPrint("Slave %d is not exists\n", pid);
6699 ret = packet_get(packet, "ssi", &pkgname, &id, &status);
6701 ErrPrint("Invalid parameters\n");
6705 ret = validate_request(pkgname, id, &inst, NULL);
6706 if (ret == (int)LB_STATUS_SUCCESS) {
6707 if (instance_state(inst) == INST_DESTROYED) {
6708 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6710 (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
6718 static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
6720 struct slave_node *slave;
6721 const struct pkg_info *pkg;
6722 struct inst_info *inst;
6723 const char *pkgname;
6727 slave = slave_find_by_pid(pid);
6729 ErrPrint("Slave %d is not exists\n", pid);
6733 ret = packet_get(packet, "ss", &pkgname, &id);
6735 ErrPrint("Invalid parameters\n");
6739 ret = validate_request(pkgname, id, &inst, &pkg);
6740 if (ret != LB_STATUS_SUCCESS) {
6744 if (instance_state(inst) == INST_DESTROYED) {
6745 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6749 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
6750 (void)instance_pd_update_end(inst);
6752 ErrPrint("Invalid request[%s]\n", id);
6759 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
6761 struct slave_node *slave;
6762 const char *pkgname;
6767 slave = slave_find_by_pid(pid);
6769 ErrPrint("Slave %d is not exists\n", pid);
6773 ret = packet_get(packet, "sss", &pkgname, &id, &func);
6775 ErrPrint("Parameter is not matched\n");
6779 ret = fault_func_call(slave, pkgname, id, func);
6780 slave_give_more_ttl(slave);
6786 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
6788 struct slave_node *slave;
6789 const char *pkgname;
6794 slave = slave_find_by_pid(pid);
6796 ErrPrint("Slave %d is not exists\n", pid);
6800 ret = packet_get(packet, "sss", &pkgname, &id, &func);
6802 ErrPrint("Parameter is not matched\n");
6806 ret = fault_func_ret(slave, pkgname, id, func);
6807 slave_give_more_ttl(slave);
6813 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
6815 struct slave_node *slave;
6816 const char *pkgname;
6817 const char *safe_filename;
6819 const char *content_info;
6827 struct inst_info *inst;
6829 slave = slave_find_by_pid(pid);
6831 ErrPrint("Slave %d is not exists\n", pid);
6835 ret = packet_get(packet, "ssiidsssss", &pkgname, &id,
6837 &content_info, &title,
6838 &safe_filename, &icon, &name);
6840 ErrPrint("Parameter is not matched\n");
6844 ret = validate_request(pkgname, id, &inst, NULL);
6845 if (ret == (int)LB_STATUS_SUCCESS) {
6846 if (instance_state(inst) == INST_DESTROYED) {
6847 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6851 instance_set_lb_info(inst, priority, content_info, title);
6852 instance_set_alt_info(inst, icon, name);
6854 switch (package_lb_type(instance_package(inst))) {
6855 case LB_TYPE_SCRIPT:
6856 script_handler_resize(instance_lb_script(inst), w, h);
6857 if (safe_filename) {
6858 (void)script_handler_parse_desc(inst, safe_filename, 0);
6860 safe_filename = util_uri_to_path(id);
6861 (void)script_handler_parse_desc(inst, safe_filename, 0);
6864 if (unlink(safe_filename) < 0) {
6865 ErrPrint("unlink: %s - %s\n", strerror(errno), safe_filename);
6868 case LB_TYPE_BUFFER:
6872 * text format (inst)
6874 instance_set_lb_size(inst, w, h);
6875 instance_lb_updated_by_instance(inst, safe_filename);
6879 slave_give_more_ttl(slave);
6886 static struct packet *slave_hold_scroll(pid_t pid, int handle, const struct packet *packet)
6888 struct slave_node *slave;
6889 struct inst_info *inst;
6890 const char *pkgname;
6895 slave = slave_find_by_pid(pid);
6897 ErrPrint("Slave %d is not exists\n", pid);
6901 ret = packet_get(packet, "ssi", &pkgname, &id, &seize);
6903 ErrPrint("Parameter is not matched\n");
6907 ret = validate_request(pkgname, id, &inst, NULL);
6908 if (ret == (int)LB_STATUS_SUCCESS) {
6909 if (instance_state(inst) == INST_DESTROYED) {
6910 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6912 (void)instance_hold_scroll(inst, seize);
6920 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
6922 struct slave_node *slave;
6923 const char *pkgname;
6925 const char *descfile;
6927 struct inst_info *inst;
6929 slave = slave_find_by_pid(pid);
6931 ErrPrint("Slave %d is not exists\n", pid);
6935 ret = packet_get(packet, "sss", &pkgname, &id, &descfile);
6937 ErrPrint("Parameter is not matched\n");
6941 ret = validate_request(pkgname, id, &inst, NULL);
6942 if (ret != LB_STATUS_SUCCESS) {
6946 if (instance_state(inst) == INST_DESTROYED) {
6947 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
6951 switch (package_pd_type(instance_package(inst))) {
6952 case PD_TYPE_SCRIPT:
6953 DbgPrint("%s updated (%s)\n", instance_id(inst), descfile);
6954 if (script_handler_is_loaded(instance_pd_script(inst))) {
6955 (void)script_handler_parse_desc(inst, descfile, 1);
6959 instance_set_pd_size(inst, 0, 0);
6960 case PD_TYPE_BUFFER:
6961 instance_pd_updated(pkgname, id, descfile);
6964 DbgPrint("Ignore updated DESC(%s)\n", pkgname);
6972 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
6974 struct slave_node *slave;
6975 const char *pkgname;
6978 struct inst_info *inst;
6980 slave = slave_find_by_pid(pid);
6982 ErrPrint("Slave %d is not exists\n", pid);
6986 ret = packet_get(packet, "ss", &pkgname, &id);
6988 ErrPrint("Parameter is not matched\n");
6992 ret = validate_request(pkgname, id, &inst, NULL);
6993 if (ret == (int)LB_STATUS_SUCCESS) {
6994 ret = instance_destroyed(inst, LB_STATUS_SUCCESS);
7002 * \note for the BUFFER Type slave
7004 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
7006 enum target_type target;
7007 const char *pkgname;
7012 struct packet *result;
7013 struct slave_node *slave;
7014 struct inst_info *inst = NULL;
7015 const struct pkg_info *pkg = NULL;
7018 slave = slave_find_by_pid(pid);
7020 ErrPrint("Failed to find a slave\n");
7022 ret = LB_STATUS_ERROR_NOT_EXIST;
7026 ret = packet_get(packet, "issiii", &target, &pkgname, &id, &w, &h, &pixel_size);
7028 ErrPrint("Invalid argument\n");
7030 ret = LB_STATUS_ERROR_INVALID;
7034 ret = validate_request(pkgname, id, &inst, &pkg);
7037 if (ret != LB_STATUS_SUCCESS) {
7041 ret = LB_STATUS_ERROR_INVALID;
7043 if (instance_state(inst) == INST_DESTROYED) {
7044 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
7048 if (target == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
7049 struct buffer_info *info;
7051 info = instance_lb_buffer(inst);
7053 if (!instance_create_lb_buffer(inst, pixel_size)) {
7054 ErrPrint("Failed to create a LB buffer\n");
7055 ret = LB_STATUS_ERROR_FAULT;
7059 info = instance_lb_buffer(inst);
7061 ErrPrint("LB buffer is not valid\n");
7064 * ret value should not be changed.
7070 ret = buffer_handler_resize(info, w, h);
7071 ret = buffer_handler_load(info);
7073 instance_set_lb_size(inst, w, h);
7074 instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
7075 id = buffer_handler_id(info);
7077 ErrPrint("Failed to load a buffer(%d)\n", ret);
7079 } else if (target == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
7080 struct buffer_info *info;
7081 Ecore_Timer *pd_monitor;
7085 pd_monitor = instance_del_data(inst, PD_OPEN_MONITOR_TAG);
7087 pd_monitor = instance_del_data(inst, PD_RESIZE_MONITOR_TAG);
7088 is_resize = !!pd_monitor;
7090 /* Invalid request. Reject this */
7091 ErrPrint("Invalid request\n");
7095 slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst);
7097 slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst);
7100 ecore_timer_del(pd_monitor);
7101 inst = instance_unref(inst);
7103 ErrPrint("Instance refcnt is ZERO: %s\n", pkgname);
7107 info = instance_pd_buffer(inst);
7109 if (!instance_create_pd_buffer(inst, pixel_size)) {
7110 ErrPrint("Failed to create a PD buffer\n");
7111 ret = LB_STATUS_ERROR_FAULT;
7112 instance_client_pd_created(inst, ret);
7116 info = instance_pd_buffer(inst);
7118 ErrPrint("PD buffer is not valid\n");
7121 * ret value should not be changed.
7123 instance_client_pd_created(inst, ret);
7128 ret = buffer_handler_resize(info, w, h);
7129 ret = buffer_handler_load(info);
7131 instance_set_pd_size(inst, w, h);
7132 id = buffer_handler_id(info);
7134 ErrPrint("Failed to load a buffer (%d)\n", ret);
7138 * Send the PD created event to the client
7141 instance_client_pd_created(inst, ret);
7146 result = packet_create_reply(packet, "is", ret, id);
7148 ErrPrint("Failed to create a packet\n");
7154 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
7156 struct slave_node *slave;
7157 struct packet *result;
7158 enum target_type type;
7159 const char *pkgname;
7163 struct inst_info *inst = NULL;
7164 const struct pkg_info *pkg = NULL;
7167 slave = slave_find_by_pid(pid);
7169 ErrPrint("Failed to find a slave\n");
7170 ret = LB_STATUS_ERROR_NOT_EXIST;
7175 ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
7177 ErrPrint("Invalid argument\n");
7178 ret = LB_STATUS_ERROR_INVALID;
7183 ret = validate_request(pkgname, id, &inst, &pkg);
7185 if (ret != LB_STATUS_SUCCESS) {
7189 ret = LB_STATUS_ERROR_INVALID;
7192 * Reset "id", It will be re-used from here
7195 if (instance_state(inst) == INST_DESTROYED) {
7196 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
7200 if (type == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
7201 struct buffer_info *info;
7203 info = instance_lb_buffer(inst);
7208 ret = buffer_handler_resize(info, w, h);
7211 * id is resued for newly assigned ID
7213 if (ret == (int)LB_STATUS_SUCCESS) {
7214 id = buffer_handler_id(info);
7215 instance_set_lb_size(inst, w, h);
7216 instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
7218 } else if (type == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
7219 struct buffer_info *info;
7221 info = instance_pd_buffer(inst);
7226 ret = buffer_handler_resize(info, w, h);
7229 * id is resued for newly assigned ID
7231 if (ret == (int)LB_STATUS_SUCCESS) {
7232 id = buffer_handler_id(info);
7233 instance_set_pd_size(inst, w, h);
7238 result = packet_create_reply(packet, "is", ret, id);
7240 ErrPrint("Failed to create a packet\n");
7246 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
7248 enum target_type type;
7249 const char *pkgname;
7251 struct packet *result;
7252 struct slave_node *slave;
7253 struct inst_info *inst;
7254 const struct pkg_info *pkg;
7257 slave = slave_find_by_pid(pid);
7259 ErrPrint("Failed to find a slave\n");
7260 ret = LB_STATUS_ERROR_NOT_EXIST;
7264 if (packet_get(packet, "iss", &type, &pkgname, &id) != 3) {
7265 ErrPrint("Inavlid argument\n");
7266 ret = LB_STATUS_ERROR_INVALID;
7270 ret = validate_request(pkgname, id, &inst, &pkg);
7271 if (ret != LB_STATUS_SUCCESS) {
7275 ret = LB_STATUS_ERROR_INVALID;
7277 if (type == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
7278 struct buffer_info *info;
7280 info = instance_lb_buffer(inst);
7281 ret = buffer_handler_unload(info);
7282 } else if (type == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
7283 struct buffer_info *info;
7284 Ecore_Timer *pd_monitor;
7286 pd_monitor = instance_del_data(inst, PD_CLOSE_MONITOR_TAG);
7287 if (!pd_monitor && !package_is_fault(pkg)) {
7288 ErrPrint("Slave requests to release a buffer\n");
7291 * In this case just keep going to release buffer,
7292 * Even if a user(client) doesn't wants to destroy the PD.
7294 * If the slave tries to destroy PD buffer, it should be
7295 * released and reported to the client about its status.
7297 * Even if the pd is destroyed by timeout handler,
7298 * instance_client_pd_destroyed function will be ignored
7299 * by pd.need_to_send_close_event flag.
7300 * which will be checked by instance_client_pd_destroyed function.
7305 * provider can try to resize the buffer size.
7306 * in that case, it will release the buffer first.
7307 * Then even though the client doesn't request to close the PD,
7308 * the provider can release it.
7309 * If we send the close event to the client,
7310 * The client will not able to allocate PD again.
7311 * In this case, add the pd,monitor again. from here.
7312 * to wait the re-allocate buffer.
7313 * If the client doesn't request buffer reallocation,
7314 * Treat it as a fault. and close the PD.
7316 info = instance_pd_buffer(inst);
7317 ret = buffer_handler_unload(info);
7319 if (ret == (int)LB_STATUS_SUCCESS) {
7320 pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_resize_monitor_cb, instance_ref(inst));
7322 ErrPrint("Failed to create a timer for PD Open monitor\n");
7323 inst = instance_unref(inst);
7325 DbgPrint("Instance is deleted\n");
7328 (void)instance_set_data(inst, PD_RESIZE_MONITOR_TAG, pd_monitor);
7329 if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst) != LB_STATUS_SUCCESS) {
7330 ErrPrint("Failed to add event handler: %s\n", pkgname);
7338 * If the instance has pd_monitor, the pd close requested from client via client_destroy_pd.
7340 slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
7341 ecore_timer_del(pd_monitor);
7343 inst = instance_unref(inst);
7345 ErrPrint("Instance is released: %s\n", pkgname);
7346 ret = LB_STATUS_ERROR_FAULT;
7351 This case means that the package is faulted so the service provider tries to release the buffer
7354 info = instance_pd_buffer(inst);
7355 ret = buffer_handler_unload(info);
7359 * Send the PD destroyed event to the client
7361 instance_client_pd_destroyed(inst, ret);
7366 result = packet_create_reply(packet, "i", ret);
7368 ErrPrint("Failed to create a packet\n");
7374 static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
7376 struct inst_info *inst;
7377 struct packet *result;
7378 const char *pkgname;
7383 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
7385 ErrPrint("Invalid packet\n");
7386 ret = LB_STATUS_ERROR_INVALID;
7391 struct pkg_info *pkg;
7393 pkg = package_find(pkgname);
7395 ret = LB_STATUS_ERROR_NOT_EXIST;
7396 } else if (package_is_fault(pkg)) {
7397 ret = LB_STATUS_ERROR_FAULT;
7399 Eina_List *inst_list;
7402 inst_list = package_instance_list(pkg);
7403 EINA_LIST_FOREACH(inst_list, l, inst) {
7404 ret = instance_set_period(inst, period);
7406 ErrPrint("Failed to change the period of %s to (%lf)\n", pkgname, period);
7411 ret = validate_request(pkgname, id, &inst, NULL);
7412 if (ret == (int)LB_STATUS_SUCCESS) {
7413 if (instance_state(inst) == INST_DESTROYED) {
7414 ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
7415 ret = LB_STATUS_ERROR_INVALID;
7419 ret = instance_set_period(inst, period);
7423 DbgPrint("Change the update period: %s, %lf : %d\n", pkgname, period, ret);
7425 result = packet_create_reply(packet, "i", ret);
7427 ErrPrint("Failed to create a packet\n");
7433 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
7435 Eina_List *inst_list;
7436 struct pkg_info *pkg;
7437 struct packet *result;
7438 const char *pkgname;
7440 const char *cluster;
7441 const char *category;
7442 const char *content;
7447 ret = packet_get(packet, "sssssi", &pkgname, &id, &cluster, &category, &content, &force);
7449 ErrPrint("Invalid Packet\n");
7450 ret = LB_STATUS_ERROR_INVALID;
7454 lbid = package_lb_pkgname(pkgname);
7456 ErrPrint("Invalid package %s\n", pkgname);
7457 ret = LB_STATUS_ERROR_INVALID;
7461 pkg = package_find(lbid);
7463 ret = LB_STATUS_ERROR_NOT_EXIST;
7468 if (package_is_fault(pkg)) {
7469 ret = LB_STATUS_ERROR_FAULT;
7474 inst_list = package_instance_list(pkg);
7475 if (!eina_list_count(inst_list)) {
7476 ret = LB_STATUS_ERROR_NOT_EXIST;
7481 if (id && strlen(id)) {
7483 struct inst_info *inst;
7485 ret = LB_STATUS_ERROR_NOT_EXIST;
7486 EINA_LIST_FOREACH(inst_list, l, inst) {
7487 if (!strcmp(instance_id(inst), id)) {
7488 ret = LB_STATUS_SUCCESS;
7493 if (ret == (int)LB_STATUS_ERROR_NOT_EXIST) {
7501 * Validate the update requstor.
7503 slave_rpc_request_update(lbid, id, cluster, category, content, force);
7505 ret = LB_STATUS_SUCCESS;
7508 result = packet_create_reply(packet, "i", ret);
7510 ErrPrint("Failed to create a packet\n");
7516 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
7518 struct liveinfo *info;
7519 struct packet *result;
7521 const char *fifo_name;
7524 DbgPrint("Request arrived from %d\n", pid);
7526 if (packet_get(packet, "d", ×tamp) != 1) {
7527 ErrPrint("Invalid packet\n");
7529 ret = LB_STATUS_ERROR_INVALID;
7533 info = liveinfo_create(pid, handle);
7535 ErrPrint("Failed to create a liveinfo object\n");
7537 ret = LB_STATUS_ERROR_INVALID;
7542 fifo_name = liveinfo_filename(info);
7543 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
7546 result = packet_create_reply(packet, "si", fifo_name, ret);
7548 ErrPrint("Failed to create a result packet\n");
7554 static Eina_Bool lazy_slave_list_cb(void *info)
7559 struct slave_node *slave;
7561 liveinfo_open_fifo(info);
7562 fp = liveinfo_fifo(info);
7564 liveinfo_close_fifo(info);
7565 return ECORE_CALLBACK_CANCEL;
7568 list = (Eina_List *)slave_list();
7569 EINA_LIST_FOREACH(list, l, slave) {
7570 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
7573 slave_pkgname(slave),
7575 slave_is_secured(slave),
7576 slave_refcnt(slave),
7577 slave_fault_count(slave),
7578 slave_state_string(slave),
7579 slave_loaded_instance(slave),
7580 slave_loaded_package(slave),
7585 fprintf(fp, "EOD\n");
7586 liveinfo_close_fifo(info);
7587 return ECORE_CALLBACK_CANCEL;
7590 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
7592 struct liveinfo *info;
7595 if (packet_get(packet, "d", ×tamp) != 1) {
7596 ErrPrint("Invalid argument\n");
7600 info = liveinfo_find_by_pid(pid);
7602 ErrPrint("Invalid request\n");
7606 lazy_slave_list_cb(info);
7611 static inline const char *visible_state_string(enum livebox_visible_state state)
7618 case LB_HIDE_WITH_PAUSE:
7627 static Eina_Bool inst_list_cb(void *info)
7631 struct pkg_info *pkg;
7633 Eina_List *inst_list;
7634 struct inst_info *inst;
7636 pkgname = liveinfo_data(info);
7638 return ECORE_CALLBACK_CANCEL;
7641 liveinfo_open_fifo(info);
7642 fp = liveinfo_fifo(info);
7644 ErrPrint("Invalid fp\n");
7645 liveinfo_close_fifo(info);
7647 return ECORE_CALLBACK_CANCEL;
7650 if (!package_is_lb_pkgname(pkgname)) {
7651 ErrPrint("Invalid package name\n");
7656 pkg = package_find(pkgname);
7659 ErrPrint("Package is not exists\n");
7663 inst_list = package_instance_list(pkg);
7664 EINA_LIST_FOREACH(inst_list, l, inst) {
7665 fprintf(fp, "%s %s %s %lf %s %d %d\n",
7667 instance_cluster(inst),
7668 instance_category(inst),
7669 instance_period(inst),
7670 visible_state_string(instance_visible_state(inst)),
7671 instance_lb_width(inst),
7672 instance_lb_height(inst));
7676 fprintf(fp, "EOD\n");
7677 liveinfo_close_fifo(info);
7679 return ECORE_CALLBACK_CANCEL;
7682 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
7684 const char *pkgname;
7686 struct liveinfo *info;
7688 if (packet_get(packet, "s", &pkgname) != 1) {
7689 ErrPrint("Invalid argument\n");
7693 info = liveinfo_find_by_pid(pid);
7695 ErrPrint("Invalid request\n");
7699 dup_pkgname = strdup(pkgname);
7701 ErrPrint("Invalid request\n");
7705 liveinfo_set_data(info, dup_pkgname);
7712 static Eina_Bool pkg_list_cb(void *info)
7717 Eina_List *inst_list;
7718 struct pkg_info *pkg;
7719 struct slave_node *slave;
7720 const char *slavename;
7723 liveinfo_open_fifo(info);
7724 fp = liveinfo_fifo(info);
7726 DbgPrint("Failed to open a pipe\n");
7727 liveinfo_close_fifo(info);
7728 return ECORE_CALLBACK_CANCEL;
7731 list = (Eina_List *)package_list();
7732 EINA_LIST_FOREACH(list, l, pkg) {
7733 slave = package_slave(pkg);
7736 slavename = slave_name(slave);
7737 pid = slave_pid(slave);
7743 inst_list = (Eina_List *)package_instance_list(pkg);
7744 fprintf(fp, "%d %s %s %s %d %d %d\n",
7746 strlen(slavename) ? slavename : "(none)",
7749 package_refcnt(pkg),
7750 package_fault_count(pkg),
7751 eina_list_count(inst_list)
7753 DbgPrint("%d %s %s %s %d %d %d\n",
7755 strlen(slavename) ? slavename : "(none)",
7758 package_refcnt(pkg),
7759 package_fault_count(pkg),
7760 eina_list_count(inst_list)
7764 fprintf(fp, "EOD\n");
7766 liveinfo_close_fifo(info);
7767 return ECORE_CALLBACK_CANCEL;
7770 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
7772 struct liveinfo *info;
7775 if (packet_get(packet, "d", ×tamp) != 1) {
7776 ErrPrint("Invalid argument\n");
7780 DbgPrint("Package List: %lf\n", timestamp);
7782 info = liveinfo_find_by_pid(pid);
7784 ErrPrint("Invalid request\n");
7793 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
7798 static Eina_Bool pkg_ctrl_rmpack_cb(void *info)
7801 liveinfo_open_fifo(info);
7802 fp = liveinfo_fifo(info);
7804 liveinfo_close_fifo(info);
7805 return ECORE_CALLBACK_CANCEL;
7808 fprintf(fp, "%d\n", ENOSYS);
7809 fprintf(fp, "EOD\n");
7810 liveinfo_close_fifo(info);
7811 return ECORE_CALLBACK_CANCEL;
7814 static Eina_Bool pkg_ctrl_rminst_cb(void *info)
7818 liveinfo_open_fifo(info);
7819 fp = liveinfo_fifo(info);
7821 liveinfo_close_fifo(info);
7822 return ECORE_CALLBACK_CANCEL;
7825 fprintf(fp, "%d\n", (int)liveinfo_data(info));
7826 fprintf(fp, "EOD\n");
7827 liveinfo_close_fifo(info);
7828 return ECORE_CALLBACK_CANCEL;
7831 static Eina_Bool pkg_ctrl_faultinst_cb(void *info)
7835 liveinfo_open_fifo(info);
7836 fp = liveinfo_fifo(info);
7838 liveinfo_close_fifo(info);
7839 return ECORE_CALLBACK_CANCEL;
7842 fprintf(fp, "%d\n", (int)liveinfo_data(info));
7843 fprintf(fp, "EOD\n");
7844 liveinfo_close_fifo(info);
7845 return ECORE_CALLBACK_CANCEL;
7848 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
7850 struct liveinfo *info;
7855 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
7856 ErrPrint("Invalid argument\n");
7860 info = liveinfo_find_by_pid(pid);
7862 ErrPrint("Invalid request\n");
7866 if (!strcmp(cmd, "rmpack")) {
7867 pkg_ctrl_rmpack_cb(info);
7868 } else if (!strcmp(cmd, "rminst")) {
7869 struct inst_info *inst;
7870 inst = package_find_instance_by_id(pkgname, id);
7872 liveinfo_set_data(info, (void *)ENOENT);
7874 (void)instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
7875 liveinfo_set_data(info, (void *)0);
7878 pkg_ctrl_rminst_cb(info);
7879 } else if (!strcmp(cmd, "faultinst")) {
7880 struct inst_info *inst;
7881 inst = package_find_instance_by_id(pkgname, id);
7883 liveinfo_set_data(info, (void *)ENOENT);
7885 struct pkg_info *pkg;
7887 pkg = instance_package(inst);
7889 liveinfo_set_data(info, (void *)EFAULT);
7891 (void)package_faulted(pkg, 1);
7892 liveinfo_set_data(info, (void *)0);
7896 pkg_ctrl_faultinst_cb(info);
7903 static Eina_Bool master_ctrl_cb(void *info)
7907 liveinfo_open_fifo(info);
7908 fp = liveinfo_fifo(info);
7910 liveinfo_close_fifo(info);
7911 return ECORE_CALLBACK_CANCEL;
7913 fprintf(fp, "%d\nEOD\n", (int)liveinfo_data(info));
7914 liveinfo_close_fifo(info);
7916 return ECORE_CALLBACK_CANCEL;
7919 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
7921 struct liveinfo *info;
7925 int ret = LB_STATUS_ERROR_INVALID;
7927 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
7928 ErrPrint("Invalid argument\n");
7932 info = liveinfo_find_by_pid(pid);
7934 ErrPrint("Invalid request\n");
7938 if (!strcasecmp(var, "debug")) {
7939 if (!strcasecmp(cmd, "set")) {
7940 g_conf.debug_mode = !strcasecmp(val, "on");
7941 } else if (!strcasecmp(cmd, "get")) {
7943 ret = g_conf.debug_mode;
7944 } else if (!strcasecmp(var, "slave_max_load")) {
7945 if (!strcasecmp(cmd, "set")) {
7946 g_conf.slave_max_load = atoi(val);
7947 } else if (!strcasecmp(cmd, "get")) {
7949 ret = g_conf.slave_max_load;
7952 liveinfo_set_data(info, (void *)ret);
7953 master_ctrl_cb(info);
7959 static struct method s_info_table[] = {
7961 .cmd = "liveinfo_hello",
7962 .handler = liveinfo_hello,
7965 .cmd = "slave_list",
7966 .handler = liveinfo_slave_list,
7970 .handler = liveinfo_pkg_list,
7974 .handler = liveinfo_inst_list,
7977 .cmd = "slave_ctrl",
7978 .handler = liveinfo_slave_ctrl,
7982 .handler = liveinfo_pkg_ctrl,
7985 .cmd = "master_ctrl",
7986 .handler = liveinfo_master_ctrl,
7994 static struct method s_client_table[] = {
7996 .cmd = "pd_mouse_move",
7997 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
8000 .cmd = "lb_mouse_move",
8001 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
8004 .cmd = "pd_mouse_down",
8005 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
8008 .cmd = "pd_mouse_up",
8009 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
8012 .cmd = "lb_mouse_down",
8013 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
8016 .cmd = "lb_mouse_up",
8017 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
8020 .cmd = "pd_mouse_enter",
8021 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
8024 .cmd = "pd_mouse_leave",
8025 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
8028 .cmd = "lb_mouse_enter",
8029 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
8032 .cmd = "lb_mouse_leave",
8033 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
8036 .cmd = "lb_mouse_set",
8037 .handler = client_lb_mouse_set,
8040 .cmd = "lb_mouse_unset",
8041 .handler = client_lb_mouse_unset,
8044 .cmd = "pd_mouse_set",
8045 .handler = client_pd_mouse_set,
8048 .cmd = "pd_mouse_unset",
8049 .handler = client_pd_mouse_unset,
8052 .cmd = "lb_mouse_on_scroll",
8053 .handler = client_lb_mouse_on_scroll,
8056 .cmd = "lb_mouse_off_scroll",
8057 .handler = client_lb_mouse_off_scroll,
8060 .cmd = "pd_mouse_on_scroll",
8061 .handler = client_pd_mouse_on_scroll,
8064 .cmd = "pd_mouse_off_scroll",
8065 .handler = client_pd_mouse_off_scroll,
8068 .cmd = "lb_mouse_on_hold",
8069 .handler = client_lb_mouse_on_hold,
8072 .cmd = "lb_mouse_off_hold",
8073 .handler = client_lb_mouse_off_hold,
8076 .cmd = "pd_mouse_on_hold",
8077 .handler = client_pd_mouse_on_hold,
8080 .cmd = "pd_mouse_off_hold",
8081 .handler = client_pd_mouse_off_hold,
8084 .cmd = "change,visibility",
8085 .handler = client_change_visibility,
8088 .cmd = "lb_acquire_pixmap",
8089 .handler = client_lb_acquire_pixmap,
8092 .cmd = "lb_release_pixmap",
8093 .handler = client_lb_release_pixmap,
8096 .cmd = "pd_acquire_pixmap",
8097 .handler = client_pd_acquire_pixmap,
8100 .cmd = "pd_release_pixmap",
8101 .handler = client_pd_release_pixmap,
8105 .handler = client_acquire, /*!< pid, ret */
8109 .handler = cilent_release, /*!< pid, ret */
8113 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
8116 .cmd = "text_signal",
8117 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
8121 .handler = client_delete, /* pid, pkgname, filename, ret */
8125 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
8129 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
8132 .cmd = "set_period",
8133 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
8136 .cmd = "change_group",
8137 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
8140 .cmd = "pinup_changed",
8141 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
8145 .handler = client_create_pd, /* pid, pkgname, filename, ret */
8149 .handler = client_pd_move, /* pkgname, id, x, y */
8152 .cmd = "destroy_pd",
8153 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
8156 .cmd = "activate_package",
8157 .handler = client_activate_package, /* pid, pkgname, ret */
8160 .cmd = "subscribe", /* pid, cluster, sub-cluster */
8161 .handler = client_subscribed,
8164 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
8165 .handler = client_unsubscribed,
8168 .cmd = "delete_cluster",
8169 .handler = client_delete_cluster,
8172 .cmd = "delete_category",
8173 .handler = client_delete_category,
8176 .cmd = "refresh_group",
8177 .handler = client_refresh_group,
8181 .handler = client_update,
8185 .cmd = "pd_access_hl",
8186 .handler = client_pd_access_hl,
8189 .cmd = "pd_access_hl_prev",
8190 .handler = client_pd_access_hl_prev,
8193 .cmd = "pd_access_hl_next",
8194 .handler = client_pd_access_hl_next,
8197 .cmd = "pd_access_activate",
8198 .handler = client_pd_access_activate,
8201 .cmd = "pd_access_action_up",
8202 .handler = client_pd_access_action_up,
8205 .cmd = "pd_access_action_down",
8206 .handler = client_pd_access_action_down,
8209 .cmd = "pd_access_unhighlight",
8210 .handler = client_pd_access_unhighlight,
8213 .cmd = "pd_access_scroll_down",
8214 .handler = client_pd_access_scroll_down,
8217 .cmd = "pd_access_scroll_move",
8218 .handler = client_pd_access_scroll_move,
8221 .cmd = "pd_access_scroll_up",
8222 .handler = client_pd_access_scroll_up,
8226 .cmd = "lb_access_hl",
8227 .handler = client_lb_access_hl,
8230 .cmd = "lb_access_hl_prev",
8231 .handler = client_lb_access_hl_prev,
8234 .cmd = "lb_access_hl_next",
8235 .handler = client_lb_access_hl_next,
8238 .cmd = "lb_access_activate",
8239 .handler = client_lb_access_activate,
8242 .cmd = "lb_access_action_up",
8243 .handler = client_lb_access_action_up,
8246 .cmd = "lb_access_action_down",
8247 .handler = client_lb_access_action_down,
8250 .cmd = "lb_access_unhighlight",
8251 .handler = client_lb_access_unhighlight,
8254 .cmd = "lb_access_scroll_down",
8255 .handler = client_lb_access_scroll_down,
8258 .cmd = "lb_access_scroll_move",
8259 .handler = client_lb_access_scroll_move,
8262 .cmd = "lb_access_scroll_up",
8263 .handler = client_lb_access_scroll_up,
8267 .cmd = "lb_key_down",
8268 .handler = client_lb_key_down,
8272 .handler = client_lb_key_up,
8275 .cmd = "lb_key_focus_in",
8276 .handler = client_lb_key_focus_in,
8279 .cmd = "lb_key_focus_out",
8280 .handler = client_lb_key_focus_out,
8283 .cmd = "lb_key_set",
8284 .handler = client_lb_key_set,
8287 .cmd = "lb_key_unset",
8288 .handler = client_lb_key_unset,
8292 .cmd = "pd_key_down",
8293 .handler = client_pd_key_down,
8297 .handler = client_pd_key_up,
8300 .cmd = "pd_key_focus_in",
8301 .handler = client_pd_key_focus_in,
8304 .cmd = "pd_key_focus_out",
8305 .handler = client_pd_key_focus_out,
8308 .cmd = "pd_key_set",
8309 .handler = client_pd_key_set,
8312 .cmd = "pd_key_unset",
8313 .handler = client_pd_key_unset,
8317 .cmd = "client_paused",
8318 .handler = client_pause_request,
8321 .cmd = "client_resumed",
8322 .handler = client_resume_request,
8326 .cmd = "update_mode",
8327 .handler = client_update_mode,
8336 static struct method s_service_table[] = {
8338 .cmd = "service_update",
8339 .handler = service_update,
8342 .cmd = "service_change_period",
8343 .handler = service_change_period,
8351 static struct method s_slave_table[] = {
8354 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
8358 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
8362 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
8365 .cmd = "desc_updated",
8366 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
8370 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
8373 .cmd = "acquire_buffer",
8374 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
8377 .cmd = "resize_buffer",
8378 .handler = slave_resize_buffer,
8381 .cmd = "release_buffer",
8382 .handler = slave_release_buffer, /* slave_name, id - ret */
8386 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
8390 .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
8394 .cmd = "lb_update_begin",
8395 .handler = slave_lb_update_begin,
8398 .cmd = "lb_update_end",
8399 .handler = slave_lb_update_end,
8402 .cmd = "pd_update_begin",
8403 .handler = slave_pd_update_begin,
8406 .cmd = "pd_update_end",
8407 .handler = slave_pd_update_end,
8411 .cmd = "access_status",
8412 .handler = slave_access_status,
8415 .cmd = "key_status",
8416 .handler = slave_key_status,
8420 .handler = slave_close_pd,
8425 .handler = slave_hello, /* slave_name, ret */
8429 .handler = slave_ping, /* slave_name, ret */
8433 .handler = slave_ctrl, /* control bits */
8442 HAPI int server_init(void)
8444 com_core_packet_use_thread(COM_CORE_THREAD);
8446 if (unlink(INFO_SOCKET) < 0) {
8447 ErrPrint("info socket: %s\n", strerror(errno));
8450 if (unlink(SLAVE_SOCKET) < 0) {
8451 ErrPrint("slave socket: %s\n", strerror(errno));
8454 if (unlink(CLIENT_SOCKET) < 0) {
8455 ErrPrint("client socket: %s\n", strerror(errno));
8458 if (unlink(SERVICE_SOCKET) < 0) {
8459 ErrPrint("service socket: %s\n", strerror(errno));
8462 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
8463 if (s_info.info_fd < 0) {
8464 ErrPrint("Failed to create a info socket\n");
8467 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
8468 if (s_info.slave_fd < 0) {
8469 ErrPrint("Failed to create a slave socket\n");
8472 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
8473 if (s_info.client_fd < 0) {
8474 ErrPrint("Failed to create a client socket\n");
8480 * Skip address to use the NULL.
8482 s_info.remote_client_fd = com_core_packet_server_init("remote://:"CLIENT_PORT, s_client_table);
8483 if (s_info.client_fd < 0) {
8484 ErrPrint("Failed to create a remote client socket\n");
8487 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
8488 if (s_info.service_fd < 0) {
8489 ErrPrint("Faild to create a service socket\n");
8492 if (chmod(INFO_SOCKET, 0600) < 0) {
8493 ErrPrint("info socket: %s\n", strerror(errno));
8496 if (chmod(SLAVE_SOCKET, 0666) < 0) {
8497 ErrPrint("slave socket: %s\n", strerror(errno));
8500 if (chmod(CLIENT_SOCKET, 0666) < 0) {
8501 ErrPrint("client socket: %s\n", strerror(errno));
8504 if (chmod(SERVICE_SOCKET, 0666) < 0) {
8505 ErrPrint("service socket: %s\n", strerror(errno));
8511 HAPI int server_fini(void)
8513 if (s_info.info_fd > 0) {
8514 com_core_packet_server_fini(s_info.info_fd);
8515 s_info.info_fd = -1;
8518 if (s_info.slave_fd > 0) {
8519 com_core_packet_server_fini(s_info.slave_fd);
8520 s_info.slave_fd = -1;
8523 if (s_info.client_fd > 0) {
8524 com_core_packet_server_fini(s_info.client_fd);
8525 s_info.client_fd = -1;
8528 if (s_info.remote_client_fd > 0) {
8529 com_core_packet_server_fini(s_info.remote_client_fd);
8530 s_info.remote_client_fd = -1;
8533 if (s_info.service_fd > 0) {
8534 com_core_packet_server_fini(s_info.service_fd);
8535 s_info.service_fd = -1;