2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <Ecore_Evas.h> /* fb.h */
28 #include <com-core_packet.h>
29 #include <livebox-errno.h>
34 #include "slave_life.h"
35 #include "slave_rpc.h"
36 #include "client_life.h"
38 #include "client_rpc.h"
40 #include "script_handler.h"
41 #include "buffer_handler.h"
43 #include "fault_manager.h"
44 #include "fb.h" /* fb_type */
64 /* Share this with provider */
72 struct client_node *client;
73 struct inst_info *inst;
76 static int event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
78 struct inst_info *inst = data;
79 const struct pkg_info *pkg;
80 struct slave_node *slave;
81 struct packet *packet;
84 pkg = instance_package(inst);
86 return LB_STATUS_ERROR_INVALID;
88 slave = package_slave(pkg);
90 return LB_STATUS_ERROR_INVALID;
93 case EVENT_STATE_ACTIVATE:
94 cmdstr = "lb_mouse_down";
96 case EVENT_STATE_ACTIVATED:
97 cmdstr = "lb_mouse_move";
99 case EVENT_STATE_DEACTIVATE:
100 cmdstr = "lb_mouse_up";
103 return LB_STATUS_ERROR_INVALID;
106 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
108 return LB_STATUS_ERROR_FAULT;
110 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
113 static int event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
115 struct script_info *script;
116 struct inst_info *inst = data;
117 const struct pkg_info *pkg;
121 pkg = instance_package(inst);
125 script = instance_lb_script(inst);
127 return LB_STATUS_ERROR_FAULT;
129 e = script_handler_evas(script);
131 return LB_STATUS_ERROR_FAULT;
133 timestamp = util_timestamp();
136 case EVENT_STATE_ACTIVATE:
137 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
138 evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
139 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
141 case EVENT_STATE_ACTIVATED:
142 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
143 evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
145 case EVENT_STATE_DEACTIVATE:
146 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
147 evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
148 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
157 static int event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
159 struct inst_info *inst = data;
160 const struct pkg_info *pkg;
161 struct slave_node *slave;
162 struct packet *packet;
165 pkg = instance_package(inst);
167 return LB_STATUS_ERROR_INVALID;
169 slave = package_slave(pkg);
171 return LB_STATUS_ERROR_INVALID;
173 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
175 case EVENT_STATE_ACTIVATE:
176 cmdstr = "pd_mouse_down";
178 case EVENT_STATE_ACTIVATED:
179 cmdstr = "pd_mouse_move";
181 case EVENT_STATE_DEACTIVATE:
182 cmdstr = "pd_mouse_up";
185 return LB_STATUS_ERROR_INVALID;
188 packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
190 return LB_STATUS_ERROR_FAULT;
192 return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
195 static int event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
197 struct script_info *script;
198 struct inst_info *inst = data;
199 const struct pkg_info *pkg;
203 pkg = instance_package(inst);
207 script = instance_pd_script(inst);
209 return LB_STATUS_ERROR_FAULT;
211 e = script_handler_evas(script);
213 return LB_STATUS_ERROR_FAULT;
215 DbgPrint("Event: %dx%d\n", event_info->x, event_info->y);
216 timestamp = util_timestamp();
219 case EVENT_STATE_ACTIVATE:
220 script_handler_update_pointer(script, event_info->x, event_info->y, 1);
221 evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
222 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
224 case EVENT_STATE_ACTIVATED:
225 script_handler_update_pointer(script, event_info->x, event_info->y, -1);
226 evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
228 case EVENT_STATE_DEACTIVATE:
229 script_handler_update_pointer(script, event_info->x, event_info->y, 0);
230 evas_event_feed_mouse_move(e, event_info->x, event_info->y, timestamp, NULL);
231 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
239 static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
241 struct client_node *client;
242 struct packet *result;
246 client = client_find_by_pid(pid);
248 ErrPrint("Client is already exists %d\n", pid);
249 ret = LB_STATUS_ERROR_EXIST;
253 if (packet_get(packet, "d", ×tamp) != 1) {
254 ErrPrint("Invalid arguemnt\n");
255 ret = LB_STATUS_ERROR_INVALID;
259 DbgPrint("Acquired %lf\n", timestamp);
264 * client_create will invoke the client created callback
266 client = client_create(pid, handle);
268 ErrPrint("Failed to create a new client for %d\n", pid);
269 ret = LB_STATUS_ERROR_FAULT;
273 result = packet_create_reply(packet, "i", ret);
275 ErrPrint("Failed to create a packet\n");
280 static struct packet *cilent_release(pid_t pid, int handle, const struct packet *packet) /*!< pid, ret */
282 struct client_node *client;
283 struct packet *result;
286 client = client_find_by_pid(pid);
288 ErrPrint("Client %d is not exists\n", pid);
289 ret = LB_STATUS_ERROR_NOT_EXIST;
293 client_destroy(client);
297 result = packet_create_reply(packet, "i", ret);
299 ErrPrint("Failed to create a packet\n");
304 /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
305 static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
307 struct client_node *client;
315 struct inst_info *inst;
317 client = client_find_by_pid(pid);
319 ErrPrint("Client %d is not exists\n", pid);
320 ret = LB_STATUS_ERROR_NOT_EXIST;
324 ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
326 ErrPrint("Parameter is not matched\n");
327 ret = LB_STATUS_ERROR_INVALID;
331 DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%lf] y[%lf]\n", pid, pkgname, id, event, timestamp, x, y);
335 * Trust the package name which are sent by the client.
336 * The package has to be a livebox package name.
338 inst = package_find_instance_by_id(pkgname, id);
340 ret = LB_STATUS_ERROR_NOT_EXIST;
341 else if (package_is_fault(instance_package(inst)))
342 ret = LB_STATUS_ERROR_FAULT;
344 ret = instance_clicked(inst, event, timestamp, x, y);
347 /*! \note No reply packet */
351 /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
352 static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
354 struct client_node *client;
355 struct packet *result;
358 const char *emission;
364 struct inst_info *inst;
367 client = client_find_by_pid(pid);
369 ErrPrint("Client %d is not exists\n", pid);
370 ret = LB_STATUS_ERROR_NOT_EXIST;
374 ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
376 ErrPrint("Parameter is not matched\n");
377 ret = LB_STATUS_ERROR_INVALID;
381 DbgPrint("pid[%d] pkgname[%s] id[%s] emission[%s] source[%s] sx[%lf] sy[%lf] ex[%lf] ey[%lf]\n", pid, pkgname, id, emission, source, sx, sy, ex, ey);
385 * Trust the package name which are sent by the client.
386 * The package has to be a livebox package name.
388 inst = package_find_instance_by_id(pkgname, id);
390 ret = LB_STATUS_ERROR_NOT_EXIST;
391 else if (package_is_fault(instance_package(inst)))
392 ret = LB_STATUS_ERROR_FAULT;
394 ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
397 result = packet_create_reply(packet, "i", ret);
399 ErrPrint("Failed to create a packet\n");
404 static Eina_Bool lazy_delete_cb(void *data)
406 struct deleted_item *item = data;
408 DbgPrint("Send delete event to the client\n");
411 * Before invoke this callback, the instance is able to already remove this client
414 if (instance_has_client(item->inst, item->client)) {
415 instance_unicast_deleted_event(item->inst, item->client);
416 instance_del_client(item->inst, item->client);
419 client_unref(item->client);
420 instance_unref(item->inst);
422 return ECORE_CALLBACK_CANCEL;
425 static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
427 struct client_node *client;
428 struct packet *result;
431 struct inst_info *inst;
434 client = client_find_by_pid(pid);
436 ErrPrint("Client %d is not exists\n", pid);
437 ret = LB_STATUS_ERROR_NOT_EXIST;
441 ret = packet_get(packet, "ss", &pkgname, &id);
443 ErrPrint("Parameter is not matched\n");
444 ret = LB_STATUS_ERROR_INVALID;
448 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
452 * Trust the package name which are sent by the client.
453 * The package has to be a livebox package name.
455 inst = package_find_instance_by_id(pkgname, id);
457 ret = LB_STATUS_ERROR_NOT_EXIST;
458 } else if (package_is_fault(instance_package(inst))) {
459 ret = LB_STATUS_ERROR_FAULT;
460 } else if (instance_client(inst) != client) {
461 if (instance_has_client(inst, client)) {
462 struct deleted_item *item;
464 item = malloc(sizeof(*item));
466 ErrPrint("Heap: %s\n", strerror(errno));
467 ret = LB_STATUS_ERROR_MEMORY;
472 * Send DELETED EVENT to the client.
473 * after return from this function.
475 * Client will prepare the deleted event after get this function's return value.
476 * So We have to make a delay to send a deleted event.
479 item->client = client_ref(client);
480 item->inst = instance_ref(inst);
482 if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
483 ErrPrint("Failed to add a delayzed delete callback\n");
484 client_unref(client);
485 instance_unref(inst);
487 ret = LB_STATUS_ERROR_FAULT;
491 ret = LB_STATUS_ERROR_PERMISSION;
494 ret = instance_destroy(inst);
498 result = packet_create_reply(packet, "i", ret);
500 ErrPrint("Failed to create a packet\n");
505 static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
507 struct client_node *client;
508 struct packet *result;
513 struct inst_info *inst;
516 client = client_find_by_pid(pid);
518 ErrPrint("Client %d is not exists\n", pid);
519 ret = LB_STATUS_ERROR_NOT_EXIST;
523 ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
525 ErrPrint("Parameter is not matched\n");
526 ret = LB_STATUS_ERROR_INVALID;
530 DbgPrint("pid[%d] pkgname[%s] id[%s] w[%d] h[%d]\n", pid, pkgname, id, w, h);
534 * Trust the package name which are sent by the client.
535 * The package has to be a livebox package name.
537 inst = package_find_instance_by_id(pkgname, id);
539 ret = LB_STATUS_ERROR_NOT_EXIST;
540 } else if (package_is_fault(instance_package(inst))) {
541 ret = LB_STATUS_ERROR_FAULT;
542 } else if (instance_client(inst) != client) {
543 ret = LB_STATUS_ERROR_PERMISSION;
545 ret = instance_resize(inst, w, h);
549 result = packet_create_reply(packet, "i", ret);
551 ErrPrint("Failed to create a packet\n");
556 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
558 struct client_node *client;
559 struct packet *result;
563 const char *category;
567 struct pkg_info *info;
572 client = client_find_by_pid(pid);
574 ErrPrint("Client %d is not exists\n", pid);
575 ret = LB_STATUS_ERROR_NOT_EXIST;
579 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
581 ErrPrint("Parameter is not matched\n");
582 ret = LB_STATUS_ERROR_INVALID;
586 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
587 pid, timestamp, pkgname, content, cluster, category, period);
589 lb_pkgname = package_lb_pkgname(pkgname);
591 ErrPrint("This %s has no livebox package\n", pkgname);
592 ret = LB_STATUS_ERROR_INVALID;
596 info = package_find(lb_pkgname);
598 info = package_create(lb_pkgname);
601 ret = LB_STATUS_ERROR_FAULT;
602 } else if (package_is_fault(info)) {
603 ret = LB_STATUS_ERROR_FAULT;
604 } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
605 ErrPrint("Not enough space\n");
606 ret = LB_STATUS_ERROR_NO_SPACE;
608 struct inst_info *inst;
610 if (period > 0.0f && period < MINIMUM_PERIOD)
611 period = MINIMUM_PERIOD;
613 if (!strlen(content))
614 content = DEFAULT_CONTENT;
616 inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
619 * Using the "inst" without validate its value is at my disposal. ;)
621 ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
627 result = packet_create_reply(packet, "i", ret);
629 ErrPrint("Failed to create a packet\n");
634 static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
636 struct client_node *client;
639 enum livebox_visible_state state;
641 struct inst_info *inst;
643 client = client_find_by_pid(pid);
645 ErrPrint("Client %d is not exists\n", pid);
646 ret = LB_STATUS_ERROR_NOT_EXIST;
650 ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
652 ErrPrint("Parameter is not matched\n");
653 ret = LB_STATUS_ERROR_INVALID;
657 DbgPrint("pid[%d] pkgname[%s] id[%s] state[%d]\n", pid, pkgname, id, state);
661 * Trust the package name which are sent by the client.
662 * The package has to be a livebox package name.
664 inst = package_find_instance_by_id(pkgname, id);
666 ret = LB_STATUS_ERROR_NOT_EXIST;
667 } else if (package_is_fault(instance_package(inst))) {
668 ret = LB_STATUS_ERROR_FAULT;
669 } else if (instance_client(inst) != client) {
670 ret = LB_STATUS_ERROR_PERMISSION;
672 ret = instance_set_visible_state(inst, state);
676 /*! \note No reply packet */
680 static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
682 struct client_node *client;
683 struct packet *result;
688 struct inst_info *inst;
690 client = client_find_by_pid(pid);
692 ErrPrint("Client %d is not exists\n", pid);
693 ret = LB_STATUS_ERROR_NOT_EXIST;
697 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
699 ErrPrint("Parameter is not matched\n");
700 ret = LB_STATUS_ERROR_INVALID;
704 DbgPrint("pid[%d] pkgname[%s] id[%s] period[%lf]\n", pid, pkgname, id, period);
708 * Trust the package name which are sent by the client.
709 * The package has to be a livebox package name.
711 inst = package_find_instance_by_id(pkgname, id);
713 ret = LB_STATUS_ERROR_NOT_EXIST;
714 } else if (package_is_fault(instance_package(inst))) {
715 ret = LB_STATUS_ERROR_FAULT;
716 } else if (instance_client(inst) != client) {
717 ret = LB_STATUS_ERROR_PERMISSION;
719 ret = instance_set_period(inst, period);
723 result = packet_create_reply(packet, "i", ret);
725 ErrPrint("Failed to create a packet\n");
730 static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
732 struct client_node *client;
733 struct packet *result;
737 const char *category;
738 struct inst_info *inst;
741 client = client_find_by_pid(pid);
743 ErrPrint("Client %d is not exists\n", pid);
744 ret = LB_STATUS_ERROR_NOT_EXIST;
748 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
750 ErrPrint("Parameter is not matched\n");
751 ret = LB_STATUS_ERROR_INVALID;
755 DbgPrint("pid[%d] pkgname[%s] id[%s] cluster[%s] category[%s]\n", pid, pkgname, id, cluster, category);
759 * Trust the package name which are sent by the client.
760 * The package has to be a livebox package name.
762 inst = package_find_instance_by_id(pkgname, id);
764 ret = LB_STATUS_ERROR_NOT_EXIST;
765 } else if (package_is_fault(instance_package(inst))) {
766 ret = LB_STATUS_ERROR_FAULT;
767 } else if (instance_client(inst) != client) {
768 ret = LB_STATUS_ERROR_PERMISSION;
770 ret = instance_change_group(inst, cluster, category);
774 result = packet_create_reply(packet, "i", ret);
776 ErrPrint("Failed to create a packet\n");
781 static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
783 struct client_node *client;
790 struct inst_info *inst;
791 const struct pkg_info *pkg;
793 client = client_find_by_pid(pid);
795 ErrPrint("Client %d is not exists\n", pid);
796 ret = LB_STATUS_ERROR_NOT_EXIST;
800 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
802 ErrPrint("Invalid parameter\n");
803 ret = LB_STATUS_ERROR_INVALID;
809 * Trust the package name which are sent by the client.
810 * The package has to be a livebox package name.
812 inst = package_find_instance_by_id(pkgname, id);
814 ErrPrint("Instance[%s] is not exists\n", id);
815 ret = LB_STATUS_ERROR_NOT_EXIST;
819 pkg = instance_package(inst);
821 ErrPrint("Package[%s] info is not found\n", pkgname);
822 ret = LB_STATUS_ERROR_FAULT;
826 if (package_is_fault(pkg)) {
829 * If the package is registered as fault module,
830 * slave has not load it, so we don't need to do anything at here!
832 DbgPrint("Package[%s] is faulted\n", pkgname);
833 ret = LB_STATUS_ERROR_FAULT;
834 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
835 struct buffer_info *buffer;
836 struct slave_node *slave;
837 // struct packet *packet;
839 buffer = instance_pd_buffer(inst);
841 ErrPrint("Instance[%s] has no buffer\n", id);
842 ret = LB_STATUS_ERROR_FAULT;
846 slave = package_slave(pkg);
848 ErrPrint("Package[%s] has no slave\n", pkgname);
849 ret = LB_STATUS_ERROR_INVALID;
854 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
856 ErrPrint("Failed to create a packet[%s]\n", pkgname);
857 ret = LB_STATUS_ERROR_FAULT;
862 packet_ref((struct packet *)packet);
863 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
864 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
865 struct script_info *script;
868 script = instance_pd_script(inst);
870 ret = LB_STATUS_ERROR_FAULT;
874 e = script_handler_evas(script);
876 ret = LB_STATUS_ERROR_FAULT;
880 script_handler_update_pointer(script, x, y, -1);
881 evas_event_feed_mouse_in(e, timestamp, NULL);
884 ErrPrint("Unsupported package\n");
885 ret = LB_STATUS_ERROR_INVALID;
889 /*! \note No reply packet */
893 static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
895 struct client_node *client;
902 struct inst_info *inst;
903 const struct pkg_info *pkg;
905 client = client_find_by_pid(pid);
907 ErrPrint("Client %d is not exists\n", pid);
908 ret = LB_STATUS_ERROR_NOT_EXIST;
912 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
914 ErrPrint("Parameter is not matched\n");
915 ret = LB_STATUS_ERROR_INVALID;
921 * Trust the package name which are sent by the client.
922 * The package has to be a livebox package name.
924 inst = package_find_instance_by_id(pkgname, id);
926 ErrPrint("Instance[%s] is not exists\n", id);
927 ret = LB_STATUS_ERROR_NOT_EXIST;
931 pkg = instance_package(inst);
933 ErrPrint("Package[%s] info is not found\n", pkgname);
934 ret = LB_STATUS_ERROR_FAULT;
938 if (package_is_fault(pkg)) {
941 * If the package is registered as fault module,
942 * slave has not load it, so we don't need to do anything at here!
944 DbgPrint("Package[%s] is faulted\n", pkgname);
945 ret = LB_STATUS_ERROR_FAULT;
946 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
947 struct buffer_info *buffer;
948 struct slave_node *slave;
949 // struct packet *packet;
951 buffer = instance_pd_buffer(inst);
953 ErrPrint("Instance[%s] has no buffer\n", id);
954 ret = LB_STATUS_ERROR_FAULT;
958 slave = package_slave(pkg);
960 ErrPrint("Package[%s] has no slave\n", pkgname);
961 ret = LB_STATUS_ERROR_INVALID;
966 packet = packet_create_noack("pd_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
968 ErrPrint("Failed to create a packet[%s]\n", pkgname);
969 ret = LB_STATUS_ERROR_FAULT;
974 packet_ref((struct packet *)packet);
975 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
976 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
977 struct script_info *script;
980 script = instance_pd_script(inst);
982 ret = LB_STATUS_ERROR_FAULT;
986 e = script_handler_evas(script);
988 ret = LB_STATUS_ERROR_FAULT;
992 script_handler_update_pointer(script, x, y, -1);
993 evas_event_feed_mouse_out(e, timestamp, NULL);
996 ErrPrint("Unsupported package\n");
997 ret = LB_STATUS_ERROR_INVALID;
1001 /*! \note No reply packet */
1005 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 */
1007 struct client_node *client;
1008 const char *pkgname;
1014 struct inst_info *inst;
1015 const struct pkg_info *pkg;
1017 client = client_find_by_pid(pid);
1019 ErrPrint("Client %d is not exists\n", pid);
1020 ret = LB_STATUS_ERROR_NOT_EXIST;
1024 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1026 ErrPrint("Parameter is not matched\n");
1027 ret = LB_STATUS_ERROR_INVALID;
1031 DbgPrint("(%dx%d)\n", x, y);
1035 * Trust the package name which are sent by the client.
1036 * The package has to be a livebox package name.
1038 inst = package_find_instance_by_id(pkgname, id);
1040 ErrPrint("Instance[%s] is not exists\n", id);
1041 ret = LB_STATUS_ERROR_NOT_EXIST;
1045 pkg = instance_package(inst);
1047 ErrPrint("Package[%s] info is not found\n", pkgname);
1048 ret = LB_STATUS_ERROR_FAULT;
1052 if (package_is_fault(pkg)) {
1055 * If the package is registered as fault module,
1056 * slave has not load it, so we don't need to do anything at here!
1058 DbgPrint("Package[%s] is faulted\n", pkgname);
1059 ret = LB_STATUS_ERROR_FAULT;
1060 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1061 struct buffer_info *buffer;
1062 struct slave_node *slave;
1063 // struct packet *packet;
1065 buffer = instance_pd_buffer(inst);
1067 ErrPrint("Instance[%s] has no buffer\n", id);
1068 ret = LB_STATUS_ERROR_FAULT;
1072 slave = package_slave(pkg);
1074 ErrPrint("Package[%s] has no slave\n", pkgname);
1075 ret = LB_STATUS_ERROR_INVALID;
1080 packet = packet_create_noack("pd_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1082 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1083 ret = LB_STATUS_ERROR_FAULT;
1088 packet_ref((struct packet *)packet);
1089 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1090 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1091 struct script_info *script;
1094 script = instance_pd_script(inst);
1096 ret = LB_STATUS_ERROR_FAULT;
1100 e = script_handler_evas(script);
1102 ret = LB_STATUS_ERROR_FAULT;
1106 script_handler_update_pointer(script, x, y, 1);
1107 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1108 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
1111 ErrPrint("Unsupported package\n");
1112 ret = LB_STATUS_ERROR_INVALID;
1116 /*! \note No reply packet */
1120 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 */
1122 struct client_node *client;
1123 const char *pkgname;
1129 struct inst_info *inst;
1130 const struct pkg_info *pkg;
1132 client = client_find_by_pid(pid);
1134 ErrPrint("Client %d is not exists\n", pid);
1135 ret = LB_STATUS_ERROR_NOT_EXIST;
1139 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1141 ErrPrint("Parameter is not matched\n");
1142 ret = LB_STATUS_ERROR_INVALID;
1146 DbgPrint("(%dx%d)\n", x, y);
1149 * Trust the package name which are sent by the client.
1150 * The package has to be a livebox package name.
1152 inst = package_find_instance_by_id(pkgname, id);
1154 ErrPrint("Instance[%s] is not exists\n", id);
1155 ret = LB_STATUS_ERROR_NOT_EXIST;
1159 pkg = instance_package(inst);
1161 ErrPrint("Package[%s] info is not exists\n", pkgname);
1162 ret = LB_STATUS_ERROR_FAULT;
1166 if (package_is_fault(pkg)) {
1169 * If the package is registered as fault module,
1170 * slave has not load it, so we don't need to do anything at here!
1172 DbgPrint("Package[%s] is faulted\n", pkgname);
1173 ret = LB_STATUS_ERROR_FAULT;
1174 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1175 struct buffer_info *buffer;
1176 struct slave_node *slave;
1177 //struct packet *packet;
1179 buffer = instance_pd_buffer(inst);
1181 ErrPrint("Instance[%s] has no buffer\n", id);
1182 ret = LB_STATUS_ERROR_FAULT;
1186 slave = package_slave(pkg);
1188 ErrPrint("Package[%s] has no slave\n", pkgname);
1189 ret = LB_STATUS_ERROR_INVALID;
1194 packet = packet_create_noack("pd_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1196 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1197 ret = LB_STATUS_ERROR_FAULT;
1202 packet_ref((struct packet *)packet);
1203 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1204 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1205 struct script_info *script;
1208 script = instance_pd_script(inst);
1210 ret = LB_STATUS_ERROR_FAULT;
1214 e = script_handler_evas(script);
1216 ret = LB_STATUS_ERROR_FAULT;
1220 script_handler_update_pointer(script, x, y, 0);
1221 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1222 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
1225 ErrPrint("Unsupported package\n");
1226 ret = LB_STATUS_ERROR_INVALID;
1230 /*! \note No reply packet */
1234 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 */
1236 struct client_node *client;
1237 const char *pkgname;
1243 struct inst_info *inst;
1244 const struct pkg_info *pkg;
1246 client = client_find_by_pid(pid);
1248 ErrPrint("Client %d is not exists\n", pid);
1249 ret = LB_STATUS_ERROR_NOT_EXIST;
1253 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1255 ErrPrint("Parameter is not matched\n");
1256 ret = LB_STATUS_ERROR_INVALID;
1260 DbgPrint("(%dx%d)\n", x, y);
1263 * Trust the package name which are sent by the client.
1264 * The package has to be a livebox package name.
1266 inst = package_find_instance_by_id(pkgname, id);
1268 ErrPrint("Instance[%s] is not exists\n", id);
1269 ret = LB_STATUS_ERROR_NOT_EXIST;
1273 pkg = instance_package(inst);
1275 ErrPrint("Package[%s] info is not exists\n", pkgname);
1276 ret = LB_STATUS_ERROR_FAULT;
1280 if (package_is_fault(pkg)) {
1283 * If the package is registered as fault module,
1284 * slave has not load it, so we don't need to do anything at here!
1286 DbgPrint("Package[%s] is faulted\n", pkgname);
1287 ret = LB_STATUS_ERROR_FAULT;
1288 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1289 struct buffer_info *buffer;
1290 struct slave_node *slave;
1291 //struct packet *packet;
1293 buffer = instance_pd_buffer(inst);
1295 ErrPrint("Instance[%s] has no buffer\n", id);
1296 ret = LB_STATUS_ERROR_FAULT;
1300 slave = package_slave(pkg);
1302 ErrPrint("Package[%s] has no slave\n", pkgname);
1303 ret = LB_STATUS_ERROR_INVALID;
1309 packet = packet_create_noack("pd_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1311 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1312 ret = LB_STATUS_ERROR_FAULT;
1316 packet_ref((struct packet *)packet);
1317 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1318 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1319 struct script_info *script;
1322 script = instance_pd_script(inst);
1324 ret = LB_STATUS_ERROR_FAULT;
1328 e = script_handler_evas(script);
1330 ret = LB_STATUS_ERROR_FAULT;
1334 script_handler_update_pointer(script, x, y, -1);
1335 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1338 ErrPrint("Unsupported package\n");
1339 ret = LB_STATUS_ERROR_INVALID;
1343 /*! \note No reply packet */
1347 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 */
1349 struct client_node *client;
1350 const char *pkgname;
1356 struct inst_info *inst;
1357 const struct pkg_info *pkg;
1359 client = client_find_by_pid(pid);
1361 ErrPrint("Client %d is not exists\n", pid);
1362 ret = LB_STATUS_ERROR_NOT_EXIST;
1366 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1368 ErrPrint("Parameter is not matched\n");
1369 ret = LB_STATUS_ERROR_INVALID;
1375 * Trust the package name which are sent by the client.
1376 * The package has to be a livebox package name.
1378 inst = package_find_instance_by_id(pkgname, id);
1380 ErrPrint("Instance[%s] is not exists\n", id);
1381 ret = LB_STATUS_ERROR_NOT_EXIST;
1385 pkg = instance_package(inst);
1387 ErrPrint("Package[%s] info is not exists\n", pkgname);
1388 ret = LB_STATUS_ERROR_FAULT;
1392 if (package_is_fault(pkg)) {
1395 * If the package is registered as fault module,
1396 * slave has not load it, so we don't need to do anything at here!
1398 DbgPrint("Package[%s] is faulted\n", pkgname);
1399 ret = LB_STATUS_ERROR_FAULT;
1400 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1401 struct buffer_info *buffer;
1402 struct slave_node *slave;
1403 //struct packet *packet;
1405 buffer = instance_lb_buffer(inst);
1407 ErrPrint("Instance[%s] has no buffer\n", id);
1408 ret = LB_STATUS_ERROR_FAULT;
1412 slave = package_slave(pkg);
1414 ErrPrint("Package[%s] has no slave\n", pkgname);
1415 ret = LB_STATUS_ERROR_INVALID;
1420 packet = packet_create_noack("lb_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1422 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1423 ret = LB_STATUS_ERROR_FAULT;
1427 packet_ref((struct packet *)packet);
1428 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1429 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1430 struct script_info *script;
1433 script = instance_lb_script(inst);
1435 ret = LB_STATUS_ERROR_FAULT;
1439 e = script_handler_evas(script);
1441 ret = LB_STATUS_ERROR_FAULT;
1445 script_handler_update_pointer(script, x, y, -1);
1446 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1449 ErrPrint("Unsupported package\n");
1450 ret = LB_STATUS_ERROR_INVALID;
1454 /*! \note No reply packet */
1458 static int inst_del_cb(struct inst_info *inst, void *data)
1461 return -1; /* Delete this callback */
1464 static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
1466 struct client_node *client;
1467 const char *pkgname;
1473 struct inst_info *inst;
1474 const struct pkg_info *pkg;
1476 client = client_find_by_pid(pid);
1478 ErrPrint("Client %d is not exists\n", pid);
1479 ret = LB_STATUS_ERROR_NOT_EXIST;
1483 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1485 ErrPrint("Parameter is not matched\n");
1486 ret = LB_STATUS_ERROR_INVALID;
1490 inst = package_find_instance_by_id(pkgname, id);
1492 ErrPrint("Instance[%s] is not exists\n", id);
1493 ret = LB_STATUS_ERROR_NOT_EXIST;
1497 pkg = instance_package(inst);
1499 ErrPrint("Package[%s] info is not exists\n", pkgname);
1500 ret = LB_STATUS_ERROR_FAULT;
1504 if (package_is_fault(pkg)) {
1507 * If the package is registered as fault module,
1508 * slave has not load it, so we don't need to do anything at here!
1510 DbgPrint("Package[%s] is faulted\n", pkgname);
1511 ret = LB_STATUS_ERROR_FAULT;
1512 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1513 if (event_is_activated()) {
1514 if (event_deactivate() == 0)
1515 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1518 ret = event_activate(x, y, event_lb_route_cb, inst);
1520 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1521 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1522 if (event_is_activated()) {
1523 if (event_deactivate() == 0)
1524 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1527 ret = event_activate(x, y, event_lb_consume_cb, inst);
1529 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1531 ErrPrint("Unsupported package\n");
1532 ret = LB_STATUS_ERROR_INVALID;
1538 static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1540 struct client_node *client;
1541 const char *pkgname;
1547 struct inst_info *inst;
1548 const struct pkg_info *pkg;
1549 client = client_find_by_pid(pid);
1551 ErrPrint("Client %d is not exists\n", pid);
1552 ret = LB_STATUS_ERROR_NOT_EXIST;
1555 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1557 ErrPrint("Parameter is not matched\n");
1558 ret = LB_STATUS_ERROR_INVALID;
1562 inst = package_find_instance_by_id(pkgname, id);
1564 ErrPrint("Instance[%s] is not exists\n", id);
1565 ret = LB_STATUS_ERROR_NOT_EXIST;
1569 pkg = instance_package(inst);
1571 ErrPrint("Package[%s] info is not exists\n", pkgname);
1572 ret = LB_STATUS_ERROR_FAULT;
1576 if (package_is_fault(pkg)) {
1579 * If the package is registered as fault module,
1580 * slave has not load it, so we don't need to do anything at here!
1582 DbgPrint("Package[%s] is faulted\n", pkgname);
1583 ret = LB_STATUS_ERROR_FAULT;
1584 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1585 ret = event_deactivate();
1587 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1588 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1589 ret = event_deactivate();
1591 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1593 ErrPrint("Unsupported package\n");
1594 ret = LB_STATUS_ERROR_INVALID;
1600 static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
1602 struct client_node *client;
1603 const char *pkgname;
1609 struct inst_info *inst;
1610 const struct pkg_info *pkg;
1612 client = client_find_by_pid(pid);
1614 ErrPrint("Client %d is not exists\n", pid);
1615 ret = LB_STATUS_ERROR_NOT_EXIST;
1619 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1621 ErrPrint("Parameter is not matched\n");
1622 ret = LB_STATUS_ERROR_INVALID;
1626 inst = package_find_instance_by_id(pkgname, id);
1628 ErrPrint("Instance[%s] is not exists\n", id);
1629 ret = LB_STATUS_ERROR_NOT_EXIST;
1633 pkg = instance_package(inst);
1635 ErrPrint("Package[%s] info is not exists\n", pkgname);
1636 ret = LB_STATUS_ERROR_FAULT;
1640 if (package_is_fault(pkg)) {
1643 * If the package is registered as fault module,
1644 * slave has not load it, so we don't need to do anything at here!
1646 DbgPrint("Package[%s] is faulted\n", pkgname);
1647 ret = LB_STATUS_ERROR_FAULT;
1648 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1649 if (event_is_activated()) {
1650 if (event_deactivate() == 0)
1651 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1654 ret = event_activate(x, y, event_pd_route_cb, inst);
1656 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1657 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1658 if (event_is_activated()) {
1659 if (event_deactivate() == 0)
1660 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1663 ret = event_activate(x, y, event_pd_consume_cb, inst);
1665 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1667 ErrPrint("Unsupported package\n");
1668 ret = LB_STATUS_ERROR_INVALID;
1675 static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1677 struct client_node *client;
1678 const char *pkgname;
1684 struct inst_info *inst;
1685 const struct pkg_info *pkg;
1687 client = client_find_by_pid(pid);
1689 ErrPrint("Client %d is not exists\n", pid);
1690 ret = LB_STATUS_ERROR_NOT_EXIST;
1694 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1696 ErrPrint("Parameter is not matched\n");
1697 ret = LB_STATUS_ERROR_INVALID;
1701 inst = package_find_instance_by_id(pkgname, id);
1703 ErrPrint("Instance[%s] is not exists\n", id);
1704 ret = LB_STATUS_ERROR_NOT_EXIST;
1708 pkg = instance_package(inst);
1710 ErrPrint("Package[%s] info is not exists\n", pkgname);
1711 ret = LB_STATUS_ERROR_FAULT;
1715 if (package_is_fault(pkg)) {
1718 * If the package is registered as fault module,
1719 * slave has not load it, so we don't need to do anything at here!
1721 DbgPrint("Package[%s] is faulted\n", pkgname);
1722 ret = LB_STATUS_ERROR_FAULT;
1723 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1724 ret = event_deactivate();
1726 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1727 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1728 ret = event_deactivate();
1730 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1732 ErrPrint("Unsupported package\n");
1733 ret = LB_STATUS_ERROR_INVALID;
1739 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 */
1741 struct client_node *client;
1742 const char *pkgname;
1748 struct inst_info *inst;
1749 const struct pkg_info *pkg;
1751 client = client_find_by_pid(pid);
1753 ErrPrint("Client %d is not exists\n", pid);
1754 ret = LB_STATUS_ERROR_NOT_EXIST;
1758 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1760 ErrPrint("Parameter is not matched\n");
1761 ret = LB_STATUS_ERROR_INVALID;
1767 * Trust the package name which are sent by the client.
1768 * The package has to be a livebox package name.
1770 inst = package_find_instance_by_id(pkgname, id);
1772 ErrPrint("Instance[%s] is not exists\n", id);
1773 ret = LB_STATUS_ERROR_NOT_EXIST;
1777 pkg = instance_package(inst);
1779 ErrPrint("Package[%s] info is not exists\n", pkgname);
1780 ret = LB_STATUS_ERROR_FAULT;
1784 if (package_is_fault(pkg)) {
1787 * If the package is registered as fault module,
1788 * slave has not load it, so we don't need to do anything at here!
1790 DbgPrint("Package[%s] is faulted\n", pkgname);
1791 ret = LB_STATUS_ERROR_FAULT;
1792 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1793 struct buffer_info *buffer;
1794 struct slave_node *slave;
1795 //struct packet *packet;
1797 buffer = instance_lb_buffer(inst);
1799 ErrPrint("Instance[%s] has no buffer\n", id);
1800 ret = LB_STATUS_ERROR_FAULT;
1804 slave = package_slave(pkg);
1806 ErrPrint("Package[%s] has no slave\n", pkgname);
1807 ret = LB_STATUS_ERROR_INVALID;
1812 packet = packet_create_noack("lb_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1814 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1815 ret = LB_STATUS_ERROR_FAULT;
1819 packet_ref((struct packet *)packet);
1820 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1821 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1822 struct script_info *script;
1825 script = instance_lb_script(inst);
1827 ret = LB_STATUS_ERROR_FAULT;
1831 e = script_handler_evas(script);
1833 ret = LB_STATUS_ERROR_FAULT;
1837 script_handler_update_pointer(script, x, y, -1);
1838 evas_event_feed_mouse_in(e, timestamp, NULL);
1841 ErrPrint("Unsupported package\n");
1842 ret = LB_STATUS_ERROR_INVALID;
1846 /*! \note No reply packet */
1850 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 */
1852 struct client_node *client;
1853 const char *pkgname;
1859 struct inst_info *inst;
1860 const struct pkg_info *pkg;
1862 client = client_find_by_pid(pid);
1864 ErrPrint("Client %d is not exists\n", pid);
1865 ret = LB_STATUS_ERROR_NOT_EXIST;
1869 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1871 ErrPrint("Parameter is not matched\n");
1872 ret = LB_STATUS_ERROR_INVALID;
1878 * Trust the package name which are sent by the client.
1879 * The package has to be a livebox package name.
1881 inst = package_find_instance_by_id(pkgname, id);
1883 ErrPrint("Instance[%s] is not exists\n", id);
1884 ret = LB_STATUS_ERROR_NOT_EXIST;
1888 pkg = instance_package(inst);
1890 ErrPrint("Package[%s] info is not exists\n", pkgname);
1891 ret = LB_STATUS_ERROR_FAULT;
1895 if (package_is_fault(pkg)) {
1898 * If the package is registered as fault module,
1899 * slave has not load it, so we don't need to do anything at here!
1901 DbgPrint("Package[%s] is faulted\n", pkgname);
1902 ret = LB_STATUS_ERROR_FAULT;
1903 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1904 struct buffer_info *buffer;
1905 struct slave_node *slave;
1906 //struct packet *packet;
1908 buffer = instance_lb_buffer(inst);
1910 ErrPrint("Instance[%s] has no buffer\n", id);
1911 ret = LB_STATUS_ERROR_FAULT;
1915 slave = package_slave(pkg);
1917 ErrPrint("Package[%s] has no slave\n", pkgname);
1918 ret = LB_STATUS_ERROR_INVALID;
1923 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1925 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1926 ret = LB_STATUS_ERROR_FAULT;
1931 packet_ref((struct packet *)packet);
1932 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1933 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1934 struct script_info *script;
1937 script = instance_lb_script(inst);
1939 ret = LB_STATUS_ERROR_FAULT;
1943 e = script_handler_evas(script);
1945 ret = LB_STATUS_ERROR_FAULT;
1949 script_handler_update_pointer(script, x, y, -1);
1950 evas_event_feed_mouse_out(e, timestamp, NULL);
1953 ErrPrint("Unsupported package\n");
1954 ret = LB_STATUS_ERROR_INVALID;
1958 /*! \note No reply packet */
1962 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 */
1964 struct client_node *client;
1965 const char *pkgname;
1971 struct inst_info *inst;
1972 const struct pkg_info *pkg;
1974 client = client_find_by_pid(pid);
1976 ErrPrint("Client %d is not exists\n", pid);
1977 ret = LB_STATUS_ERROR_NOT_EXIST;
1981 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1983 ErrPrint("Parameter is not matched\n");
1984 ret = LB_STATUS_ERROR_INVALID;
1990 * Trust the package name which are sent by the client.
1991 * The package has to be a livebox package name.
1993 inst = package_find_instance_by_id(pkgname, id);
1995 ErrPrint("Instance[%s] is not exists\n", id);
1996 ret = LB_STATUS_ERROR_NOT_EXIST;
2000 pkg = instance_package(inst);
2002 ErrPrint("Package[%s] info is not exists\n", pkgname);
2003 ret = LB_STATUS_ERROR_FAULT;
2007 if (package_is_fault(pkg)) {
2010 * If the package is registered as fault module,
2011 * slave has not load it, so we don't need to do anything at here!
2013 DbgPrint("Package[%s] is faulted\n", pkgname);
2014 ret = LB_STATUS_ERROR_FAULT;
2015 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2016 struct buffer_info *buffer;
2017 struct slave_node *slave;
2018 // struct packet *packet;
2020 buffer = instance_lb_buffer(inst);
2022 ErrPrint("Instance[%s] has no buffer\n", id);
2023 ret = LB_STATUS_ERROR_FAULT;
2027 slave = package_slave(pkg);
2029 ErrPrint("Package[%s] has no slave\n", pkgname);
2030 ret = LB_STATUS_ERROR_INVALID;
2035 packet = packet_create_noack("lb_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2037 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2038 ret = LB_STATUS_ERROR_FAULT;
2043 packet_ref((struct packet *)packet);
2044 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2045 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2046 struct script_info *script;
2049 script = instance_lb_script(inst);
2051 ret = LB_STATUS_ERROR_FAULT;
2055 e = script_handler_evas(script);
2057 ret = LB_STATUS_ERROR_FAULT;
2061 script_handler_update_pointer(script, x, y, 1);
2062 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
2063 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
2066 ErrPrint("Unsupported package\n");
2067 ret = LB_STATUS_ERROR_INVALID;
2071 /*! \note No reply packet */
2075 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 */
2077 struct client_node *client;
2078 const char *pkgname;
2084 struct inst_info *inst;
2085 const struct pkg_info *pkg;
2087 client = client_find_by_pid(pid);
2089 ErrPrint("Client %d is not exists\n", pid);
2090 ret = LB_STATUS_ERROR_NOT_EXIST;
2094 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2096 ErrPrint("Parameter is not matched\n");
2097 ret = LB_STATUS_ERROR_INVALID;
2103 * Trust the package name which are sent by the client.
2104 * The package has to be a livebox package name.
2106 inst = package_find_instance_by_id(pkgname, id);
2108 ErrPrint("Instance[%s] is not exists\n", id);
2109 ret = LB_STATUS_ERROR_NOT_EXIST;
2113 pkg = instance_package(inst);
2115 ErrPrint("Package[%s] info is not exists\n", pkgname);
2116 ret = LB_STATUS_ERROR_FAULT;
2120 if (package_is_fault(pkg)) {
2123 * If the package is registered as fault module,
2124 * slave has not load it, so we don't need to do anything at here!
2126 DbgPrint("Package[%s] is faulted\n", pkgname);
2127 ret = LB_STATUS_ERROR_FAULT;
2128 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2129 struct buffer_info *buffer;
2130 struct slave_node *slave;
2131 //struct packet *packet;
2133 buffer = instance_lb_buffer(inst);
2135 ErrPrint("Instance[%s] has no buffer\n", id);
2136 ret = LB_STATUS_ERROR_FAULT;
2140 slave = package_slave(pkg);
2142 ErrPrint("Package[%s] has no slave\n", pkgname);
2143 ret = LB_STATUS_ERROR_INVALID;
2148 packet = packet_create_noack("lb_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2150 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2151 ret = LB_STATUS_ERROR_FAULT;
2156 packet_ref((struct packet *)packet);
2157 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2158 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2159 struct script_info *script;
2162 script = instance_lb_script(inst);
2164 ret = LB_STATUS_ERROR_FAULT;
2168 e = script_handler_evas(script);
2170 ret = LB_STATUS_ERROR_FAULT;
2174 script_handler_update_pointer(script, x, y, 0);
2175 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
2176 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
2179 ErrPrint("Unsupported package\n");
2180 ret = LB_STATUS_ERROR_INVALID;
2184 /*! \note No reply packet */
2188 static struct packet *client_pd_access_read(pid_t pid, int handle, const struct packet *packet)
2190 struct client_node *client;
2191 const char *pkgname;
2197 struct inst_info *inst;
2198 const struct pkg_info *pkg;
2200 client = client_find_by_pid(pid);
2202 ErrPrint("Client %d is not exists\n", pid);
2203 ret = LB_STATUS_ERROR_NOT_EXIST;
2207 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2209 ErrPrint("Invalid parameter\n");
2210 ret = LB_STATUS_ERROR_INVALID;
2216 * Trust the package name which are sent by the client.
2217 * The package has to be a livebox package name.
2219 inst = package_find_instance_by_id(pkgname, id);
2221 ErrPrint("Instance[%s] is not exists\n", id);
2222 ret = LB_STATUS_ERROR_NOT_EXIST;
2226 pkg = instance_package(inst);
2228 ErrPrint("Package[%s] info is not found\n", pkgname);
2229 ret = LB_STATUS_ERROR_FAULT;
2233 if (package_is_fault(pkg)) {
2236 * If the package is registered as fault module,
2237 * slave has not load it, so we don't need to do anything at here!
2239 DbgPrint("Package[%s] is faulted\n", pkgname);
2240 ret = LB_STATUS_ERROR_FAULT;
2241 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2242 struct buffer_info *buffer;
2243 struct slave_node *slave;
2244 // struct packet *packet;
2246 buffer = instance_pd_buffer(inst);
2248 ErrPrint("Instance[%s] has no buffer\n", id);
2249 ret = LB_STATUS_ERROR_FAULT;
2253 slave = package_slave(pkg);
2255 ErrPrint("Package[%s] has no slave\n", pkgname);
2256 ret = LB_STATUS_ERROR_INVALID;
2261 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2263 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2264 ret = LB_STATUS_ERROR_FAULT;
2269 packet_ref((struct packet *)packet);
2270 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2271 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2272 struct script_info *script;
2275 script = instance_pd_script(inst);
2277 ret = LB_STATUS_ERROR_FAULT;
2281 e = script_handler_evas(script);
2283 ret = LB_STATUS_ERROR_FAULT;
2287 script_handler_update_pointer(script, x, y, -1);
2289 * \TODO: Push up the ACCESS_READ event
2293 ErrPrint("Unsupported package\n");
2294 ret = LB_STATUS_ERROR_INVALID;
2298 /*! \note No reply packet */
2302 static struct packet *client_pd_access_read_prev(pid_t pid, int handle, const struct packet *packet)
2304 struct client_node *client;
2305 const char *pkgname;
2311 struct inst_info *inst;
2312 const struct pkg_info *pkg;
2314 client = client_find_by_pid(pid);
2316 ErrPrint("Client %d is not exists\n", pid);
2317 ret = LB_STATUS_ERROR_NOT_EXIST;
2321 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2323 ErrPrint("Invalid parameter\n");
2324 ret = LB_STATUS_ERROR_INVALID;
2330 * Trust the package name which are sent by the client.
2331 * The package has to be a livebox package name.
2333 inst = package_find_instance_by_id(pkgname, id);
2335 ErrPrint("Instance[%s] is not exists\n", id);
2336 ret = LB_STATUS_ERROR_NOT_EXIST;
2340 pkg = instance_package(inst);
2342 ErrPrint("Package[%s] info is not found\n", pkgname);
2343 ret = LB_STATUS_ERROR_FAULT;
2347 if (package_is_fault(pkg)) {
2350 * If the package is registered as fault module,
2351 * slave has not load it, so we don't need to do anything at here!
2353 DbgPrint("Package[%s] is faulted\n", pkgname);
2354 ret = LB_STATUS_ERROR_FAULT;
2355 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2356 struct buffer_info *buffer;
2357 struct slave_node *slave;
2358 // struct packet *packet;
2360 buffer = instance_pd_buffer(inst);
2362 ErrPrint("Instance[%s] has no buffer\n", id);
2363 ret = LB_STATUS_ERROR_FAULT;
2367 slave = package_slave(pkg);
2369 ErrPrint("Package[%s] has no slave\n", pkgname);
2370 ret = LB_STATUS_ERROR_INVALID;
2375 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2377 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2378 ret = LB_STATUS_ERROR_FAULT;
2383 packet_ref((struct packet *)packet);
2384 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2385 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2386 struct script_info *script;
2389 script = instance_pd_script(inst);
2391 ret = LB_STATUS_ERROR_FAULT;
2395 e = script_handler_evas(script);
2397 ret = LB_STATUS_ERROR_FAULT;
2401 script_handler_update_pointer(script, x, y, -1);
2403 * \TODO: Push up the ACCESS_READ_PREV event
2407 ErrPrint("Unsupported package\n");
2408 ret = LB_STATUS_ERROR_INVALID;
2412 /*! \note No reply packet */
2416 static struct packet *client_pd_access_read_next(pid_t pid, int handle, const struct packet *packet)
2418 struct client_node *client;
2419 const char *pkgname;
2425 struct inst_info *inst;
2426 const struct pkg_info *pkg;
2428 client = client_find_by_pid(pid);
2430 ErrPrint("Client %d is not exists\n", pid);
2431 ret = LB_STATUS_ERROR_NOT_EXIST;
2435 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2437 ErrPrint("Invalid parameter\n");
2438 ret = LB_STATUS_ERROR_INVALID;
2444 * Trust the package name which are sent by the client.
2445 * The package has to be a livebox package name.
2447 inst = package_find_instance_by_id(pkgname, id);
2449 ErrPrint("Instance[%s] is not exists\n", id);
2450 ret = LB_STATUS_ERROR_NOT_EXIST;
2454 pkg = instance_package(inst);
2456 ErrPrint("Package[%s] info is not found\n", pkgname);
2457 ret = LB_STATUS_ERROR_FAULT;
2461 if (package_is_fault(pkg)) {
2464 * If the package is registered as fault module,
2465 * slave has not load it, so we don't need to do anything at here!
2467 DbgPrint("Package[%s] is faulted\n", pkgname);
2468 ret = LB_STATUS_ERROR_FAULT;
2469 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2470 struct buffer_info *buffer;
2471 struct slave_node *slave;
2472 // struct packet *packet;
2474 buffer = instance_pd_buffer(inst);
2476 ErrPrint("Instance[%s] has no buffer\n", id);
2477 ret = LB_STATUS_ERROR_FAULT;
2481 slave = package_slave(pkg);
2483 ErrPrint("Package[%s] has no slave\n", pkgname);
2484 ret = LB_STATUS_ERROR_INVALID;
2489 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2491 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2492 ret = LB_STATUS_ERROR_FAULT;
2497 packet_ref((struct packet *)packet);
2498 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2499 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2500 struct script_info *script;
2503 script = instance_pd_script(inst);
2505 ret = LB_STATUS_ERROR_FAULT;
2509 e = script_handler_evas(script);
2511 ret = LB_STATUS_ERROR_FAULT;
2515 script_handler_update_pointer(script, x, y, -1);
2517 * \TODO: Push up the ACCESS_READ_NEXT event
2521 ErrPrint("Unsupported package\n");
2522 ret = LB_STATUS_ERROR_INVALID;
2526 /*! \note No reply packet */
2530 static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
2532 struct client_node *client;
2533 const char *pkgname;
2539 struct inst_info *inst;
2540 const struct pkg_info *pkg;
2542 client = client_find_by_pid(pid);
2544 ErrPrint("Client %d is not exists\n", pid);
2545 ret = LB_STATUS_ERROR_NOT_EXIST;
2549 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2551 ErrPrint("Invalid parameter\n");
2552 ret = LB_STATUS_ERROR_INVALID;
2558 * Trust the package name which are sent by the client.
2559 * The package has to be a livebox package name.
2561 inst = package_find_instance_by_id(pkgname, id);
2563 ErrPrint("Instance[%s] is not exists\n", id);
2564 ret = LB_STATUS_ERROR_NOT_EXIST;
2568 pkg = instance_package(inst);
2570 ErrPrint("Package[%s] info is not found\n", pkgname);
2571 ret = LB_STATUS_ERROR_FAULT;
2575 if (package_is_fault(pkg)) {
2578 * If the package is registered as fault module,
2579 * slave has not load it, so we don't need to do anything at here!
2581 DbgPrint("Package[%s] is faulted\n", pkgname);
2582 ret = LB_STATUS_ERROR_FAULT;
2583 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2584 struct buffer_info *buffer;
2585 struct slave_node *slave;
2586 // struct packet *packet;
2588 buffer = instance_pd_buffer(inst);
2590 ErrPrint("Instance[%s] has no buffer\n", id);
2591 ret = LB_STATUS_ERROR_FAULT;
2595 slave = package_slave(pkg);
2597 ErrPrint("Package[%s] has no slave\n", pkgname);
2598 ret = LB_STATUS_ERROR_INVALID;
2603 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2605 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2606 ret = LB_STATUS_ERROR_FAULT;
2611 packet_ref((struct packet *)packet);
2612 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2613 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2614 struct script_info *script;
2617 script = instance_pd_script(inst);
2619 ret = LB_STATUS_ERROR_FAULT;
2623 e = script_handler_evas(script);
2625 ret = LB_STATUS_ERROR_FAULT;
2629 script_handler_update_pointer(script, x, y, -1);
2631 * \TODO: Push up the ACCESS_READ_ACTIVATE event
2635 ErrPrint("Unsupported package\n");
2636 ret = LB_STATUS_ERROR_INVALID;
2640 /*! \note No reply packet */
2644 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
2646 struct client_node *client;
2647 const char *pkgname;
2653 struct inst_info *inst;
2654 const struct pkg_info *pkg;
2656 client = client_find_by_pid(pid);
2658 ErrPrint("Client %d is not exists\n", pid);
2659 ret = LB_STATUS_ERROR_NOT_EXIST;
2663 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2665 ErrPrint("Invalid parameter\n");
2666 ret = LB_STATUS_ERROR_INVALID;
2672 * Trust the package name which are sent by the client.
2673 * The package has to be a livebox package name.
2675 inst = package_find_instance_by_id(pkgname, id);
2677 ErrPrint("Instance[%s] is not exists\n", id);
2678 ret = LB_STATUS_ERROR_NOT_EXIST;
2682 pkg = instance_package(inst);
2684 ErrPrint("Package[%s] info is not found\n", pkgname);
2685 ret = LB_STATUS_ERROR_FAULT;
2689 if (package_is_fault(pkg)) {
2692 * If the package is registered as fault module,
2693 * slave has not load it, so we don't need to do anything at here!
2695 DbgPrint("Package[%s] is faulted\n", pkgname);
2696 ret = LB_STATUS_ERROR_FAULT;
2697 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2698 struct buffer_info *buffer;
2699 struct slave_node *slave;
2700 // struct packet *packet;
2702 buffer = instance_pd_buffer(inst);
2704 ErrPrint("Instance[%s] has no buffer\n", id);
2705 ret = LB_STATUS_ERROR_FAULT;
2709 slave = package_slave(pkg);
2711 ErrPrint("Package[%s] has no slave\n", pkgname);
2712 ret = LB_STATUS_ERROR_INVALID;
2717 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2719 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2720 ret = LB_STATUS_ERROR_FAULT;
2725 packet_ref((struct packet *)packet);
2726 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2727 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2728 struct script_info *script;
2731 script = instance_pd_script(inst);
2733 ret = LB_STATUS_ERROR_FAULT;
2737 e = script_handler_evas(script);
2739 ret = LB_STATUS_ERROR_FAULT;
2743 script_handler_update_pointer(script, x, y, -1);
2745 * \TODO: Push up the KEY_DOWN event
2749 ErrPrint("Unsupported package\n");
2750 ret = LB_STATUS_ERROR_INVALID;
2754 /*! \note No reply packet */
2758 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
2760 struct client_node *client;
2764 client = client_find_by_pid(pid);
2766 ErrPrint("Client %d is paused - manually reported\n", pid);
2767 ret = LB_STATUS_ERROR_NOT_EXIST;
2771 ret = packet_get(packet, "d", ×tamp);
2773 ErrPrint("Invalid parameter\n");
2774 ret = LB_STATUS_ERROR_INVALID;
2779 DbgPrint("XMONITOR enabled. ignore client paused request\n");
2781 xmonitor_pause(client);
2787 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
2789 struct client_node *client;
2793 client = client_find_by_pid(pid);
2795 ErrPrint("Client %d is paused - manually reported\n", pid);
2796 ret = LB_STATUS_ERROR_NOT_EXIST;
2800 ret = packet_get(packet, "d", ×tamp);
2802 ErrPrint("Invalid parameter\n");
2803 ret = LB_STATUS_ERROR_INVALID;
2808 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
2810 xmonitor_resume(client);
2816 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
2818 struct client_node *client;
2819 const char *pkgname;
2825 struct inst_info *inst;
2826 const struct pkg_info *pkg;
2828 client = client_find_by_pid(pid);
2830 ErrPrint("Client %d is not exists\n", pid);
2831 ret = LB_STATUS_ERROR_NOT_EXIST;
2835 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2837 ErrPrint("Invalid parameter\n");
2838 ret = LB_STATUS_ERROR_INVALID;
2844 * Trust the package name which are sent by the client.
2845 * The package has to be a livebox package name.
2847 inst = package_find_instance_by_id(pkgname, id);
2849 ErrPrint("Instance[%s] is not exists\n", id);
2850 ret = LB_STATUS_ERROR_NOT_EXIST;
2854 pkg = instance_package(inst);
2856 ErrPrint("Package[%s] info is not found\n", pkgname);
2857 ret = LB_STATUS_ERROR_FAULT;
2861 if (package_is_fault(pkg)) {
2864 * If the package is registered as fault module,
2865 * slave has not load it, so we don't need to do anything at here!
2867 DbgPrint("Package[%s] is faulted\n", pkgname);
2868 ret = LB_STATUS_ERROR_FAULT;
2869 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2870 struct buffer_info *buffer;
2871 struct slave_node *slave;
2872 // struct packet *packet;
2874 buffer = instance_pd_buffer(inst);
2876 ErrPrint("Instance[%s] has no buffer\n", id);
2877 ret = LB_STATUS_ERROR_FAULT;
2881 slave = package_slave(pkg);
2883 ErrPrint("Package[%s] has no slave\n", pkgname);
2884 ret = LB_STATUS_ERROR_INVALID;
2889 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2891 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2892 ret = LB_STATUS_ERROR_FAULT;
2897 packet_ref((struct packet *)packet);
2898 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2899 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2900 struct script_info *script;
2903 script = instance_pd_script(inst);
2905 ret = LB_STATUS_ERROR_FAULT;
2909 e = script_handler_evas(script);
2911 ret = LB_STATUS_ERROR_FAULT;
2915 script_handler_update_pointer(script, x, y, -1);
2917 * \TODO: Push up the KEY_UP event
2921 ErrPrint("Unsupported package\n");
2922 ret = LB_STATUS_ERROR_INVALID;
2926 /*! \note No reply packet */
2930 static struct packet *client_lb_access_read(pid_t pid, int handle, const struct packet *packet)
2932 struct client_node *client;
2933 const char *pkgname;
2939 struct inst_info *inst;
2940 const struct pkg_info *pkg;
2942 client = client_find_by_pid(pid);
2944 ErrPrint("Client %d is not exists\n", pid);
2945 ret = LB_STATUS_ERROR_NOT_EXIST;
2949 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2951 ErrPrint("Parameter is not matched\n");
2952 ret = LB_STATUS_ERROR_INVALID;
2958 * Trust the package name which are sent by the client.
2959 * The package has to be a livebox package name.
2961 inst = package_find_instance_by_id(pkgname, id);
2963 ErrPrint("Instance[%s] is not exists\n", id);
2964 ret = LB_STATUS_ERROR_NOT_EXIST;
2968 pkg = instance_package(inst);
2970 ErrPrint("Package[%s] info is not exists\n", pkgname);
2971 ret = LB_STATUS_ERROR_FAULT;
2975 if (package_is_fault(pkg)) {
2978 * If the package is registered as fault module,
2979 * slave has not load it, so we don't need to do anything at here!
2981 DbgPrint("Package[%s] is faulted\n", pkgname);
2982 ret = LB_STATUS_ERROR_FAULT;
2983 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2984 struct buffer_info *buffer;
2985 struct slave_node *slave;
2986 //struct packet *packet;
2988 buffer = instance_lb_buffer(inst);
2990 ErrPrint("Instance[%s] has no buffer\n", id);
2991 ret = LB_STATUS_ERROR_FAULT;
2995 slave = package_slave(pkg);
2997 ErrPrint("Package[%s] has no slave\n", pkgname);
2998 ret = LB_STATUS_ERROR_INVALID;
3003 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3005 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3006 ret = LB_STATUS_ERROR_FAULT;
3011 packet_ref((struct packet *)packet);
3012 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3013 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3014 struct script_info *script;
3017 script = instance_lb_script(inst);
3019 ret = LB_STATUS_ERROR_FAULT;
3023 e = script_handler_evas(script);
3025 ret = LB_STATUS_ERROR_FAULT;
3029 script_handler_update_pointer(script, x, y, -1);
3032 * \TODO: Feed up this ACCESS_READ event
3036 ErrPrint("Unsupported package\n");
3037 ret = LB_STATUS_ERROR_INVALID;
3041 /*! \note No reply packet */
3045 static struct packet *client_lb_access_read_prev(pid_t pid, int handle, const struct packet *packet)
3047 struct client_node *client;
3048 const char *pkgname;
3054 struct inst_info *inst;
3055 const struct pkg_info *pkg;
3057 client = client_find_by_pid(pid);
3059 ErrPrint("Client %d is not exists\n", pid);
3060 ret = LB_STATUS_ERROR_NOT_EXIST;
3064 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3066 ErrPrint("Parameter is not matched\n");
3067 ret = LB_STATUS_ERROR_INVALID;
3073 * Trust the package name which are sent by the client.
3074 * The package has to be a livebox package name.
3076 inst = package_find_instance_by_id(pkgname, id);
3078 ErrPrint("Instance[%s] is not exists\n", id);
3079 ret = LB_STATUS_ERROR_NOT_EXIST;
3083 pkg = instance_package(inst);
3085 ErrPrint("Package[%s] info is not exists\n", pkgname);
3086 ret = LB_STATUS_ERROR_FAULT;
3090 if (package_is_fault(pkg)) {
3093 * If the package is registered as fault module,
3094 * slave has not load it, so we don't need to do anything at here!
3096 DbgPrint("Package[%s] is faulted\n", pkgname);
3097 ret = LB_STATUS_ERROR_FAULT;
3098 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3099 struct buffer_info *buffer;
3100 struct slave_node *slave;
3101 //struct packet *packet;
3103 buffer = instance_lb_buffer(inst);
3105 ErrPrint("Instance[%s] has no buffer\n", id);
3106 ret = LB_STATUS_ERROR_FAULT;
3110 slave = package_slave(pkg);
3112 ErrPrint("Package[%s] has no slave\n", pkgname);
3113 ret = LB_STATUS_ERROR_INVALID;
3118 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3120 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3121 ret = LB_STATUS_ERROR_FAULT;
3126 packet_ref((struct packet *)packet);
3127 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3128 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3129 struct script_info *script;
3132 script = instance_lb_script(inst);
3134 ret = LB_STATUS_ERROR_FAULT;
3138 e = script_handler_evas(script);
3140 ret = LB_STATUS_ERROR_FAULT;
3144 script_handler_update_pointer(script, x, y, -1);
3147 * \TODO: Feed up this ACCESS_READ_PREV event
3151 ErrPrint("Unsupported package\n");
3152 ret = LB_STATUS_ERROR_INVALID;
3156 /*! \note No reply packet */
3160 static struct packet *client_lb_access_read_next(pid_t pid, int handle, const struct packet *packet)
3162 struct client_node *client;
3163 const char *pkgname;
3169 struct inst_info *inst;
3170 const struct pkg_info *pkg;
3172 client = client_find_by_pid(pid);
3174 ErrPrint("Client %d is not exists\n", pid);
3175 ret = LB_STATUS_ERROR_NOT_EXIST;
3179 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3181 ErrPrint("Parameter is not matched\n");
3182 ret = LB_STATUS_ERROR_INVALID;
3188 * Trust the package name which are sent by the client.
3189 * The package has to be a livebox package name.
3191 inst = package_find_instance_by_id(pkgname, id);
3193 ErrPrint("Instance[%s] is not exists\n", id);
3194 ret = LB_STATUS_ERROR_NOT_EXIST;
3198 pkg = instance_package(inst);
3200 ErrPrint("Package[%s] info is not exists\n", pkgname);
3201 ret = LB_STATUS_ERROR_FAULT;
3205 if (package_is_fault(pkg)) {
3208 * If the package is registered as fault module,
3209 * slave has not load it, so we don't need to do anything at here!
3211 DbgPrint("Package[%s] is faulted\n", pkgname);
3212 ret = LB_STATUS_ERROR_FAULT;
3213 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3214 struct buffer_info *buffer;
3215 struct slave_node *slave;
3216 //struct packet *packet;
3218 buffer = instance_lb_buffer(inst);
3220 ErrPrint("Instance[%s] has no buffer\n", id);
3221 ret = LB_STATUS_ERROR_FAULT;
3225 slave = package_slave(pkg);
3227 ErrPrint("Package[%s] has no slave\n", pkgname);
3228 ret = LB_STATUS_ERROR_INVALID;
3233 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3235 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3236 ret = LB_STATUS_ERROR_FAULT;
3241 packet_ref((struct packet *)packet);
3242 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3243 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3244 struct script_info *script;
3247 script = instance_lb_script(inst);
3249 ret = LB_STATUS_ERROR_FAULT;
3253 e = script_handler_evas(script);
3255 ret = LB_STATUS_ERROR_FAULT;
3259 script_handler_update_pointer(script, x, y, -1);
3262 * \TODO: Feed up this ACCESS_READ_NEXT event
3266 ErrPrint("Unsupported package\n");
3267 ret = LB_STATUS_ERROR_INVALID;
3271 /*! \note No reply packet */
3275 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
3277 struct client_node *client;
3278 const char *pkgname;
3284 struct inst_info *inst;
3285 const struct pkg_info *pkg;
3287 client = client_find_by_pid(pid);
3289 ErrPrint("Client %d is not exists\n", pid);
3290 ret = LB_STATUS_ERROR_NOT_EXIST;
3294 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3296 ErrPrint("Parameter is not matched\n");
3297 ret = LB_STATUS_ERROR_INVALID;
3303 * Trust the package name which are sent by the client.
3304 * The package has to be a livebox package name.
3306 inst = package_find_instance_by_id(pkgname, id);
3308 ErrPrint("Instance[%s] is not exists\n", id);
3309 ret = LB_STATUS_ERROR_NOT_EXIST;
3313 pkg = instance_package(inst);
3315 ErrPrint("Package[%s] info is not exists\n", pkgname);
3316 ret = LB_STATUS_ERROR_FAULT;
3320 if (package_is_fault(pkg)) {
3323 * If the package is registered as fault module,
3324 * slave has not load it, so we don't need to do anything at here!
3326 DbgPrint("Package[%s] is faulted\n", pkgname);
3327 ret = LB_STATUS_ERROR_FAULT;
3328 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3329 struct buffer_info *buffer;
3330 struct slave_node *slave;
3331 //struct packet *packet;
3333 buffer = instance_lb_buffer(inst);
3335 ErrPrint("Instance[%s] has no buffer\n", id);
3336 ret = LB_STATUS_ERROR_FAULT;
3340 slave = package_slave(pkg);
3342 ErrPrint("Package[%s] has no slave\n", pkgname);
3343 ret = LB_STATUS_ERROR_INVALID;
3348 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3350 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3351 ret = LB_STATUS_ERROR_FAULT;
3356 packet_ref((struct packet *)packet);
3357 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3358 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3359 struct script_info *script;
3362 script = instance_lb_script(inst);
3364 ret = LB_STATUS_ERROR_FAULT;
3368 e = script_handler_evas(script);
3370 ret = LB_STATUS_ERROR_FAULT;
3374 script_handler_update_pointer(script, x, y, -1);
3377 * \TODO: Feed up this ACCESS_ACTIVATE event
3381 ErrPrint("Unsupported package\n");
3382 ret = LB_STATUS_ERROR_INVALID;
3386 /*! \note No reply packet */
3390 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
3392 struct client_node *client;
3393 const char *pkgname;
3399 struct inst_info *inst;
3400 const struct pkg_info *pkg;
3402 client = client_find_by_pid(pid);
3404 ErrPrint("Client %d is not exists\n", pid);
3405 ret = LB_STATUS_ERROR_NOT_EXIST;
3409 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3411 ErrPrint("Parameter is not matched\n");
3412 ret = LB_STATUS_ERROR_INVALID;
3418 * Trust the package name which are sent by the client.
3419 * The package has to be a livebox package name.
3421 inst = package_find_instance_by_id(pkgname, id);
3423 ErrPrint("Instance[%s] is not exists\n", id);
3424 ret = LB_STATUS_ERROR_NOT_EXIST;
3428 pkg = instance_package(inst);
3430 ErrPrint("Package[%s] info is not exists\n", pkgname);
3431 ret = LB_STATUS_ERROR_FAULT;
3435 if (package_is_fault(pkg)) {
3438 * If the package is registered as fault module,
3439 * slave has not load it, so we don't need to do anything at here!
3441 DbgPrint("Package[%s] is faulted\n", pkgname);
3442 ret = LB_STATUS_ERROR_FAULT;
3443 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3444 struct buffer_info *buffer;
3445 struct slave_node *slave;
3446 //struct packet *packet;
3448 buffer = instance_lb_buffer(inst);
3450 ErrPrint("Instance[%s] has no buffer\n", id);
3451 ret = LB_STATUS_ERROR_FAULT;
3455 slave = package_slave(pkg);
3457 ErrPrint("Package[%s] has no slave\n", pkgname);
3458 ret = LB_STATUS_ERROR_INVALID;
3463 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3465 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3466 ret = LB_STATUS_ERROR_FAULT;
3471 packet_ref((struct packet *)packet);
3472 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3473 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3474 struct script_info *script;
3477 script = instance_lb_script(inst);
3479 ret = LB_STATUS_ERROR_FAULT;
3483 e = script_handler_evas(script);
3485 ret = LB_STATUS_ERROR_FAULT;
3489 script_handler_update_pointer(script, x, y, -1);
3492 * \TODO: Feed up this KEY_DOWN event
3496 ErrPrint("Unsupported package\n");
3497 ret = LB_STATUS_ERROR_INVALID;
3501 /*! \note No reply packet */
3505 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
3507 struct client_node *client;
3508 const char *pkgname;
3514 struct inst_info *inst;
3515 const struct pkg_info *pkg;
3517 client = client_find_by_pid(pid);
3519 ErrPrint("Client %d is not exists\n", pid);
3520 ret = LB_STATUS_ERROR_NOT_EXIST;
3524 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3526 ErrPrint("Parameter is not matched\n");
3527 ret = LB_STATUS_ERROR_INVALID;
3533 * Trust the package name which are sent by the client.
3534 * The package has to be a livebox package name.
3536 inst = package_find_instance_by_id(pkgname, id);
3538 ErrPrint("Instance[%s] is not exists\n", id);
3539 ret = LB_STATUS_ERROR_NOT_EXIST;
3543 pkg = instance_package(inst);
3545 ErrPrint("Package[%s] info is not exists\n", pkgname);
3546 ret = LB_STATUS_ERROR_FAULT;
3550 if (package_is_fault(pkg)) {
3553 * If the package is registered as fault module,
3554 * slave has not load it, so we don't need to do anything at here!
3556 DbgPrint("Package[%s] is faulted\n", pkgname);
3557 ret = LB_STATUS_ERROR_FAULT;
3558 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3559 struct buffer_info *buffer;
3560 struct slave_node *slave;
3561 //struct packet *packet;
3563 buffer = instance_lb_buffer(inst);
3565 ErrPrint("Instance[%s] has no buffer\n", id);
3566 ret = LB_STATUS_ERROR_FAULT;
3570 slave = package_slave(pkg);
3572 ErrPrint("Package[%s] has no slave\n", pkgname);
3573 ret = LB_STATUS_ERROR_INVALID;
3578 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3580 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3581 ret = LB_STATUS_ERROR_FAULT;
3586 packet_ref((struct packet *)packet);
3587 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3588 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3589 struct script_info *script;
3592 script = instance_lb_script(inst);
3594 ret = LB_STATUS_ERROR_FAULT;
3598 e = script_handler_evas(script);
3600 ret = LB_STATUS_ERROR_FAULT;
3604 script_handler_update_pointer(script, x, y, -1);
3607 * \TODO: Feed up this KEY_UP event
3611 ErrPrint("Unsupported package\n");
3612 ret = LB_STATUS_ERROR_INVALID;
3616 /*! \note No reply packet */
3620 static int release_pixmap_cb(struct client_node *client, void *canvas)
3622 DbgPrint("Forcely unref the \"buffer\"\n");
3623 buffer_handler_pixmap_unref(canvas);
3624 return -1; /* Delete this callback */
3627 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 */
3629 struct packet *result;
3630 const char *pkgname;
3632 struct client_node *client;
3633 struct inst_info *inst;
3638 client = client_find_by_pid(pid);
3640 ErrPrint("Client %d is not exists\n", pid);
3644 ret = packet_get(packet, "ss", &pkgname, &id);
3646 ErrPrint("Parameter is not matched\n");
3652 * Trust the package name which are sent by the client.
3653 * The package has to be a livebox package name.
3655 inst = package_find_instance_by_id(pkgname, id);
3657 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3661 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3663 buf_ptr = buffer_handler_pixmap_ref(instance_lb_buffer(inst));
3665 ErrPrint("Failed to ref pixmap\n");
3669 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
3671 ErrPrint("Failed to add a new client deactivate callback\n");
3672 buffer_handler_pixmap_unref(buf_ptr);
3675 pixmap = buffer_handler_pixmap(instance_lb_buffer(inst));
3679 result = packet_create_reply(packet, "i", pixmap);
3681 ErrPrint("Failed to create a reply packet\n");
3686 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
3688 const char *pkgname;
3690 struct client_node *client;
3691 struct inst_info *inst;
3696 client = client_find_by_pid(pid);
3698 ErrPrint("Client %d is not exists\n", pid);
3702 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
3704 ErrPrint("Parameter is not matched\n");
3707 DbgPrint("pid[%d] pkgname[%s] id[%s] Pixmap[0x%X]\n", pid, pkgname, id, pixmap);
3711 * Trust the package name which are sent by the client.
3712 * The package has to be a livebox package name.
3714 inst = package_find_instance_by_id(pkgname, id);
3716 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3720 buf_ptr = buffer_handler_pixmap_find(pixmap);
3722 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
3726 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
3727 buffer_handler_pixmap_unref(buf_ptr);
3730 /*! \note No reply packet */
3734 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 */
3736 struct packet *result;
3737 const char *pkgname;
3739 struct client_node *client;
3740 struct inst_info *inst;
3745 client = client_find_by_pid(pid);
3747 ErrPrint("Client %d is not exists\n", pid);
3751 ret = packet_get(packet, "ss", &pkgname, &id);
3753 ErrPrint("Parameter is not matched\n");
3759 * Trust the package name which are sent by the client.
3760 * The package has to be a livebox package name.
3762 inst = package_find_instance_by_id(pkgname, id);
3764 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3768 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3770 buf_ptr = buffer_handler_pixmap_ref(instance_pd_buffer(inst));
3772 ErrPrint("Failed to ref pixmap\n");
3776 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
3778 buffer_handler_pixmap_unref(buf_ptr);
3780 pixmap = buffer_handler_pixmap(instance_pd_buffer(inst));
3782 result = packet_create_reply(packet, "i", pixmap);
3784 ErrPrint("Failed to create a reply packet\n");
3789 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
3791 const char *pkgname;
3793 struct client_node *client;
3794 struct inst_info *inst;
3799 client = client_find_by_pid(pid);
3801 ErrPrint("Client %d is not exists\n", pid);
3805 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
3807 ErrPrint("Parameter is not matched\n");
3810 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3814 * Trust the package name which are sent by the client.
3815 * The package has to be a livebox package name.
3817 inst = package_find_instance_by_id(pkgname, id);
3819 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3823 buf_ptr = buffer_handler_pixmap_find(pixmap);
3825 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
3829 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
3830 buffer_handler_pixmap_unref(buf_ptr);
3833 /*! \note No reply packet */
3837 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
3839 struct client_node *client;
3840 struct packet *result;
3841 const char *pkgname;
3845 struct inst_info *inst;
3847 client = client_find_by_pid(pid);
3849 ErrPrint("Client %d is not exists\n", pid);
3850 ret = LB_STATUS_ERROR_NOT_EXIST;
3855 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
3857 ErrPrint("Parameter is not matched\n");
3858 ret = LB_STATUS_ERROR_INVALID;
3863 DbgPrint("pid[%d] pkgname[%s] id[%s] pinup[%d]\n", pid, pkgname, id, pinup);
3867 * Trust the package name which are sent by the client.
3868 * The package has to be a livebox package name.
3870 inst = package_find_instance_by_id(pkgname, id);
3872 ret = LB_STATUS_ERROR_NOT_EXIST;
3873 else if (package_is_fault(instance_package(inst)))
3874 ret = LB_STATUS_ERROR_FAULT;
3876 ret = instance_set_pinup(inst, pinup);
3879 result = packet_create_reply(packet, "i", ret);
3881 ErrPrint("Failed to create a packet\n");
3886 static Eina_Bool lazy_pd_created_cb(void *data)
3888 DbgPrint("Send PD Create event\n");
3889 instance_client_pd_created(data, 0);
3891 instance_unref(data);
3892 return ECORE_CALLBACK_CANCEL;
3895 static Eina_Bool lazy_pd_destroyed_cb(void *data)
3897 DbgPrint("Send PD Destroy event\n");
3898 instance_client_pd_destroyed(data, 0);
3900 instance_unref(data);
3901 return ECORE_CALLBACK_CANCEL;
3904 static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
3906 struct client_node *client;
3907 struct inst_info *inst;
3908 const char *pkgname;
3914 client = client_find_by_pid(pid);
3916 ErrPrint("Client %d is not exists\n", pid);
3917 ret = LB_STATUS_ERROR_NOT_EXIST;
3921 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
3923 ErrPrint("Parameter is not correct\n");
3924 ret = LB_STATUS_ERROR_INVALID;
3928 DbgPrint("pid[%d] pkgname[%s] id[%s] %lfx%lf\n", pid, pkgname, id, x, y);
3930 inst = package_find_instance_by_id(pkgname, id);
3932 ret = LB_STATUS_ERROR_NOT_EXIST;
3933 else if (package_is_fault(instance_package(inst)))
3934 ret = LB_STATUS_ERROR_FAULT;
3935 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
3936 instance_slave_set_pd_pos(inst, x, y);
3937 ret = instance_signal_emit(inst,
3938 "pd,move", util_uri_to_path(instance_id(inst)),
3939 0.0, 0.0, 0.0, 0.0, x, y, 0);
3940 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
3944 instance_slave_set_pd_pos(inst, x, y);
3945 ix = x * instance_pd_width(inst);
3946 iy = y * instance_pd_height(inst);
3947 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
3948 ret = instance_signal_emit(inst,
3949 "pd,move", util_uri_to_path(instance_id(inst)),
3950 0.0, 0.0, 0.0, 0.0, x, y, 0);
3952 ErrPrint("Invalid PD type\n");
3953 ret = LB_STATUS_ERROR_INVALID;
3956 DbgPrint("Update PD position: %lfx%lf (%d)\n", x, y, ret);
3960 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
3962 struct client_node *client;
3963 struct packet *result;
3964 const char *pkgname;
3967 struct inst_info *inst;
3971 client = client_find_by_pid(pid);
3973 ErrPrint("Client %d is not exists\n", pid);
3974 ret = LB_STATUS_ERROR_NOT_EXIST;
3978 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
3980 ErrPrint("Parameter is not matched\n");
3981 ret = LB_STATUS_ERROR_INVALID;
3985 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3989 * Trust the package name which are sent by the client.
3990 * The package has to be a livebox package name.
3992 inst = package_find_instance_by_id(pkgname, id);
3994 ret = LB_STATUS_ERROR_NOT_EXIST;
3995 else if (package_is_fault(instance_package(inst)))
3996 ret = LB_STATUS_ERROR_FAULT;
3997 else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
3998 ret = LB_STATUS_ERROR_NO_SPACE;
3999 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4000 instance_slave_set_pd_pos(inst, x, y);
4001 ret = instance_slave_open_pd(inst, client);
4002 ret = instance_signal_emit(inst,
4003 "pd,show", util_uri_to_path(instance_id(inst)),
4004 0.0, 0.0, 0.0, 0.0, x, y, 0);
4007 * PD craeted event will be send by the acquire_buffer function.
4008 * Because the slave will make request the acquire_buffer to
4011 * instance_client_pd_created(inst);
4013 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4018 * ret value should be cared but in this case,
4019 * we ignore this for this moment, so we have to handle this error later.
4021 * if ret is less than 0, the slave has some problem.
4022 * but the script mode doesn't need slave for rendering default view of PD
4023 * so we can hanle it later.
4025 instance_slave_set_pd_pos(inst, x, y);
4026 ix = x * instance_pd_width(inst);
4027 iy = y * instance_pd_height(inst);
4028 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
4029 ret = instance_slave_open_pd(inst, client);
4030 ret = script_handler_load(instance_pd_script(inst), 1);
4034 * Send the PD created event to the clients,
4039 * But the created event has to be send afte return
4040 * from this function or the viewer couldn't care
4041 * the event correctly.
4043 inst = instance_ref(inst); /* To guarantee the inst */
4044 if (!ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst))
4045 instance_unref(inst);
4047 instance_client_pd_created(inst, ret);
4050 ErrPrint("Invalid PD TYPE\n");
4051 ret = LB_STATUS_ERROR_INVALID;
4055 result = packet_create_reply(packet, "i", ret);
4057 ErrPrint("Failed to create a packet\n");
4062 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
4064 struct client_node *client;
4065 struct packet *result;
4066 const char *pkgname;
4069 struct inst_info *inst;
4071 client = client_find_by_pid(pid);
4073 ErrPrint("Client %d is not exists\n", pid);
4074 ret = LB_STATUS_ERROR_NOT_EXIST;
4078 ret = packet_get(packet, "ss", &pkgname, &id);
4080 ErrPrint("Parameter is not matched\n");
4081 ret = LB_STATUS_ERROR_INVALID;
4085 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4089 * Trust the package name which are sent by the client.
4090 * The package has to be a livebox package name.
4092 inst = package_find_instance_by_id(pkgname, id);
4094 ret = LB_STATUS_ERROR_NOT_EXIST;
4095 else if (package_is_fault(instance_package(inst)))
4096 ret = LB_STATUS_ERROR_FAULT;
4097 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4098 ret = instance_signal_emit(inst,
4099 "pd,hide", util_uri_to_path(instance_id(inst)),
4100 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
4101 ret = instance_slave_close_pd(inst, client);
4105 * release_buffer will be called by the slave after this.
4106 * Then it will send the "pd_destroyed" event to the client
4108 * instance_client_pd_destroyed(inst);
4111 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4112 ret = script_handler_unload(instance_pd_script(inst), 1);
4113 ret = instance_slave_close_pd(inst, client);
4117 * Send the destroyed PD event to the client
4120 inst = instance_ref(inst);
4121 if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst))
4122 instance_unref(inst);
4125 ErrPrint("Invalid PD TYPE\n");
4126 ret = LB_STATUS_ERROR_INVALID;
4130 result = packet_create_reply(packet, "i", ret);
4132 ErrPrint("Failed to create a packet\n");
4137 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
4139 struct client_node *client;
4140 struct packet *result;
4141 const char *pkgname;
4143 struct pkg_info *info;
4145 client = client_find_by_pid(pid);
4147 ErrPrint("Client %d is not exists\n", pid);
4148 ret = LB_STATUS_ERROR_NOT_EXIST;
4153 ret = packet_get(packet, "s", &pkgname);
4155 ErrPrint("Parameter is not matched\n");
4156 ret = LB_STATUS_ERROR_INVALID;
4161 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
4165 * Validate the livebox package name.
4167 if (!package_is_lb_pkgname(pkgname)) {
4168 ErrPrint("%s is not a valid livebox package\n", pkgname);
4170 ret = LB_STATUS_ERROR_INVALID;
4174 info = package_find(pkgname);
4176 ret = LB_STATUS_ERROR_NOT_EXIST;
4178 ret = package_clear_fault(info);
4181 result = packet_create_reply(packet, "is", ret, pkgname);
4183 ErrPrint("Failed to create a packet\n");
4188 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
4190 const char *cluster;
4191 const char *category;
4192 struct client_node *client;
4195 client = client_find_by_pid(pid);
4197 ErrPrint("Client %d is not exists\n", pid);
4198 ret = LB_STATUS_ERROR_NOT_EXIST;
4202 ret = packet_get(packet, "ss", &cluster, &category);
4204 ErrPrint("Invalid argument\n");
4205 ret = LB_STATUS_ERROR_INVALID;
4209 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
4210 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4211 ErrPrint("Invalid cluster name\n");
4217 * SUBSCRIBE cluster & sub-cluster for a client.
4219 ret = client_subscribe(client, cluster, category);
4221 package_alter_instances_to_client(client, ALTER_CREATE);
4224 /*! \note No reply packet */
4228 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
4230 const char *cluster;
4231 struct client_node *client;
4232 struct packet *result;
4235 client = client_find_by_pid(pid);
4237 ErrPrint("Client %d is not exists\n", pid);
4238 ret = LB_STATUS_ERROR_NOT_EXIST;
4242 ret = packet_get(packet, "s", &cluster);
4244 ErrPrint("Invalid parameters\n");
4245 ret = LB_STATUS_ERROR_INVALID;
4249 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
4251 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4252 ErrPrint("Invalid cluster: %s\n", cluster);
4253 ret = LB_STATUS_ERROR_INVALID;
4260 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
4263 result = packet_create_reply(packet, "i", ret);
4265 ErrPrint("Failed to create a packet\n");
4269 static inline int update_pkg_cb(struct category *category, const char *pkgname)
4274 c_name = group_cluster_name_by_category(category);
4275 s_name = group_category_name(category);
4277 if (!c_name || !s_name || !pkgname) {
4278 ErrPrint("Name is not valid\n");
4279 return EXIT_FAILURE;
4282 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
4283 slave_rpc_request_update(pkgname, "", c_name, s_name);
4285 /* Just try to create a new package */
4286 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
4288 struct inst_info *inst;
4290 timestamp = util_timestamp();
4293 * Don't need to check the subscribed clients.
4294 * Because this callback is called by the requests of clients.
4295 * It means. some clients wants to handle this instances ;)
4297 inst = instance_create(NULL, timestamp, pkgname, DEFAULT_CONTENT, c_name, s_name, DEFAULT_PERIOD, 0, 0);
4299 ErrPrint("Failed to create a new instance\n");
4301 ErrPrint("Not enough space\n");
4303 return EXIT_SUCCESS;
4306 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
4308 struct inst_info *inst;
4309 struct client_node *client;
4310 const char *pkgname;
4314 client = client_find_by_pid(pid);
4316 ErrPrint("Cilent %d is not exists\n", pid);
4320 ret = packet_get(packet, "ss", &pkgname, &id);
4322 ErrPrint("Invalid argument\n");
4326 inst = package_find_instance_by_id(pkgname, id);
4328 } else if (package_is_fault(instance_package(inst))) {
4329 } else if (instance_client(inst) != client) {
4331 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
4335 /*! \note No reply packet */
4339 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
4341 const char *cluster_id;
4342 const char *category_id;
4343 struct client_node *client;
4345 struct cluster *cluster;
4346 struct category *category;
4347 struct context_info *info;
4348 Eina_List *info_list;
4351 client = client_find_by_pid(pid);
4353 ErrPrint("Cilent %d is not exists\n", pid);
4357 ret = packet_get(packet, "ss", &cluster_id, &category_id);
4359 ErrPrint("Invalid parameter\n");
4363 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
4365 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
4366 ErrPrint("Invalid cluster name: %s\n", cluster_id);
4370 cluster = group_find_cluster(cluster_id);
4372 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
4376 category = group_find_category(cluster, category_id);
4378 ErrPrint("Category [%s] is not registered\n", category_id);
4382 info_list = group_context_info_list(category);
4383 EINA_LIST_FOREACH(info_list, l, info) {
4384 update_pkg_cb(category, group_pkgname_from_context_info(info));
4388 /*! \note No reply packet */
4392 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
4394 const char *cluster;
4395 const char *category;
4396 struct client_node *client;
4397 struct packet *result;
4400 client = client_find_by_pid(pid);
4402 ErrPrint("Client %d is not exists\n", pid);
4403 ret = LB_STATUS_ERROR_NOT_EXIST;
4407 ret = packet_get(packet, "ss", &cluster, &category);
4409 ErrPrint("Invalid paramenters\n");
4410 ret = LB_STATUS_ERROR_INVALID;
4414 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
4415 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4416 ErrPrint("Invalid cluster: %s\n", cluster);
4417 ret = LB_STATUS_ERROR_INVALID;
4424 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
4427 result = packet_create_reply(packet, "i", ret);
4429 ErrPrint("Failed to create a packet\n");
4433 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
4435 const char *cluster;
4436 const char *category;
4437 struct client_node *client;
4440 client = client_find_by_pid(pid);
4442 ErrPrint("Client %d is not exists\n", pid);
4443 ret = LB_STATUS_ERROR_NOT_EXIST;
4447 ret = packet_get(packet, "ss", &cluster, &category);
4449 ErrPrint("Invalid argument\n");
4450 ret = LB_STATUS_ERROR_INVALID;
4454 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
4456 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4457 ErrPrint("Invalid cluster name: %s\n", cluster);
4463 * UNSUBSCRIBE cluster & sub-cluster for a client.
4465 ret = client_unsubscribe(client, cluster, category);
4467 package_alter_instances_to_client(client, ALTER_DESTROY);
4470 /*! \note No reply packet */
4474 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
4476 struct slave_node *slave;
4477 const char *slavename;
4480 ret = packet_get(packet, "s", &slavename);
4482 ErrPrint("Parameter is not matched\n");
4486 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
4488 slave = slave_find_by_pid(pid);
4491 char pkgname[pathconf("/", _PC_PATH_MAX)];
4494 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
4495 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
4496 slave = slave_find_by_name(slavename);
4497 pkgname[0] = '\0'; /* Reset the pkgname */
4499 slave = slave_find_by_pkgname(pkgname);
4503 abi = abi_find_by_pkgname(pkgname);
4506 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
4509 slave = slave_create(slavename, 1, abi, pkgname);
4511 ErrPrint("Failed to create a new slave for %s\n", slavename);
4515 DbgPrint("New slave is created\n");
4517 DbgPrint("Registered slave is replaced with this new one\n");
4518 abi = slave_abi(slave);
4521 slave_set_pid(slave, pid);
4522 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
4524 ErrPrint("Slave[%d] is not exists\n", pid);
4531 * After updating handle,
4532 * slave activated callback will be called.
4534 slave_rpc_update_handle(slave, handle);
4540 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
4542 struct slave_node *slave;
4543 const char *slavename;
4546 slave = slave_find_by_pid(pid);
4548 ErrPrint("Slave %d is not exists\n", pid);
4552 ret = packet_get(packet, "s", &slavename);
4554 ErrPrint("Parameter is not matched\n");
4556 slave_rpc_ping(slave);
4562 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
4564 struct slave_node *slave;
4565 struct inst_info *inst;
4566 const char *slavename;
4567 const char *pkgname;
4572 slave = slave_find_by_pid(pid);
4574 ErrPrint("Slave %d is not exists\n", pid);
4578 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4580 ErrPrint("Parameter is not matched\n");
4584 ret = fault_info_set(slave, pkgname, id, func);
4585 DbgPrint("Slave Faulted: %s (%d)\n", slavename, ret);
4587 inst = package_find_instance_by_id(pkgname, id);
4589 DbgPrint("There is a no such instance(%s)\n", id);
4590 } else if (instance_state(inst) == INST_DESTROYED) {
4591 ErrPrint("Instance(%s) is already destroyed\n", id);
4593 ret = instance_destroy(inst);
4594 DbgPrint("Destroy instance(%s) %d\n", id, ret);
4601 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
4603 struct slave_node *slave;
4604 const char *slavename;
4605 const char *pkgname;
4610 slave = slave_find_by_pid(pid);
4612 ErrPrint("Slave %d is not exists\n", pid);
4616 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4618 ErrPrint("Parameter is not matched\n");
4622 ret = fault_func_call(slave, pkgname, id, func);
4623 slave_give_more_ttl(slave);
4629 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
4631 struct slave_node *slave;
4632 const char *slavename;
4633 const char *pkgname;
4638 slave = slave_find_by_pid(pid);
4640 ErrPrint("Slave %d is not exists\n", pid);
4644 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4646 ErrPrint("Parameter is not matched\n");
4650 ret = fault_func_ret(slave, pkgname, id, func);
4651 slave_give_more_ttl(slave);
4657 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
4659 struct slave_node *slave;
4660 const char *slavename;
4661 const char *pkgname;
4663 const char *content_info;
4669 struct inst_info *inst;
4671 slave = slave_find_by_pid(pid);
4673 ErrPrint("Slave %d is not exists\n", pid);
4677 ret = packet_get(packet, "sssiidss", &slavename, &pkgname, &id,
4679 &content_info, &title);
4681 ErrPrint("Parameter is not matched\n");
4685 inst = package_find_instance_by_id(pkgname, id);
4687 } else if (package_is_fault(instance_package(inst))) {
4688 ErrPrint("Faulted instance cannot make any event.\n");
4689 } else if (instance_state(inst) == INST_DESTROYED) {
4690 ErrPrint("Instance is already destroyed\n");
4694 switch (package_lb_type(instance_package(inst))) {
4695 case LB_TYPE_SCRIPT:
4696 script_handler_resize(instance_lb_script(inst), w, h);
4697 filename = util_get_file_kept_in_safe(id);
4699 (void)script_handler_parse_desc(pkgname, id,
4703 (void)script_handler_parse_desc(pkgname, id,
4704 util_uri_to_path(id), 0);
4707 case LB_TYPE_BUFFER:
4711 * text format (inst)
4713 instance_set_lb_info(inst, w, h, priority, content_info, title);
4714 instance_lb_updated_by_instance(inst);
4718 slave_give_more_ttl(slave);
4725 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
4727 struct slave_node *slave;
4728 const char *slavename;
4729 const char *pkgname;
4731 const char *descfile;
4733 struct inst_info *inst;
4735 slave = slave_find_by_pid(pid);
4737 ErrPrint("Slave %d is not exists\n", pid);
4741 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &descfile);
4743 ErrPrint("Parameter is not matched\n");
4747 inst = package_find_instance_by_id(pkgname, id);
4749 } else if (package_is_fault(instance_package(inst))) {
4750 ErrPrint("Faulted package cannot make event\n");
4751 } else if (instance_state(inst) == INST_DESTROYED) {
4752 ErrPrint("Instance is already destroyed\n");
4754 switch (package_pd_type(instance_package(inst))) {
4755 case PD_TYPE_SCRIPT:
4756 DbgPrint("Script (%s)\n", id);
4757 if (script_handler_is_loaded(instance_pd_script(inst))) {
4758 (void)script_handler_parse_desc(pkgname, id,
4763 instance_set_pd_info(inst, 0, 0);
4764 case PD_TYPE_BUFFER:
4765 instance_pd_updated(pkgname, id, descfile);
4768 DbgPrint("Ignore updated DESC(%s - %s - %s)\n",
4769 pkgname, id, descfile);
4778 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
4780 struct slave_node *slave;
4781 const char *slavename;
4782 const char *pkgname;
4785 struct inst_info *inst;
4787 slave = slave_find_by_pid(pid);
4789 ErrPrint("Slave %d is not exists\n", pid);
4793 ret = packet_get(packet, "sss", &slavename, &pkgname, &id);
4795 ErrPrint("Parameter is not matched\n");
4799 inst = package_find_instance_by_id(pkgname, id);
4801 } else if (package_is_fault(instance_package(inst))) {
4803 ret = instance_destroyed(inst);
4804 DbgPrint("Destroy instance %d\n", ret);
4812 * \note for the BUFFER Type slave
4814 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
4816 enum target_type target;
4817 const char *slavename;
4818 const char *pkgname;
4823 struct packet *result;
4824 struct slave_node *slave;
4825 struct inst_info *inst;
4826 const struct pkg_info *pkg;
4829 slave = slave_find_by_pid(pid);
4831 ErrPrint("Failed to find a slave\n");
4833 ret = LB_STATUS_ERROR_NOT_EXIST;
4837 ret = packet_get(packet, "isssiii", &target, &slavename, &pkgname, &id, &w, &h, &pixel_size);
4839 ErrPrint("Invalid argument\n");
4841 ret = LB_STATUS_ERROR_INVALID;
4845 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
4846 DbgPrint("No space\n");
4847 ret = LB_STATUS_ERROR_NO_SPACE;
4853 inst = package_find_instance_by_id(pkgname, id);
4855 DbgPrint("Package[%s] Id[%s] is not found\n", pkgname, id);
4856 ret = LB_STATUS_ERROR_INVALID;
4861 pkg = instance_package(inst);
4863 ret = LB_STATUS_ERROR_INVALID;
4864 if (target == TYPE_LB) {
4865 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4866 struct buffer_info *info;
4868 info = instance_lb_buffer(inst);
4870 if (!instance_create_lb_buffer(inst)) {
4871 ErrPrint("Failed to create a LB buffer\n");
4873 info = instance_lb_buffer(inst);
4875 ErrPrint("LB buffer is not valid\n");
4876 ret = LB_STATUS_ERROR_INVALID;
4883 ret = buffer_handler_resize(info, w, h);
4884 DbgPrint("Buffer resize returns %d\n", ret);
4886 ret = buffer_handler_load(info);
4888 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
4889 id = buffer_handler_id(info);
4890 DbgPrint("Buffer handler ID: %s\n", id);
4892 DbgPrint("Failed to load a buffer(%d)\n", ret);
4895 } else if (target == TYPE_PD) {
4896 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
4897 struct buffer_info *info;
4899 DbgPrint("Slave acquire buffer for PD\n");
4901 info = instance_pd_buffer(inst);
4903 if (!instance_create_pd_buffer(inst)) {
4904 ErrPrint("Failed to create a PD buffer\n");
4906 info = instance_pd_buffer(inst);
4908 ErrPrint("PD buffer is not valid\n");
4909 ret = LB_STATUS_ERROR_INVALID;
4911 instance_client_pd_created(inst, ret);
4917 ret = buffer_handler_resize(info, w, h);
4918 DbgPrint("Buffer resize returns %d\n", ret);
4920 ret = buffer_handler_load(info);
4922 instance_set_pd_info(inst, w, h);
4923 id = buffer_handler_id(info);
4924 DbgPrint("Buffer handler ID: %s\n", id);
4926 DbgPrint("Failed to load a buffer (%d)\n", ret);
4930 * Send the PD created event to the client
4932 instance_client_pd_created(inst, ret);
4937 result = packet_create_reply(packet, "is", ret, id);
4939 ErrPrint("Failed to create a packet\n");
4944 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
4946 struct slave_node *slave;
4947 struct packet *result;
4948 enum target_type type;
4949 const char *slavename;
4950 const char *pkgname;
4954 struct inst_info *inst;
4955 const struct pkg_info *pkg;
4958 slave = slave_find_by_pid(pid);
4960 ErrPrint("Failed to find a slave\n");
4961 ret = LB_STATUS_ERROR_NOT_EXIST;
4966 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
4967 ErrPrint("Not enough space\n");
4968 ret = LB_STATUS_ERROR_NO_SPACE;
4973 ret = packet_get(packet, "isssii", &type, &slavename, &pkgname, &id, &w, &h);
4975 ErrPrint("Invalid argument\n");
4976 ret = LB_STATUS_ERROR_INVALID;
4981 inst = package_find_instance_by_id(pkgname, id);
4983 DbgPrint("Instance is not found[%s] [%s]\n", pkgname, id);
4984 ret = LB_STATUS_ERROR_NOT_EXIST;
4989 pkg = instance_package(inst);
4993 * THIS statement should not be entered.
4995 ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
4996 ret = LB_STATUS_ERROR_FAULT;
5001 ret = LB_STATUS_ERROR_INVALID;
5004 * Reset "id", It will be re-used from here
5007 if (type == TYPE_LB) {
5008 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5009 struct buffer_info *info;
5011 info = instance_lb_buffer(inst);
5013 ret = buffer_handler_resize(info, w, h);
5016 * id is resued for newly assigned ID
5019 id = buffer_handler_id(info);
5020 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
5024 } else if (type == TYPE_PD) {
5025 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5026 struct buffer_info *info;
5028 info = instance_pd_buffer(inst);
5030 ret = buffer_handler_resize(info, w, h);
5033 * id is resued for newly assigned ID
5036 id = buffer_handler_id(info);
5037 instance_set_pd_info(inst, w, h);
5044 result = packet_create_reply(packet, "is", ret, id);
5046 ErrPrint("Failed to create a packet\n");
5051 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
5053 enum target_type type;
5054 const char *slavename;
5055 const char *pkgname;
5057 struct packet *result;
5058 struct slave_node *slave;
5059 struct inst_info *inst;
5062 slave = slave_find_by_pid(pid);
5064 ErrPrint("Failed to find a slave\n");
5065 ret = LB_STATUS_ERROR_NOT_EXIST;
5069 if (packet_get(packet, "isss", &type, &slavename, &pkgname, &id) != 4) {
5070 ErrPrint("Inavlid argument\n");
5071 ret = LB_STATUS_ERROR_INVALID;
5075 inst = package_find_instance_by_id(pkgname, id);
5077 ErrPrint("Instance is not found [%s - %s]\n", pkgname, id);
5078 ret = LB_STATUS_ERROR_NOT_EXIST;
5082 ret = LB_STATUS_ERROR_INVALID;
5083 if (type == TYPE_LB) {
5084 struct buffer_info *info;
5086 info = instance_lb_buffer(inst);
5087 ret = buffer_handler_unload(info);
5088 } else if (type == TYPE_PD) {
5089 struct buffer_info *info;
5091 DbgPrint("Slave release buffer for PD\n");
5093 info = instance_pd_buffer(inst);
5094 ret = buffer_handler_unload(info);
5098 * Send the PD destroyed event to the client
5100 instance_client_pd_destroyed(inst, ret);
5104 result = packet_create_reply(packet, "i", ret);
5106 ErrPrint("Failed to create a packet\n");
5111 static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
5113 struct inst_info *inst;
5114 struct packet *result;
5115 const char *pkgname;
5120 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
5122 ErrPrint("Invalid packet\n");
5123 ret = LB_STATUS_ERROR_INVALID;
5128 struct pkg_info *pkg;
5130 pkg = package_find(pkgname);
5132 ret = LB_STATUS_ERROR_NOT_EXIST;
5133 } else if (package_is_fault(pkg)) {
5134 ret = LB_STATUS_ERROR_FAULT;
5136 Eina_List *inst_list;
5139 inst_list = package_instance_list(pkg);
5140 EINA_LIST_FOREACH(inst_list, l, inst) {
5141 ret = instance_set_period(inst, period);
5143 DbgPrint("Failed to change the period of %s to (%lf)\n", instance_id(inst), period);
5147 inst = package_find_instance_by_id(pkgname, id);
5149 ret = LB_STATUS_ERROR_NOT_EXIST;
5150 else if (package_is_fault(instance_package(inst)))
5151 ret = LB_STATUS_ERROR_FAULT;
5153 ret = instance_set_period(inst, period);
5156 DbgPrint("Change the update period: %s(%s), %lf : %d\n", pkgname, id, period, ret);
5158 result = packet_create_reply(packet, "i", ret);
5160 ErrPrint("Failed to create a packet\n");
5165 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
5167 struct pkg_info *pkg;
5168 struct packet *result;
5169 const char *pkgname;
5171 const char *cluster;
5172 const char *category;
5176 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
5178 ErrPrint("Invalid Packet\n");
5179 ret = LB_STATUS_ERROR_INVALID;
5183 lb_pkgname = package_lb_pkgname(pkgname);
5185 ErrPrint("Invalid package %s\n", pkgname);
5186 ret = LB_STATUS_ERROR_INVALID;
5190 pkg = package_find(lb_pkgname);
5192 ret = LB_STATUS_ERROR_NOT_EXIST;
5196 if (package_is_fault(pkg)) {
5197 ret = LB_STATUS_ERROR_FAULT;
5203 * Validate the update requstor.
5205 slave_rpc_request_update(lb_pkgname, id, cluster, category);
5206 DbgFree(lb_pkgname);
5210 result = packet_create_reply(packet, "i", ret);
5212 ErrPrint("Failed to create a packet\n");
5217 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
5219 struct liveinfo *info;
5220 struct packet *result;
5222 const char *fifo_name;
5225 DbgPrint("Request arrived from %d\n", pid);
5227 if (packet_get(packet, "d", ×tamp) != 1) {
5228 ErrPrint("Invalid packet\n");
5230 ret = LB_STATUS_ERROR_INVALID;
5234 info = liveinfo_create(pid, handle);
5236 ErrPrint("Failed to create a liveinfo object\n");
5238 ret = LB_STATUS_ERROR_INVALID;
5243 fifo_name = liveinfo_filename(info);
5244 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
5247 result = packet_create_reply(packet, "si", fifo_name, ret);
5249 ErrPrint("Failed to create a result packet\n");
5254 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
5258 struct liveinfo *info;
5259 struct slave_node *slave;
5263 if (packet_get(packet, "d", ×tamp) != 1) {
5264 ErrPrint("Invalid argument\n");
5268 info = liveinfo_find_by_pid(pid);
5270 ErrPrint("Invalid request\n");
5274 liveinfo_open_fifo(info);
5275 fp = liveinfo_fifo(info);
5277 liveinfo_close_fifo(info);
5281 list = (Eina_List *)slave_list();
5282 EINA_LIST_FOREACH(list, l, slave) {
5283 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
5286 slave_pkgname(slave),
5288 slave_is_secured(slave),
5289 slave_refcnt(slave),
5290 slave_fault_count(slave),
5291 slave_state_string(slave),
5292 slave_loaded_instance(slave),
5293 slave_loaded_package(slave),
5298 fprintf(fp, "EOD\n");
5299 liveinfo_close_fifo(info);
5304 static inline const char *visible_state_string(enum livebox_visible_state state)
5311 case LB_HIDE_WITH_PAUSE:
5320 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
5322 const char *pkgname;
5323 struct liveinfo *info;
5324 struct pkg_info *pkg;
5326 Eina_List *inst_list;
5327 struct inst_info *inst;
5330 if (packet_get(packet, "s", &pkgname) != 1) {
5331 ErrPrint("Invalid argument\n");
5335 info = liveinfo_find_by_pid(pid);
5337 ErrPrint("Invalid request\n");
5341 liveinfo_open_fifo(info);
5342 fp = liveinfo_fifo(info);
5344 ErrPrint("Invalid fp\n");
5345 liveinfo_close_fifo(info);
5349 if (!package_is_lb_pkgname(pkgname)) {
5350 ErrPrint("Invalid package name\n");
5354 pkg = package_find(pkgname);
5356 ErrPrint("Package is not exists\n");
5360 inst_list = package_instance_list(pkg);
5361 EINA_LIST_FOREACH(inst_list, l, inst) {
5362 fprintf(fp, "%s %s %s %lf %s %d %d\n",
5364 instance_cluster(inst),
5365 instance_category(inst),
5366 instance_period(inst),
5367 visible_state_string(instance_visible_state(inst)),
5368 instance_lb_width(inst),
5369 instance_lb_height(inst));
5373 fprintf(fp, "EOD\n");
5374 liveinfo_close_fifo(info);
5380 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
5384 Eina_List *inst_list;
5385 struct liveinfo *info;
5386 struct pkg_info *pkg;
5387 struct slave_node *slave;
5389 const char *slavename;
5392 if (packet_get(packet, "d", ×tamp) != 1) {
5393 ErrPrint("Invalid argument\n");
5397 info = liveinfo_find_by_pid(pid);
5399 ErrPrint("Invalid request\n");
5403 liveinfo_open_fifo(info);
5404 fp = liveinfo_fifo(info);
5406 liveinfo_close_fifo(info);
5410 list = (Eina_List *)package_list();
5411 EINA_LIST_FOREACH(list, l, pkg) {
5412 slave = package_slave(pkg);
5415 slavename = slave_name(slave);
5416 pid = slave_pid(slave);
5422 inst_list = (Eina_List *)package_instance_list(pkg);
5423 fprintf(fp, "%d %s %s %s %d %d %d\n",
5425 strlen(slavename) ? slavename : "(none)",
5428 package_refcnt(pkg),
5429 package_fault_count(pkg),
5430 eina_list_count(inst_list)
5434 fprintf(fp, "EOD\n");
5435 liveinfo_close_fifo(info);
5440 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
5445 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
5447 struct liveinfo *info;
5453 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
5454 ErrPrint("Invalid argument\n");
5458 info = liveinfo_find_by_pid(pid);
5460 ErrPrint("Invalid request\n");
5464 liveinfo_open_fifo(info);
5465 fp = liveinfo_fifo(info);
5467 liveinfo_close_fifo(info);
5471 if (!strcmp(cmd, "rmpack")) {
5472 fprintf(fp, "%d\n", ENOSYS);
5473 } else if (!strcmp(cmd, "rminst")) {
5474 struct inst_info *inst;
5475 inst = package_find_instance_by_id(pkgname, id);
5477 fprintf(fp, "%d\n", ENOENT);
5479 instance_destroy(inst);
5480 fprintf(fp, "%d\n", 0);
5484 fprintf(fp, "EOD\n");
5485 liveinfo_close_fifo(info);
5491 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
5493 struct liveinfo *info;
5498 int ret = LB_STATUS_ERROR_INVALID;
5500 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
5501 ErrPrint("Invalid argument\n");
5505 info = liveinfo_find_by_pid(pid);
5507 ErrPrint("Invalid request\n");
5511 if (!strcasecmp(var, "debug")) {
5512 if (!strcasecmp(cmd, "set")) {
5513 g_conf.debug_mode = !strcasecmp(val, "on");
5514 } else if (!strcasecmp(cmd, "get")) {
5516 ret = g_conf.debug_mode;
5517 } else if (!strcasecmp(var, "slave_max_load")) {
5518 if (!strcasecmp(cmd, "set")) {
5519 g_conf.slave_max_load = atoi(val);
5520 } else if (!strcasecmp(cmd, "get")) {
5522 ret = g_conf.slave_max_load;
5525 liveinfo_open_fifo(info);
5526 fp = liveinfo_fifo(info);
5528 liveinfo_close_fifo(info);
5531 fprintf(fp, "%d\nEOD\n", ret);
5532 liveinfo_close_fifo(info);
5538 static struct method s_info_table[] = {
5540 .cmd = "liveinfo_hello",
5541 .handler = liveinfo_hello,
5544 .cmd = "slave_list",
5545 .handler = liveinfo_slave_list,
5549 .handler = liveinfo_pkg_list,
5553 .handler = liveinfo_inst_list,
5556 .cmd = "slave_ctrl",
5557 .handler = liveinfo_slave_ctrl,
5561 .handler = liveinfo_pkg_ctrl,
5564 .cmd = "master_ctrl",
5565 .handler = liveinfo_master_ctrl,
5573 static struct method s_client_table[] = {
5575 .cmd = "pd_mouse_move",
5576 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5579 .cmd = "lb_mouse_move",
5580 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5583 .cmd = "pd_mouse_down",
5584 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5587 .cmd = "pd_mouse_up",
5588 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5591 .cmd = "lb_mouse_down",
5592 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5595 .cmd = "lb_mouse_up",
5596 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5599 .cmd = "pd_mouse_enter",
5600 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5603 .cmd = "pd_mouse_leave",
5604 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5607 .cmd = "lb_mouse_enter",
5608 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5611 .cmd = "lb_mouse_leave",
5612 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5615 .cmd = "lb_mouse_set",
5616 .handler = client_lb_mouse_set,
5619 .cmd = "lb_mouse_unset",
5620 .handler = client_lb_mouse_unset,
5623 .cmd = "pd_mouse_set",
5624 .handler = client_pd_mouse_set,
5627 .cmd = "pd_mouse_unset",
5628 .handler = client_pd_mouse_unset,
5631 .cmd = "change,visibility",
5632 .handler = client_change_visibility,
5635 .cmd = "lb_acquire_pixmap",
5636 .handler = client_lb_acquire_pixmap,
5639 .cmd = "lb_release_pixmap",
5640 .handler = client_lb_release_pixmap,
5643 .cmd = "pd_acquire_pixmap",
5644 .handler = client_pd_acquire_pixmap,
5647 .cmd = "pd_release_pixmap",
5648 .handler = client_pd_release_pixmap,
5652 .handler = client_acquire, /*!< pid, ret */
5656 .handler = cilent_release, /*!< pid, ret */
5660 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
5663 .cmd = "text_signal",
5664 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
5668 .handler = client_delete, /* pid, pkgname, filename, ret */
5672 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
5676 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
5679 .cmd = "set_period",
5680 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
5683 .cmd = "change_group",
5684 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
5687 .cmd = "pinup_changed",
5688 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
5692 .handler = client_create_pd, /* pid, pkgname, filename, ret */
5696 .handler = client_pd_move, /* pkgname, id, x, y */
5699 .cmd = "destroy_pd",
5700 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
5703 .cmd = "activate_package",
5704 .handler = client_activate_package, /* pid, pkgname, ret */
5707 .cmd = "subscribe", /* pid, cluster, sub-cluster */
5708 .handler = client_subscribed,
5711 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
5712 .handler = client_unsubscribed,
5715 .cmd = "delete_cluster",
5716 .handler = client_delete_cluster,
5719 .cmd = "delete_category",
5720 .handler = client_delete_category,
5723 .cmd = "refresh_group",
5724 .handler = client_refresh_group,
5728 .handler = client_update,
5732 .cmd = "pd_access_read",
5733 .handler = client_pd_access_read,
5736 .cmd = "pd_access_read_prev",
5737 .handler = client_pd_access_read_prev,
5740 .cmd = "pd_access_read_next",
5741 .handler = client_pd_access_read_next,
5744 .cmd = "pd_access_activate",
5745 .handler = client_pd_access_activate,
5749 .cmd = "lb_access_read",
5750 .handler = client_lb_access_read,
5753 .cmd = "lb_access_read_prev",
5754 .handler = client_lb_access_read_prev,
5757 .cmd = "lb_access_read_next",
5758 .handler = client_lb_access_read_next,
5761 .cmd = "lb_access_activate",
5762 .handler = client_lb_access_activate,
5766 .cmd = "lb_key_down",
5767 .handler = client_lb_key_down,
5771 .handler = client_lb_key_up,
5775 .cmd = "pd_key_down",
5776 .handler = client_pd_key_down,
5780 .handler = client_pd_key_up,
5784 .cmd = "client_paused",
5785 .handler = client_pause_request,
5788 .cmd = "client_resumed",
5789 .handler = client_resume_request,
5798 static struct method s_service_table[] = {
5800 .cmd = "service_update",
5801 .handler = service_update,
5804 .cmd = "service_change_period",
5805 .handler = service_change_period,
5813 static struct method s_slave_table[] = {
5816 .handler = slave_hello, /* slave_name, ret */
5820 .handler = slave_ping, /* slave_name, ret */
5824 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
5828 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
5832 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
5835 .cmd = "desc_updated",
5836 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
5840 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
5843 .cmd = "acquire_buffer",
5844 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
5847 .cmd = "resize_buffer",
5848 .handler = slave_resize_buffer,
5851 .cmd = "release_buffer",
5852 .handler = slave_release_buffer, /* slave_name, id - ret */
5856 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
5864 HAPI int server_init(void)
5866 com_core_packet_use_thread(COM_CORE_THREAD);
5868 if (unlink(INFO_SOCKET) < 0)
5869 ErrPrint("info socket: %s\n", strerror(errno));
5871 if (unlink(SLAVE_SOCKET) < 0)
5872 ErrPrint("slave socket: %s\n", strerror(errno));
5874 if (unlink(CLIENT_SOCKET) < 0)
5875 ErrPrint("client socket: %s\n", strerror(errno));
5877 if (unlink(SERVICE_SOCKET) < 0)
5878 ErrPrint("service socket: %s\n", strerror(errno));
5880 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
5881 if (s_info.info_fd < 0)
5882 ErrPrint("Failed to create a info socket\n");
5884 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
5885 if (s_info.slave_fd < 0)
5886 ErrPrint("Failed to create a slave socket\n");
5888 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
5889 if (s_info.client_fd < 0)
5890 ErrPrint("Failed to create a client socket\n");
5892 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
5893 if (s_info.service_fd < 0)
5894 ErrPrint("Faild to create a service socket\n");
5896 if (chmod(INFO_SOCKET, 0600) < 0)
5897 ErrPrint("info socket: %s\n", strerror(errno));
5899 if (chmod(SLAVE_SOCKET, 0666) < 0)
5900 ErrPrint("slave socket: %s\n", strerror(errno));
5902 if (chmod(CLIENT_SOCKET, 0666) < 0)
5903 ErrPrint("client socket: %s\n", strerror(errno));
5905 if (chmod(SERVICE_SOCKET, 0666) < 0)
5906 ErrPrint("service socket: %s\n", strerror(errno));
5911 HAPI int server_fini(void)
5913 if (s_info.info_fd > 0) {
5914 com_core_packet_server_fini(s_info.info_fd);
5915 s_info.info_fd = -1;
5918 if (s_info.slave_fd > 0) {
5919 com_core_packet_server_fini(s_info.slave_fd);
5920 s_info.slave_fd = -1;
5923 if (s_info.client_fd > 0) {
5924 com_core_packet_server_fini(s_info.client_fd);
5925 s_info.client_fd = -1;
5928 if (s_info.service_fd > 0) {
5929 com_core_packet_server_fini(s_info.service_fd);
5930 s_info.service_fd = -1;