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);
531 DbgPrint("RESIZE: INSTANCE[%s] Client request resize to %dx%d\n", id, w, h);
535 * Trust the package name which are sent by the client.
536 * The package has to be a livebox package name.
538 inst = package_find_instance_by_id(pkgname, id);
540 ret = LB_STATUS_ERROR_NOT_EXIST;
541 } else if (package_is_fault(instance_package(inst))) {
542 ret = LB_STATUS_ERROR_FAULT;
543 } else if (instance_client(inst) != client) {
544 ret = LB_STATUS_ERROR_PERMISSION;
546 ret = instance_resize(inst, w, h);
550 result = packet_create_reply(packet, "i", ret);
552 ErrPrint("Failed to create a packet\n");
557 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
559 struct client_node *client;
560 struct packet *result;
564 const char *category;
568 struct pkg_info *info;
573 client = client_find_by_pid(pid);
575 ErrPrint("Client %d is not exists\n", pid);
576 ret = LB_STATUS_ERROR_NOT_EXIST;
580 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
582 ErrPrint("Parameter is not matched\n");
583 ret = LB_STATUS_ERROR_INVALID;
587 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
588 pid, timestamp, pkgname, content, cluster, category, period);
590 lb_pkgname = package_lb_pkgname(pkgname);
592 ErrPrint("This %s has no livebox package\n", pkgname);
593 ret = LB_STATUS_ERROR_INVALID;
597 info = package_find(lb_pkgname);
599 info = package_create(lb_pkgname);
602 ret = LB_STATUS_ERROR_FAULT;
603 } else if (package_is_fault(info)) {
604 ret = LB_STATUS_ERROR_FAULT;
605 } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
606 ErrPrint("Not enough space\n");
607 ret = LB_STATUS_ERROR_NO_SPACE;
609 struct inst_info *inst;
611 if (period > 0.0f && period < MINIMUM_PERIOD)
612 period = MINIMUM_PERIOD;
614 if (!strlen(content))
615 content = DEFAULT_CONTENT;
617 inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
620 * Using the "inst" without validate its value is at my disposal. ;)
622 ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
628 result = packet_create_reply(packet, "i", ret);
630 ErrPrint("Failed to create a packet\n");
635 static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
637 struct client_node *client;
640 enum livebox_visible_state state;
642 struct inst_info *inst;
644 client = client_find_by_pid(pid);
646 ErrPrint("Client %d is not exists\n", pid);
647 ret = LB_STATUS_ERROR_NOT_EXIST;
651 ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
653 ErrPrint("Parameter is not matched\n");
654 ret = LB_STATUS_ERROR_INVALID;
658 DbgPrint("pid[%d] pkgname[%s] id[%s] state[%d]\n", pid, pkgname, id, state);
662 * Trust the package name which are sent by the client.
663 * The package has to be a livebox package name.
665 inst = package_find_instance_by_id(pkgname, id);
667 ret = LB_STATUS_ERROR_NOT_EXIST;
668 } else if (package_is_fault(instance_package(inst))) {
669 ret = LB_STATUS_ERROR_FAULT;
670 } else if (instance_client(inst) != client) {
671 ret = LB_STATUS_ERROR_PERMISSION;
673 ret = instance_set_visible_state(inst, state);
677 /*! \note No reply packet */
681 static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
683 struct client_node *client;
684 struct packet *result;
689 struct inst_info *inst;
691 client = client_find_by_pid(pid);
693 ErrPrint("Client %d is not exists\n", pid);
694 ret = LB_STATUS_ERROR_NOT_EXIST;
698 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
700 ErrPrint("Parameter is not matched\n");
701 ret = LB_STATUS_ERROR_INVALID;
705 DbgPrint("pid[%d] pkgname[%s] id[%s] period[%lf]\n", pid, pkgname, id, period);
709 * Trust the package name which are sent by the client.
710 * The package has to be a livebox package name.
712 inst = package_find_instance_by_id(pkgname, id);
714 ret = LB_STATUS_ERROR_NOT_EXIST;
715 } else if (package_is_fault(instance_package(inst))) {
716 ret = LB_STATUS_ERROR_FAULT;
717 } else if (instance_client(inst) != client) {
718 ret = LB_STATUS_ERROR_PERMISSION;
720 ret = instance_set_period(inst, period);
724 result = packet_create_reply(packet, "i", ret);
726 ErrPrint("Failed to create a packet\n");
731 static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
733 struct client_node *client;
734 struct packet *result;
738 const char *category;
739 struct inst_info *inst;
742 client = client_find_by_pid(pid);
744 ErrPrint("Client %d is not exists\n", pid);
745 ret = LB_STATUS_ERROR_NOT_EXIST;
749 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
751 ErrPrint("Parameter is not matched\n");
752 ret = LB_STATUS_ERROR_INVALID;
756 DbgPrint("pid[%d] pkgname[%s] id[%s] cluster[%s] category[%s]\n", pid, pkgname, id, cluster, category);
760 * Trust the package name which are sent by the client.
761 * The package has to be a livebox package name.
763 inst = package_find_instance_by_id(pkgname, id);
765 ret = LB_STATUS_ERROR_NOT_EXIST;
766 } else if (package_is_fault(instance_package(inst))) {
767 ret = LB_STATUS_ERROR_FAULT;
768 } else if (instance_client(inst) != client) {
769 ret = LB_STATUS_ERROR_PERMISSION;
771 ret = instance_change_group(inst, cluster, category);
775 result = packet_create_reply(packet, "i", ret);
777 ErrPrint("Failed to create a packet\n");
782 static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
784 struct client_node *client;
791 struct inst_info *inst;
792 const struct pkg_info *pkg;
794 client = client_find_by_pid(pid);
796 ErrPrint("Client %d is not exists\n", pid);
797 ret = LB_STATUS_ERROR_NOT_EXIST;
801 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
803 ErrPrint("Invalid parameter\n");
804 ret = LB_STATUS_ERROR_INVALID;
810 * Trust the package name which are sent by the client.
811 * The package has to be a livebox package name.
813 inst = package_find_instance_by_id(pkgname, id);
815 ErrPrint("Instance[%s] is not exists\n", id);
816 ret = LB_STATUS_ERROR_NOT_EXIST;
820 pkg = instance_package(inst);
822 ErrPrint("Package[%s] info is not found\n", pkgname);
823 ret = LB_STATUS_ERROR_FAULT;
827 if (package_is_fault(pkg)) {
830 * If the package is registered as fault module,
831 * slave has not load it, so we don't need to do anything at here!
833 DbgPrint("Package[%s] is faulted\n", pkgname);
834 ret = LB_STATUS_ERROR_FAULT;
835 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
836 struct buffer_info *buffer;
837 struct slave_node *slave;
838 // struct packet *packet;
840 buffer = instance_pd_buffer(inst);
842 ErrPrint("Instance[%s] has no buffer\n", id);
843 ret = LB_STATUS_ERROR_FAULT;
847 slave = package_slave(pkg);
849 ErrPrint("Package[%s] has no slave\n", pkgname);
850 ret = LB_STATUS_ERROR_INVALID;
855 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
857 ErrPrint("Failed to create a packet[%s]\n", pkgname);
858 ret = LB_STATUS_ERROR_FAULT;
863 packet_ref((struct packet *)packet);
864 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
865 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
866 struct script_info *script;
869 script = instance_pd_script(inst);
871 ret = LB_STATUS_ERROR_FAULT;
875 e = script_handler_evas(script);
877 ret = LB_STATUS_ERROR_FAULT;
881 script_handler_update_pointer(script, x, y, -1);
882 evas_event_feed_mouse_in(e, timestamp, NULL);
885 ErrPrint("Unsupported package\n");
886 ret = LB_STATUS_ERROR_INVALID;
890 /*! \note No reply packet */
894 static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
896 struct client_node *client;
903 struct inst_info *inst;
904 const struct pkg_info *pkg;
906 client = client_find_by_pid(pid);
908 ErrPrint("Client %d is not exists\n", pid);
909 ret = LB_STATUS_ERROR_NOT_EXIST;
913 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
915 ErrPrint("Parameter is not matched\n");
916 ret = LB_STATUS_ERROR_INVALID;
922 * Trust the package name which are sent by the client.
923 * The package has to be a livebox package name.
925 inst = package_find_instance_by_id(pkgname, id);
927 ErrPrint("Instance[%s] is not exists\n", id);
928 ret = LB_STATUS_ERROR_NOT_EXIST;
932 pkg = instance_package(inst);
934 ErrPrint("Package[%s] info is not found\n", pkgname);
935 ret = LB_STATUS_ERROR_FAULT;
939 if (package_is_fault(pkg)) {
942 * If the package is registered as fault module,
943 * slave has not load it, so we don't need to do anything at here!
945 DbgPrint("Package[%s] is faulted\n", pkgname);
946 ret = LB_STATUS_ERROR_FAULT;
947 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
948 struct buffer_info *buffer;
949 struct slave_node *slave;
950 // struct packet *packet;
952 buffer = instance_pd_buffer(inst);
954 ErrPrint("Instance[%s] has no buffer\n", id);
955 ret = LB_STATUS_ERROR_FAULT;
959 slave = package_slave(pkg);
961 ErrPrint("Package[%s] has no slave\n", pkgname);
962 ret = LB_STATUS_ERROR_INVALID;
967 packet = packet_create_noack("pd_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
969 ErrPrint("Failed to create a packet[%s]\n", pkgname);
970 ret = LB_STATUS_ERROR_FAULT;
975 packet_ref((struct packet *)packet);
976 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
977 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
978 struct script_info *script;
981 script = instance_pd_script(inst);
983 ret = LB_STATUS_ERROR_FAULT;
987 e = script_handler_evas(script);
989 ret = LB_STATUS_ERROR_FAULT;
993 script_handler_update_pointer(script, x, y, -1);
994 evas_event_feed_mouse_out(e, timestamp, NULL);
997 ErrPrint("Unsupported package\n");
998 ret = LB_STATUS_ERROR_INVALID;
1002 /*! \note No reply packet */
1006 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 */
1008 struct client_node *client;
1009 const char *pkgname;
1015 struct inst_info *inst;
1016 const struct pkg_info *pkg;
1018 client = client_find_by_pid(pid);
1020 ErrPrint("Client %d is not exists\n", pid);
1021 ret = LB_STATUS_ERROR_NOT_EXIST;
1025 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1027 ErrPrint("Parameter is not matched\n");
1028 ret = LB_STATUS_ERROR_INVALID;
1032 DbgPrint("(%dx%d)\n", x, y);
1036 * Trust the package name which are sent by the client.
1037 * The package has to be a livebox package name.
1039 inst = package_find_instance_by_id(pkgname, id);
1041 ErrPrint("Instance[%s] is not exists\n", id);
1042 ret = LB_STATUS_ERROR_NOT_EXIST;
1046 pkg = instance_package(inst);
1048 ErrPrint("Package[%s] info is not found\n", pkgname);
1049 ret = LB_STATUS_ERROR_FAULT;
1053 if (package_is_fault(pkg)) {
1056 * If the package is registered as fault module,
1057 * slave has not load it, so we don't need to do anything at here!
1059 DbgPrint("Package[%s] is faulted\n", pkgname);
1060 ret = LB_STATUS_ERROR_FAULT;
1061 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1062 struct buffer_info *buffer;
1063 struct slave_node *slave;
1064 // struct packet *packet;
1066 buffer = instance_pd_buffer(inst);
1068 ErrPrint("Instance[%s] has no buffer\n", id);
1069 ret = LB_STATUS_ERROR_FAULT;
1073 slave = package_slave(pkg);
1075 ErrPrint("Package[%s] has no slave\n", pkgname);
1076 ret = LB_STATUS_ERROR_INVALID;
1081 packet = packet_create_noack("pd_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1083 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1084 ret = LB_STATUS_ERROR_FAULT;
1089 packet_ref((struct packet *)packet);
1090 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1091 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1092 struct script_info *script;
1095 script = instance_pd_script(inst);
1097 ret = LB_STATUS_ERROR_FAULT;
1101 e = script_handler_evas(script);
1103 ret = LB_STATUS_ERROR_FAULT;
1107 script_handler_update_pointer(script, x, y, 1);
1108 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1109 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
1112 ErrPrint("Unsupported package\n");
1113 ret = LB_STATUS_ERROR_INVALID;
1117 /*! \note No reply packet */
1121 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 */
1123 struct client_node *client;
1124 const char *pkgname;
1130 struct inst_info *inst;
1131 const struct pkg_info *pkg;
1133 client = client_find_by_pid(pid);
1135 ErrPrint("Client %d is not exists\n", pid);
1136 ret = LB_STATUS_ERROR_NOT_EXIST;
1140 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1142 ErrPrint("Parameter is not matched\n");
1143 ret = LB_STATUS_ERROR_INVALID;
1147 DbgPrint("(%dx%d)\n", x, y);
1150 * Trust the package name which are sent by the client.
1151 * The package has to be a livebox package name.
1153 inst = package_find_instance_by_id(pkgname, id);
1155 ErrPrint("Instance[%s] is not exists\n", id);
1156 ret = LB_STATUS_ERROR_NOT_EXIST;
1160 pkg = instance_package(inst);
1162 ErrPrint("Package[%s] info is not exists\n", pkgname);
1163 ret = LB_STATUS_ERROR_FAULT;
1167 if (package_is_fault(pkg)) {
1170 * If the package is registered as fault module,
1171 * slave has not load it, so we don't need to do anything at here!
1173 DbgPrint("Package[%s] is faulted\n", pkgname);
1174 ret = LB_STATUS_ERROR_FAULT;
1175 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1176 struct buffer_info *buffer;
1177 struct slave_node *slave;
1178 //struct packet *packet;
1180 buffer = instance_pd_buffer(inst);
1182 ErrPrint("Instance[%s] has no buffer\n", id);
1183 ret = LB_STATUS_ERROR_FAULT;
1187 slave = package_slave(pkg);
1189 ErrPrint("Package[%s] has no slave\n", pkgname);
1190 ret = LB_STATUS_ERROR_INVALID;
1195 packet = packet_create_noack("pd_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1197 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1198 ret = LB_STATUS_ERROR_FAULT;
1203 packet_ref((struct packet *)packet);
1204 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1205 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1206 struct script_info *script;
1209 script = instance_pd_script(inst);
1211 ret = LB_STATUS_ERROR_FAULT;
1215 e = script_handler_evas(script);
1217 ret = LB_STATUS_ERROR_FAULT;
1221 script_handler_update_pointer(script, x, y, 0);
1222 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1223 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
1226 ErrPrint("Unsupported package\n");
1227 ret = LB_STATUS_ERROR_INVALID;
1231 /*! \note No reply packet */
1235 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 */
1237 struct client_node *client;
1238 const char *pkgname;
1244 struct inst_info *inst;
1245 const struct pkg_info *pkg;
1247 client = client_find_by_pid(pid);
1249 ErrPrint("Client %d is not exists\n", pid);
1250 ret = LB_STATUS_ERROR_NOT_EXIST;
1254 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1256 ErrPrint("Parameter is not matched\n");
1257 ret = LB_STATUS_ERROR_INVALID;
1261 DbgPrint("(%dx%d)\n", x, y);
1264 * Trust the package name which are sent by the client.
1265 * The package has to be a livebox package name.
1267 inst = package_find_instance_by_id(pkgname, id);
1269 ErrPrint("Instance[%s] is not exists\n", id);
1270 ret = LB_STATUS_ERROR_NOT_EXIST;
1274 pkg = instance_package(inst);
1276 ErrPrint("Package[%s] info is not exists\n", pkgname);
1277 ret = LB_STATUS_ERROR_FAULT;
1281 if (package_is_fault(pkg)) {
1284 * If the package is registered as fault module,
1285 * slave has not load it, so we don't need to do anything at here!
1287 DbgPrint("Package[%s] is faulted\n", pkgname);
1288 ret = LB_STATUS_ERROR_FAULT;
1289 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1290 struct buffer_info *buffer;
1291 struct slave_node *slave;
1292 //struct packet *packet;
1294 buffer = instance_pd_buffer(inst);
1296 ErrPrint("Instance[%s] has no buffer\n", id);
1297 ret = LB_STATUS_ERROR_FAULT;
1301 slave = package_slave(pkg);
1303 ErrPrint("Package[%s] has no slave\n", pkgname);
1304 ret = LB_STATUS_ERROR_INVALID;
1310 packet = packet_create_noack("pd_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1312 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1313 ret = LB_STATUS_ERROR_FAULT;
1317 packet_ref((struct packet *)packet);
1318 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1319 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1320 struct script_info *script;
1323 script = instance_pd_script(inst);
1325 ret = LB_STATUS_ERROR_FAULT;
1329 e = script_handler_evas(script);
1331 ret = LB_STATUS_ERROR_FAULT;
1335 script_handler_update_pointer(script, x, y, -1);
1336 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1339 ErrPrint("Unsupported package\n");
1340 ret = LB_STATUS_ERROR_INVALID;
1344 /*! \note No reply packet */
1348 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 */
1350 struct client_node *client;
1351 const char *pkgname;
1357 struct inst_info *inst;
1358 const struct pkg_info *pkg;
1360 client = client_find_by_pid(pid);
1362 ErrPrint("Client %d is not exists\n", pid);
1363 ret = LB_STATUS_ERROR_NOT_EXIST;
1367 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1369 ErrPrint("Parameter is not matched\n");
1370 ret = LB_STATUS_ERROR_INVALID;
1376 * Trust the package name which are sent by the client.
1377 * The package has to be a livebox package name.
1379 inst = package_find_instance_by_id(pkgname, id);
1381 ErrPrint("Instance[%s] is not exists\n", id);
1382 ret = LB_STATUS_ERROR_NOT_EXIST;
1386 pkg = instance_package(inst);
1388 ErrPrint("Package[%s] info is not exists\n", pkgname);
1389 ret = LB_STATUS_ERROR_FAULT;
1393 if (package_is_fault(pkg)) {
1396 * If the package is registered as fault module,
1397 * slave has not load it, so we don't need to do anything at here!
1399 DbgPrint("Package[%s] is faulted\n", pkgname);
1400 ret = LB_STATUS_ERROR_FAULT;
1401 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1402 struct buffer_info *buffer;
1403 struct slave_node *slave;
1404 //struct packet *packet;
1406 buffer = instance_lb_buffer(inst);
1408 ErrPrint("Instance[%s] has no buffer\n", id);
1409 ret = LB_STATUS_ERROR_FAULT;
1413 slave = package_slave(pkg);
1415 ErrPrint("Package[%s] has no slave\n", pkgname);
1416 ret = LB_STATUS_ERROR_INVALID;
1421 packet = packet_create_noack("lb_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1423 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1424 ret = LB_STATUS_ERROR_FAULT;
1428 packet_ref((struct packet *)packet);
1429 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1430 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1431 struct script_info *script;
1434 script = instance_lb_script(inst);
1436 ret = LB_STATUS_ERROR_FAULT;
1440 e = script_handler_evas(script);
1442 ret = LB_STATUS_ERROR_FAULT;
1446 script_handler_update_pointer(script, x, y, -1);
1447 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
1450 ErrPrint("Unsupported package\n");
1451 ret = LB_STATUS_ERROR_INVALID;
1455 /*! \note No reply packet */
1459 static int inst_del_cb(struct inst_info *inst, void *data)
1462 return -1; /* Delete this callback */
1465 static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
1467 struct client_node *client;
1468 const char *pkgname;
1474 struct inst_info *inst;
1475 const struct pkg_info *pkg;
1477 client = client_find_by_pid(pid);
1479 ErrPrint("Client %d is not exists\n", pid);
1480 ret = LB_STATUS_ERROR_NOT_EXIST;
1484 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1486 ErrPrint("Parameter is not matched\n");
1487 ret = LB_STATUS_ERROR_INVALID;
1491 inst = package_find_instance_by_id(pkgname, id);
1493 ErrPrint("Instance[%s] is not exists\n", id);
1494 ret = LB_STATUS_ERROR_NOT_EXIST;
1498 pkg = instance_package(inst);
1500 ErrPrint("Package[%s] info is not exists\n", pkgname);
1501 ret = LB_STATUS_ERROR_FAULT;
1505 if (package_is_fault(pkg)) {
1508 * If the package is registered as fault module,
1509 * slave has not load it, so we don't need to do anything at here!
1511 DbgPrint("Package[%s] is faulted\n", pkgname);
1512 ret = LB_STATUS_ERROR_FAULT;
1513 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1514 if (event_is_activated()) {
1515 if (event_deactivate() == 0)
1516 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1519 ret = event_activate(x, y, event_lb_route_cb, inst);
1521 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1522 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1523 if (event_is_activated()) {
1524 if (event_deactivate() == 0)
1525 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1528 ret = event_activate(x, y, event_lb_consume_cb, inst);
1530 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1532 ErrPrint("Unsupported package\n");
1533 ret = LB_STATUS_ERROR_INVALID;
1539 static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1541 struct client_node *client;
1542 const char *pkgname;
1548 struct inst_info *inst;
1549 const struct pkg_info *pkg;
1550 client = client_find_by_pid(pid);
1552 ErrPrint("Client %d is not exists\n", pid);
1553 ret = LB_STATUS_ERROR_NOT_EXIST;
1556 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1558 ErrPrint("Parameter is not matched\n");
1559 ret = LB_STATUS_ERROR_INVALID;
1563 inst = package_find_instance_by_id(pkgname, id);
1565 ErrPrint("Instance[%s] is not exists\n", id);
1566 ret = LB_STATUS_ERROR_NOT_EXIST;
1570 pkg = instance_package(inst);
1572 ErrPrint("Package[%s] info is not exists\n", pkgname);
1573 ret = LB_STATUS_ERROR_FAULT;
1577 if (package_is_fault(pkg)) {
1580 * If the package is registered as fault module,
1581 * slave has not load it, so we don't need to do anything at here!
1583 DbgPrint("Package[%s] is faulted\n", pkgname);
1584 ret = LB_STATUS_ERROR_FAULT;
1585 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1586 ret = event_deactivate();
1588 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1589 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1590 ret = event_deactivate();
1592 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1594 ErrPrint("Unsupported package\n");
1595 ret = LB_STATUS_ERROR_INVALID;
1601 static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
1603 struct client_node *client;
1604 const char *pkgname;
1610 struct inst_info *inst;
1611 const struct pkg_info *pkg;
1613 client = client_find_by_pid(pid);
1615 ErrPrint("Client %d is not exists\n", pid);
1616 ret = LB_STATUS_ERROR_NOT_EXIST;
1620 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1622 ErrPrint("Parameter is not matched\n");
1623 ret = LB_STATUS_ERROR_INVALID;
1627 inst = package_find_instance_by_id(pkgname, id);
1629 ErrPrint("Instance[%s] is not exists\n", id);
1630 ret = LB_STATUS_ERROR_NOT_EXIST;
1634 pkg = instance_package(inst);
1636 ErrPrint("Package[%s] info is not exists\n", pkgname);
1637 ret = LB_STATUS_ERROR_FAULT;
1641 if (package_is_fault(pkg)) {
1644 * If the package is registered as fault module,
1645 * slave has not load it, so we don't need to do anything at here!
1647 DbgPrint("Package[%s] is faulted\n", pkgname);
1648 ret = LB_STATUS_ERROR_FAULT;
1649 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1650 if (event_is_activated()) {
1651 if (event_deactivate() == 0)
1652 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1655 ret = event_activate(x, y, event_pd_route_cb, inst);
1657 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1658 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1659 if (event_is_activated()) {
1660 if (event_deactivate() == 0)
1661 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1664 ret = event_activate(x, y, event_pd_consume_cb, inst);
1666 instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, NULL);
1668 ErrPrint("Unsupported package\n");
1669 ret = LB_STATUS_ERROR_INVALID;
1676 static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
1678 struct client_node *client;
1679 const char *pkgname;
1685 struct inst_info *inst;
1686 const struct pkg_info *pkg;
1688 client = client_find_by_pid(pid);
1690 ErrPrint("Client %d is not exists\n", pid);
1691 ret = LB_STATUS_ERROR_NOT_EXIST;
1695 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1697 ErrPrint("Parameter is not matched\n");
1698 ret = LB_STATUS_ERROR_INVALID;
1702 inst = package_find_instance_by_id(pkgname, id);
1704 ErrPrint("Instance[%s] is not exists\n", id);
1705 ret = LB_STATUS_ERROR_NOT_EXIST;
1709 pkg = instance_package(inst);
1711 ErrPrint("Package[%s] info is not exists\n", pkgname);
1712 ret = LB_STATUS_ERROR_FAULT;
1716 if (package_is_fault(pkg)) {
1719 * If the package is registered as fault module,
1720 * slave has not load it, so we don't need to do anything at here!
1722 DbgPrint("Package[%s] is faulted\n", pkgname);
1723 ret = LB_STATUS_ERROR_FAULT;
1724 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1725 ret = event_deactivate();
1727 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1728 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1729 ret = event_deactivate();
1731 instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
1733 ErrPrint("Unsupported package\n");
1734 ret = LB_STATUS_ERROR_INVALID;
1740 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 */
1742 struct client_node *client;
1743 const char *pkgname;
1749 struct inst_info *inst;
1750 const struct pkg_info *pkg;
1752 client = client_find_by_pid(pid);
1754 ErrPrint("Client %d is not exists\n", pid);
1755 ret = LB_STATUS_ERROR_NOT_EXIST;
1759 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1761 ErrPrint("Parameter is not matched\n");
1762 ret = LB_STATUS_ERROR_INVALID;
1768 * Trust the package name which are sent by the client.
1769 * The package has to be a livebox package name.
1771 inst = package_find_instance_by_id(pkgname, id);
1773 ErrPrint("Instance[%s] is not exists\n", id);
1774 ret = LB_STATUS_ERROR_NOT_EXIST;
1778 pkg = instance_package(inst);
1780 ErrPrint("Package[%s] info is not exists\n", pkgname);
1781 ret = LB_STATUS_ERROR_FAULT;
1785 if (package_is_fault(pkg)) {
1788 * If the package is registered as fault module,
1789 * slave has not load it, so we don't need to do anything at here!
1791 DbgPrint("Package[%s] is faulted\n", pkgname);
1792 ret = LB_STATUS_ERROR_FAULT;
1793 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1794 struct buffer_info *buffer;
1795 struct slave_node *slave;
1796 //struct packet *packet;
1798 buffer = instance_lb_buffer(inst);
1800 ErrPrint("Instance[%s] has no buffer\n", id);
1801 ret = LB_STATUS_ERROR_FAULT;
1805 slave = package_slave(pkg);
1807 ErrPrint("Package[%s] has no slave\n", pkgname);
1808 ret = LB_STATUS_ERROR_INVALID;
1813 packet = packet_create_noack("lb_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1815 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1816 ret = LB_STATUS_ERROR_FAULT;
1820 packet_ref((struct packet *)packet);
1821 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1822 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1823 struct script_info *script;
1826 script = instance_lb_script(inst);
1828 ret = LB_STATUS_ERROR_FAULT;
1832 e = script_handler_evas(script);
1834 ret = LB_STATUS_ERROR_FAULT;
1838 script_handler_update_pointer(script, x, y, -1);
1839 evas_event_feed_mouse_in(e, timestamp, NULL);
1842 ErrPrint("Unsupported package\n");
1843 ret = LB_STATUS_ERROR_INVALID;
1847 /*! \note No reply packet */
1851 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 */
1853 struct client_node *client;
1854 const char *pkgname;
1860 struct inst_info *inst;
1861 const struct pkg_info *pkg;
1863 client = client_find_by_pid(pid);
1865 ErrPrint("Client %d is not exists\n", pid);
1866 ret = LB_STATUS_ERROR_NOT_EXIST;
1870 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1872 ErrPrint("Parameter is not matched\n");
1873 ret = LB_STATUS_ERROR_INVALID;
1879 * Trust the package name which are sent by the client.
1880 * The package has to be a livebox package name.
1882 inst = package_find_instance_by_id(pkgname, id);
1884 ErrPrint("Instance[%s] is not exists\n", id);
1885 ret = LB_STATUS_ERROR_NOT_EXIST;
1889 pkg = instance_package(inst);
1891 ErrPrint("Package[%s] info is not exists\n", pkgname);
1892 ret = LB_STATUS_ERROR_FAULT;
1896 if (package_is_fault(pkg)) {
1899 * If the package is registered as fault module,
1900 * slave has not load it, so we don't need to do anything at here!
1902 DbgPrint("Package[%s] is faulted\n", pkgname);
1903 ret = LB_STATUS_ERROR_FAULT;
1904 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1905 struct buffer_info *buffer;
1906 struct slave_node *slave;
1907 //struct packet *packet;
1909 buffer = instance_lb_buffer(inst);
1911 ErrPrint("Instance[%s] has no buffer\n", id);
1912 ret = LB_STATUS_ERROR_FAULT;
1916 slave = package_slave(pkg);
1918 ErrPrint("Package[%s] has no slave\n", pkgname);
1919 ret = LB_STATUS_ERROR_INVALID;
1924 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1926 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1927 ret = LB_STATUS_ERROR_FAULT;
1932 packet_ref((struct packet *)packet);
1933 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1934 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1935 struct script_info *script;
1938 script = instance_lb_script(inst);
1940 ret = LB_STATUS_ERROR_FAULT;
1944 e = script_handler_evas(script);
1946 ret = LB_STATUS_ERROR_FAULT;
1950 script_handler_update_pointer(script, x, y, -1);
1951 evas_event_feed_mouse_out(e, timestamp, NULL);
1954 ErrPrint("Unsupported package\n");
1955 ret = LB_STATUS_ERROR_INVALID;
1959 /*! \note No reply packet */
1963 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 */
1965 struct client_node *client;
1966 const char *pkgname;
1972 struct inst_info *inst;
1973 const struct pkg_info *pkg;
1975 client = client_find_by_pid(pid);
1977 ErrPrint("Client %d is not exists\n", pid);
1978 ret = LB_STATUS_ERROR_NOT_EXIST;
1982 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
1984 ErrPrint("Parameter is not matched\n");
1985 ret = LB_STATUS_ERROR_INVALID;
1991 * Trust the package name which are sent by the client.
1992 * The package has to be a livebox package name.
1994 inst = package_find_instance_by_id(pkgname, id);
1996 ErrPrint("Instance[%s] is not exists\n", id);
1997 ret = LB_STATUS_ERROR_NOT_EXIST;
2001 pkg = instance_package(inst);
2003 ErrPrint("Package[%s] info is not exists\n", pkgname);
2004 ret = LB_STATUS_ERROR_FAULT;
2008 if (package_is_fault(pkg)) {
2011 * If the package is registered as fault module,
2012 * slave has not load it, so we don't need to do anything at here!
2014 DbgPrint("Package[%s] is faulted\n", pkgname);
2015 ret = LB_STATUS_ERROR_FAULT;
2016 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2017 struct buffer_info *buffer;
2018 struct slave_node *slave;
2019 // struct packet *packet;
2021 buffer = instance_lb_buffer(inst);
2023 ErrPrint("Instance[%s] has no buffer\n", id);
2024 ret = LB_STATUS_ERROR_FAULT;
2028 slave = package_slave(pkg);
2030 ErrPrint("Package[%s] has no slave\n", pkgname);
2031 ret = LB_STATUS_ERROR_INVALID;
2036 packet = packet_create_noack("lb_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2038 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2039 ret = LB_STATUS_ERROR_FAULT;
2044 packet_ref((struct packet *)packet);
2045 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2046 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2047 struct script_info *script;
2050 script = instance_lb_script(inst);
2052 ret = LB_STATUS_ERROR_FAULT;
2056 e = script_handler_evas(script);
2058 ret = LB_STATUS_ERROR_FAULT;
2062 script_handler_update_pointer(script, x, y, 1);
2063 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
2064 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
2067 ErrPrint("Unsupported package\n");
2068 ret = LB_STATUS_ERROR_INVALID;
2072 /*! \note No reply packet */
2076 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 */
2078 struct client_node *client;
2079 const char *pkgname;
2085 struct inst_info *inst;
2086 const struct pkg_info *pkg;
2088 client = client_find_by_pid(pid);
2090 ErrPrint("Client %d is not exists\n", pid);
2091 ret = LB_STATUS_ERROR_NOT_EXIST;
2095 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2097 ErrPrint("Parameter is not matched\n");
2098 ret = LB_STATUS_ERROR_INVALID;
2104 * Trust the package name which are sent by the client.
2105 * The package has to be a livebox package name.
2107 inst = package_find_instance_by_id(pkgname, id);
2109 ErrPrint("Instance[%s] is not exists\n", id);
2110 ret = LB_STATUS_ERROR_NOT_EXIST;
2114 pkg = instance_package(inst);
2116 ErrPrint("Package[%s] info is not exists\n", pkgname);
2117 ret = LB_STATUS_ERROR_FAULT;
2121 if (package_is_fault(pkg)) {
2124 * If the package is registered as fault module,
2125 * slave has not load it, so we don't need to do anything at here!
2127 DbgPrint("Package[%s] is faulted\n", pkgname);
2128 ret = LB_STATUS_ERROR_FAULT;
2129 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2130 struct buffer_info *buffer;
2131 struct slave_node *slave;
2132 //struct packet *packet;
2134 buffer = instance_lb_buffer(inst);
2136 ErrPrint("Instance[%s] has no buffer\n", id);
2137 ret = LB_STATUS_ERROR_FAULT;
2141 slave = package_slave(pkg);
2143 ErrPrint("Package[%s] has no slave\n", pkgname);
2144 ret = LB_STATUS_ERROR_INVALID;
2149 packet = packet_create_noack("lb_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2151 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2152 ret = LB_STATUS_ERROR_FAULT;
2157 packet_ref((struct packet *)packet);
2158 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2159 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2160 struct script_info *script;
2163 script = instance_lb_script(inst);
2165 ret = LB_STATUS_ERROR_FAULT;
2169 e = script_handler_evas(script);
2171 ret = LB_STATUS_ERROR_FAULT;
2175 script_handler_update_pointer(script, x, y, 0);
2176 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
2177 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
2180 ErrPrint("Unsupported package\n");
2181 ret = LB_STATUS_ERROR_INVALID;
2185 /*! \note No reply packet */
2189 static struct packet *client_pd_access_read(pid_t pid, int handle, const struct packet *packet)
2191 struct client_node *client;
2192 const char *pkgname;
2198 struct inst_info *inst;
2199 const struct pkg_info *pkg;
2201 client = client_find_by_pid(pid);
2203 ErrPrint("Client %d is not exists\n", pid);
2204 ret = LB_STATUS_ERROR_NOT_EXIST;
2208 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2210 ErrPrint("Invalid parameter\n");
2211 ret = LB_STATUS_ERROR_INVALID;
2217 * Trust the package name which are sent by the client.
2218 * The package has to be a livebox package name.
2220 inst = package_find_instance_by_id(pkgname, id);
2222 ErrPrint("Instance[%s] is not exists\n", id);
2223 ret = LB_STATUS_ERROR_NOT_EXIST;
2227 pkg = instance_package(inst);
2229 ErrPrint("Package[%s] info is not found\n", pkgname);
2230 ret = LB_STATUS_ERROR_FAULT;
2234 if (package_is_fault(pkg)) {
2237 * If the package is registered as fault module,
2238 * slave has not load it, so we don't need to do anything at here!
2240 DbgPrint("Package[%s] is faulted\n", pkgname);
2241 ret = LB_STATUS_ERROR_FAULT;
2242 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2243 struct buffer_info *buffer;
2244 struct slave_node *slave;
2245 // struct packet *packet;
2247 buffer = instance_pd_buffer(inst);
2249 ErrPrint("Instance[%s] has no buffer\n", id);
2250 ret = LB_STATUS_ERROR_FAULT;
2254 slave = package_slave(pkg);
2256 ErrPrint("Package[%s] has no slave\n", pkgname);
2257 ret = LB_STATUS_ERROR_INVALID;
2262 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2264 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2265 ret = LB_STATUS_ERROR_FAULT;
2270 packet_ref((struct packet *)packet);
2271 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2272 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2273 struct script_info *script;
2276 script = instance_pd_script(inst);
2278 ret = LB_STATUS_ERROR_FAULT;
2282 e = script_handler_evas(script);
2284 ret = LB_STATUS_ERROR_FAULT;
2288 script_handler_update_pointer(script, x, y, -1);
2290 * \TODO: Push up the ACCESS_READ event
2294 ErrPrint("Unsupported package\n");
2295 ret = LB_STATUS_ERROR_INVALID;
2299 /*! \note No reply packet */
2303 static struct packet *client_pd_access_read_prev(pid_t pid, int handle, const struct packet *packet)
2305 struct client_node *client;
2306 const char *pkgname;
2312 struct inst_info *inst;
2313 const struct pkg_info *pkg;
2315 client = client_find_by_pid(pid);
2317 ErrPrint("Client %d is not exists\n", pid);
2318 ret = LB_STATUS_ERROR_NOT_EXIST;
2322 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2324 ErrPrint("Invalid parameter\n");
2325 ret = LB_STATUS_ERROR_INVALID;
2331 * Trust the package name which are sent by the client.
2332 * The package has to be a livebox package name.
2334 inst = package_find_instance_by_id(pkgname, id);
2336 ErrPrint("Instance[%s] is not exists\n", id);
2337 ret = LB_STATUS_ERROR_NOT_EXIST;
2341 pkg = instance_package(inst);
2343 ErrPrint("Package[%s] info is not found\n", pkgname);
2344 ret = LB_STATUS_ERROR_FAULT;
2348 if (package_is_fault(pkg)) {
2351 * If the package is registered as fault module,
2352 * slave has not load it, so we don't need to do anything at here!
2354 DbgPrint("Package[%s] is faulted\n", pkgname);
2355 ret = LB_STATUS_ERROR_FAULT;
2356 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2357 struct buffer_info *buffer;
2358 struct slave_node *slave;
2359 // struct packet *packet;
2361 buffer = instance_pd_buffer(inst);
2363 ErrPrint("Instance[%s] has no buffer\n", id);
2364 ret = LB_STATUS_ERROR_FAULT;
2368 slave = package_slave(pkg);
2370 ErrPrint("Package[%s] has no slave\n", pkgname);
2371 ret = LB_STATUS_ERROR_INVALID;
2376 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2378 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2379 ret = LB_STATUS_ERROR_FAULT;
2384 packet_ref((struct packet *)packet);
2385 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2386 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2387 struct script_info *script;
2390 script = instance_pd_script(inst);
2392 ret = LB_STATUS_ERROR_FAULT;
2396 e = script_handler_evas(script);
2398 ret = LB_STATUS_ERROR_FAULT;
2402 script_handler_update_pointer(script, x, y, -1);
2404 * \TODO: Push up the ACCESS_READ_PREV event
2408 ErrPrint("Unsupported package\n");
2409 ret = LB_STATUS_ERROR_INVALID;
2413 /*! \note No reply packet */
2417 static struct packet *client_pd_access_read_next(pid_t pid, int handle, const struct packet *packet)
2419 struct client_node *client;
2420 const char *pkgname;
2426 struct inst_info *inst;
2427 const struct pkg_info *pkg;
2429 client = client_find_by_pid(pid);
2431 ErrPrint("Client %d is not exists\n", pid);
2432 ret = LB_STATUS_ERROR_NOT_EXIST;
2436 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2438 ErrPrint("Invalid parameter\n");
2439 ret = LB_STATUS_ERROR_INVALID;
2445 * Trust the package name which are sent by the client.
2446 * The package has to be a livebox package name.
2448 inst = package_find_instance_by_id(pkgname, id);
2450 ErrPrint("Instance[%s] is not exists\n", id);
2451 ret = LB_STATUS_ERROR_NOT_EXIST;
2455 pkg = instance_package(inst);
2457 ErrPrint("Package[%s] info is not found\n", pkgname);
2458 ret = LB_STATUS_ERROR_FAULT;
2462 if (package_is_fault(pkg)) {
2465 * If the package is registered as fault module,
2466 * slave has not load it, so we don't need to do anything at here!
2468 DbgPrint("Package[%s] is faulted\n", pkgname);
2469 ret = LB_STATUS_ERROR_FAULT;
2470 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2471 struct buffer_info *buffer;
2472 struct slave_node *slave;
2473 // struct packet *packet;
2475 buffer = instance_pd_buffer(inst);
2477 ErrPrint("Instance[%s] has no buffer\n", id);
2478 ret = LB_STATUS_ERROR_FAULT;
2482 slave = package_slave(pkg);
2484 ErrPrint("Package[%s] has no slave\n", pkgname);
2485 ret = LB_STATUS_ERROR_INVALID;
2490 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2492 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2493 ret = LB_STATUS_ERROR_FAULT;
2498 packet_ref((struct packet *)packet);
2499 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2500 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2501 struct script_info *script;
2504 script = instance_pd_script(inst);
2506 ret = LB_STATUS_ERROR_FAULT;
2510 e = script_handler_evas(script);
2512 ret = LB_STATUS_ERROR_FAULT;
2516 script_handler_update_pointer(script, x, y, -1);
2518 * \TODO: Push up the ACCESS_READ_NEXT event
2522 ErrPrint("Unsupported package\n");
2523 ret = LB_STATUS_ERROR_INVALID;
2527 /*! \note No reply packet */
2531 static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
2533 struct client_node *client;
2534 const char *pkgname;
2540 struct inst_info *inst;
2541 const struct pkg_info *pkg;
2543 client = client_find_by_pid(pid);
2545 ErrPrint("Client %d is not exists\n", pid);
2546 ret = LB_STATUS_ERROR_NOT_EXIST;
2550 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2552 ErrPrint("Invalid parameter\n");
2553 ret = LB_STATUS_ERROR_INVALID;
2559 * Trust the package name which are sent by the client.
2560 * The package has to be a livebox package name.
2562 inst = package_find_instance_by_id(pkgname, id);
2564 ErrPrint("Instance[%s] is not exists\n", id);
2565 ret = LB_STATUS_ERROR_NOT_EXIST;
2569 pkg = instance_package(inst);
2571 ErrPrint("Package[%s] info is not found\n", pkgname);
2572 ret = LB_STATUS_ERROR_FAULT;
2576 if (package_is_fault(pkg)) {
2579 * If the package is registered as fault module,
2580 * slave has not load it, so we don't need to do anything at here!
2582 DbgPrint("Package[%s] is faulted\n", pkgname);
2583 ret = LB_STATUS_ERROR_FAULT;
2584 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2585 struct buffer_info *buffer;
2586 struct slave_node *slave;
2587 // struct packet *packet;
2589 buffer = instance_pd_buffer(inst);
2591 ErrPrint("Instance[%s] has no buffer\n", id);
2592 ret = LB_STATUS_ERROR_FAULT;
2596 slave = package_slave(pkg);
2598 ErrPrint("Package[%s] has no slave\n", pkgname);
2599 ret = LB_STATUS_ERROR_INVALID;
2604 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2606 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2607 ret = LB_STATUS_ERROR_FAULT;
2612 packet_ref((struct packet *)packet);
2613 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2614 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2615 struct script_info *script;
2618 script = instance_pd_script(inst);
2620 ret = LB_STATUS_ERROR_FAULT;
2624 e = script_handler_evas(script);
2626 ret = LB_STATUS_ERROR_FAULT;
2630 script_handler_update_pointer(script, x, y, -1);
2632 * \TODO: Push up the ACCESS_READ_ACTIVATE event
2636 ErrPrint("Unsupported package\n");
2637 ret = LB_STATUS_ERROR_INVALID;
2641 /*! \note No reply packet */
2645 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
2647 struct client_node *client;
2648 const char *pkgname;
2654 struct inst_info *inst;
2655 const struct pkg_info *pkg;
2657 client = client_find_by_pid(pid);
2659 ErrPrint("Client %d is not exists\n", pid);
2660 ret = LB_STATUS_ERROR_NOT_EXIST;
2664 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2666 ErrPrint("Invalid parameter\n");
2667 ret = LB_STATUS_ERROR_INVALID;
2673 * Trust the package name which are sent by the client.
2674 * The package has to be a livebox package name.
2676 inst = package_find_instance_by_id(pkgname, id);
2678 ErrPrint("Instance[%s] is not exists\n", id);
2679 ret = LB_STATUS_ERROR_NOT_EXIST;
2683 pkg = instance_package(inst);
2685 ErrPrint("Package[%s] info is not found\n", pkgname);
2686 ret = LB_STATUS_ERROR_FAULT;
2690 if (package_is_fault(pkg)) {
2693 * If the package is registered as fault module,
2694 * slave has not load it, so we don't need to do anything at here!
2696 DbgPrint("Package[%s] is faulted\n", pkgname);
2697 ret = LB_STATUS_ERROR_FAULT;
2698 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2699 struct buffer_info *buffer;
2700 struct slave_node *slave;
2701 // struct packet *packet;
2703 buffer = instance_pd_buffer(inst);
2705 ErrPrint("Instance[%s] has no buffer\n", id);
2706 ret = LB_STATUS_ERROR_FAULT;
2710 slave = package_slave(pkg);
2712 ErrPrint("Package[%s] has no slave\n", pkgname);
2713 ret = LB_STATUS_ERROR_INVALID;
2718 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2720 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2721 ret = LB_STATUS_ERROR_FAULT;
2726 packet_ref((struct packet *)packet);
2727 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2728 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2729 struct script_info *script;
2732 script = instance_pd_script(inst);
2734 ret = LB_STATUS_ERROR_FAULT;
2738 e = script_handler_evas(script);
2740 ret = LB_STATUS_ERROR_FAULT;
2744 script_handler_update_pointer(script, x, y, -1);
2746 * \TODO: Push up the KEY_DOWN event
2750 ErrPrint("Unsupported package\n");
2751 ret = LB_STATUS_ERROR_INVALID;
2755 /*! \note No reply packet */
2759 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
2761 struct client_node *client;
2765 client = client_find_by_pid(pid);
2767 ErrPrint("Client %d is paused - manually reported\n", pid);
2768 ret = LB_STATUS_ERROR_NOT_EXIST;
2772 ret = packet_get(packet, "d", ×tamp);
2774 ErrPrint("Invalid parameter\n");
2775 ret = LB_STATUS_ERROR_INVALID;
2780 DbgPrint("XMONITOR enabled. ignore client paused request\n");
2782 xmonitor_pause(client);
2788 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
2790 struct client_node *client;
2794 client = client_find_by_pid(pid);
2796 ErrPrint("Client %d is paused - manually reported\n", pid);
2797 ret = LB_STATUS_ERROR_NOT_EXIST;
2801 ret = packet_get(packet, "d", ×tamp);
2803 ErrPrint("Invalid parameter\n");
2804 ret = LB_STATUS_ERROR_INVALID;
2809 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
2811 xmonitor_resume(client);
2817 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
2819 struct client_node *client;
2820 const char *pkgname;
2826 struct inst_info *inst;
2827 const struct pkg_info *pkg;
2829 client = client_find_by_pid(pid);
2831 ErrPrint("Client %d is not exists\n", pid);
2832 ret = LB_STATUS_ERROR_NOT_EXIST;
2836 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2838 ErrPrint("Invalid parameter\n");
2839 ret = LB_STATUS_ERROR_INVALID;
2845 * Trust the package name which are sent by the client.
2846 * The package has to be a livebox package name.
2848 inst = package_find_instance_by_id(pkgname, id);
2850 ErrPrint("Instance[%s] is not exists\n", id);
2851 ret = LB_STATUS_ERROR_NOT_EXIST;
2855 pkg = instance_package(inst);
2857 ErrPrint("Package[%s] info is not found\n", pkgname);
2858 ret = LB_STATUS_ERROR_FAULT;
2862 if (package_is_fault(pkg)) {
2865 * If the package is registered as fault module,
2866 * slave has not load it, so we don't need to do anything at here!
2868 DbgPrint("Package[%s] is faulted\n", pkgname);
2869 ret = LB_STATUS_ERROR_FAULT;
2870 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2871 struct buffer_info *buffer;
2872 struct slave_node *slave;
2873 // struct packet *packet;
2875 buffer = instance_pd_buffer(inst);
2877 ErrPrint("Instance[%s] has no buffer\n", id);
2878 ret = LB_STATUS_ERROR_FAULT;
2882 slave = package_slave(pkg);
2884 ErrPrint("Package[%s] has no slave\n", pkgname);
2885 ret = LB_STATUS_ERROR_INVALID;
2890 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2892 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2893 ret = LB_STATUS_ERROR_FAULT;
2898 packet_ref((struct packet *)packet);
2899 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2900 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2901 struct script_info *script;
2904 script = instance_pd_script(inst);
2906 ret = LB_STATUS_ERROR_FAULT;
2910 e = script_handler_evas(script);
2912 ret = LB_STATUS_ERROR_FAULT;
2916 script_handler_update_pointer(script, x, y, -1);
2918 * \TODO: Push up the KEY_UP event
2922 ErrPrint("Unsupported package\n");
2923 ret = LB_STATUS_ERROR_INVALID;
2927 /*! \note No reply packet */
2931 static struct packet *client_lb_access_read(pid_t pid, int handle, const struct packet *packet)
2933 struct client_node *client;
2934 const char *pkgname;
2940 struct inst_info *inst;
2941 const struct pkg_info *pkg;
2943 client = client_find_by_pid(pid);
2945 ErrPrint("Client %d is not exists\n", pid);
2946 ret = LB_STATUS_ERROR_NOT_EXIST;
2950 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
2952 ErrPrint("Parameter is not matched\n");
2953 ret = LB_STATUS_ERROR_INVALID;
2959 * Trust the package name which are sent by the client.
2960 * The package has to be a livebox package name.
2962 inst = package_find_instance_by_id(pkgname, id);
2964 ErrPrint("Instance[%s] is not exists\n", id);
2965 ret = LB_STATUS_ERROR_NOT_EXIST;
2969 pkg = instance_package(inst);
2971 ErrPrint("Package[%s] info is not exists\n", pkgname);
2972 ret = LB_STATUS_ERROR_FAULT;
2976 if (package_is_fault(pkg)) {
2979 * If the package is registered as fault module,
2980 * slave has not load it, so we don't need to do anything at here!
2982 DbgPrint("Package[%s] is faulted\n", pkgname);
2983 ret = LB_STATUS_ERROR_FAULT;
2984 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2985 struct buffer_info *buffer;
2986 struct slave_node *slave;
2987 //struct packet *packet;
2989 buffer = instance_lb_buffer(inst);
2991 ErrPrint("Instance[%s] has no buffer\n", id);
2992 ret = LB_STATUS_ERROR_FAULT;
2996 slave = package_slave(pkg);
2998 ErrPrint("Package[%s] has no slave\n", pkgname);
2999 ret = LB_STATUS_ERROR_INVALID;
3004 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3006 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3007 ret = LB_STATUS_ERROR_FAULT;
3012 packet_ref((struct packet *)packet);
3013 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3014 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3015 struct script_info *script;
3018 script = instance_lb_script(inst);
3020 ret = LB_STATUS_ERROR_FAULT;
3024 e = script_handler_evas(script);
3026 ret = LB_STATUS_ERROR_FAULT;
3030 script_handler_update_pointer(script, x, y, -1);
3033 * \TODO: Feed up this ACCESS_READ event
3037 ErrPrint("Unsupported package\n");
3038 ret = LB_STATUS_ERROR_INVALID;
3042 /*! \note No reply packet */
3046 static struct packet *client_lb_access_read_prev(pid_t pid, int handle, const struct packet *packet)
3048 struct client_node *client;
3049 const char *pkgname;
3055 struct inst_info *inst;
3056 const struct pkg_info *pkg;
3058 client = client_find_by_pid(pid);
3060 ErrPrint("Client %d is not exists\n", pid);
3061 ret = LB_STATUS_ERROR_NOT_EXIST;
3065 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3067 ErrPrint("Parameter is not matched\n");
3068 ret = LB_STATUS_ERROR_INVALID;
3074 * Trust the package name which are sent by the client.
3075 * The package has to be a livebox package name.
3077 inst = package_find_instance_by_id(pkgname, id);
3079 ErrPrint("Instance[%s] is not exists\n", id);
3080 ret = LB_STATUS_ERROR_NOT_EXIST;
3084 pkg = instance_package(inst);
3086 ErrPrint("Package[%s] info is not exists\n", pkgname);
3087 ret = LB_STATUS_ERROR_FAULT;
3091 if (package_is_fault(pkg)) {
3094 * If the package is registered as fault module,
3095 * slave has not load it, so we don't need to do anything at here!
3097 DbgPrint("Package[%s] is faulted\n", pkgname);
3098 ret = LB_STATUS_ERROR_FAULT;
3099 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3100 struct buffer_info *buffer;
3101 struct slave_node *slave;
3102 //struct packet *packet;
3104 buffer = instance_lb_buffer(inst);
3106 ErrPrint("Instance[%s] has no buffer\n", id);
3107 ret = LB_STATUS_ERROR_FAULT;
3111 slave = package_slave(pkg);
3113 ErrPrint("Package[%s] has no slave\n", pkgname);
3114 ret = LB_STATUS_ERROR_INVALID;
3119 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3121 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3122 ret = LB_STATUS_ERROR_FAULT;
3127 packet_ref((struct packet *)packet);
3128 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3129 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3130 struct script_info *script;
3133 script = instance_lb_script(inst);
3135 ret = LB_STATUS_ERROR_FAULT;
3139 e = script_handler_evas(script);
3141 ret = LB_STATUS_ERROR_FAULT;
3145 script_handler_update_pointer(script, x, y, -1);
3148 * \TODO: Feed up this ACCESS_READ_PREV event
3152 ErrPrint("Unsupported package\n");
3153 ret = LB_STATUS_ERROR_INVALID;
3157 /*! \note No reply packet */
3161 static struct packet *client_lb_access_read_next(pid_t pid, int handle, const struct packet *packet)
3163 struct client_node *client;
3164 const char *pkgname;
3170 struct inst_info *inst;
3171 const struct pkg_info *pkg;
3173 client = client_find_by_pid(pid);
3175 ErrPrint("Client %d is not exists\n", pid);
3176 ret = LB_STATUS_ERROR_NOT_EXIST;
3180 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3182 ErrPrint("Parameter is not matched\n");
3183 ret = LB_STATUS_ERROR_INVALID;
3189 * Trust the package name which are sent by the client.
3190 * The package has to be a livebox package name.
3192 inst = package_find_instance_by_id(pkgname, id);
3194 ErrPrint("Instance[%s] is not exists\n", id);
3195 ret = LB_STATUS_ERROR_NOT_EXIST;
3199 pkg = instance_package(inst);
3201 ErrPrint("Package[%s] info is not exists\n", pkgname);
3202 ret = LB_STATUS_ERROR_FAULT;
3206 if (package_is_fault(pkg)) {
3209 * If the package is registered as fault module,
3210 * slave has not load it, so we don't need to do anything at here!
3212 DbgPrint("Package[%s] is faulted\n", pkgname);
3213 ret = LB_STATUS_ERROR_FAULT;
3214 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3215 struct buffer_info *buffer;
3216 struct slave_node *slave;
3217 //struct packet *packet;
3219 buffer = instance_lb_buffer(inst);
3221 ErrPrint("Instance[%s] has no buffer\n", id);
3222 ret = LB_STATUS_ERROR_FAULT;
3226 slave = package_slave(pkg);
3228 ErrPrint("Package[%s] has no slave\n", pkgname);
3229 ret = LB_STATUS_ERROR_INVALID;
3234 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3236 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3237 ret = LB_STATUS_ERROR_FAULT;
3242 packet_ref((struct packet *)packet);
3243 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3244 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3245 struct script_info *script;
3248 script = instance_lb_script(inst);
3250 ret = LB_STATUS_ERROR_FAULT;
3254 e = script_handler_evas(script);
3256 ret = LB_STATUS_ERROR_FAULT;
3260 script_handler_update_pointer(script, x, y, -1);
3263 * \TODO: Feed up this ACCESS_READ_NEXT event
3267 ErrPrint("Unsupported package\n");
3268 ret = LB_STATUS_ERROR_INVALID;
3272 /*! \note No reply packet */
3276 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
3278 struct client_node *client;
3279 const char *pkgname;
3285 struct inst_info *inst;
3286 const struct pkg_info *pkg;
3288 client = client_find_by_pid(pid);
3290 ErrPrint("Client %d is not exists\n", pid);
3291 ret = LB_STATUS_ERROR_NOT_EXIST;
3295 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3297 ErrPrint("Parameter is not matched\n");
3298 ret = LB_STATUS_ERROR_INVALID;
3304 * Trust the package name which are sent by the client.
3305 * The package has to be a livebox package name.
3307 inst = package_find_instance_by_id(pkgname, id);
3309 ErrPrint("Instance[%s] is not exists\n", id);
3310 ret = LB_STATUS_ERROR_NOT_EXIST;
3314 pkg = instance_package(inst);
3316 ErrPrint("Package[%s] info is not exists\n", pkgname);
3317 ret = LB_STATUS_ERROR_FAULT;
3321 if (package_is_fault(pkg)) {
3324 * If the package is registered as fault module,
3325 * slave has not load it, so we don't need to do anything at here!
3327 DbgPrint("Package[%s] is faulted\n", pkgname);
3328 ret = LB_STATUS_ERROR_FAULT;
3329 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3330 struct buffer_info *buffer;
3331 struct slave_node *slave;
3332 //struct packet *packet;
3334 buffer = instance_lb_buffer(inst);
3336 ErrPrint("Instance[%s] has no buffer\n", id);
3337 ret = LB_STATUS_ERROR_FAULT;
3341 slave = package_slave(pkg);
3343 ErrPrint("Package[%s] has no slave\n", pkgname);
3344 ret = LB_STATUS_ERROR_INVALID;
3349 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3351 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3352 ret = LB_STATUS_ERROR_FAULT;
3357 packet_ref((struct packet *)packet);
3358 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3359 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3360 struct script_info *script;
3363 script = instance_lb_script(inst);
3365 ret = LB_STATUS_ERROR_FAULT;
3369 e = script_handler_evas(script);
3371 ret = LB_STATUS_ERROR_FAULT;
3375 script_handler_update_pointer(script, x, y, -1);
3378 * \TODO: Feed up this ACCESS_ACTIVATE event
3382 ErrPrint("Unsupported package\n");
3383 ret = LB_STATUS_ERROR_INVALID;
3387 /*! \note No reply packet */
3391 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
3393 struct client_node *client;
3394 const char *pkgname;
3400 struct inst_info *inst;
3401 const struct pkg_info *pkg;
3403 client = client_find_by_pid(pid);
3405 ErrPrint("Client %d is not exists\n", pid);
3406 ret = LB_STATUS_ERROR_NOT_EXIST;
3410 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3412 ErrPrint("Parameter is not matched\n");
3413 ret = LB_STATUS_ERROR_INVALID;
3419 * Trust the package name which are sent by the client.
3420 * The package has to be a livebox package name.
3422 inst = package_find_instance_by_id(pkgname, id);
3424 ErrPrint("Instance[%s] is not exists\n", id);
3425 ret = LB_STATUS_ERROR_NOT_EXIST;
3429 pkg = instance_package(inst);
3431 ErrPrint("Package[%s] info is not exists\n", pkgname);
3432 ret = LB_STATUS_ERROR_FAULT;
3436 if (package_is_fault(pkg)) {
3439 * If the package is registered as fault module,
3440 * slave has not load it, so we don't need to do anything at here!
3442 DbgPrint("Package[%s] is faulted\n", pkgname);
3443 ret = LB_STATUS_ERROR_FAULT;
3444 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3445 struct buffer_info *buffer;
3446 struct slave_node *slave;
3447 //struct packet *packet;
3449 buffer = instance_lb_buffer(inst);
3451 ErrPrint("Instance[%s] has no buffer\n", id);
3452 ret = LB_STATUS_ERROR_FAULT;
3456 slave = package_slave(pkg);
3458 ErrPrint("Package[%s] has no slave\n", pkgname);
3459 ret = LB_STATUS_ERROR_INVALID;
3464 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3466 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3467 ret = LB_STATUS_ERROR_FAULT;
3472 packet_ref((struct packet *)packet);
3473 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3474 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3475 struct script_info *script;
3478 script = instance_lb_script(inst);
3480 ret = LB_STATUS_ERROR_FAULT;
3484 e = script_handler_evas(script);
3486 ret = LB_STATUS_ERROR_FAULT;
3490 script_handler_update_pointer(script, x, y, -1);
3493 * \TODO: Feed up this KEY_DOWN event
3497 ErrPrint("Unsupported package\n");
3498 ret = LB_STATUS_ERROR_INVALID;
3502 /*! \note No reply packet */
3506 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
3508 struct client_node *client;
3509 const char *pkgname;
3515 struct inst_info *inst;
3516 const struct pkg_info *pkg;
3518 client = client_find_by_pid(pid);
3520 ErrPrint("Client %d is not exists\n", pid);
3521 ret = LB_STATUS_ERROR_NOT_EXIST;
3525 ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
3527 ErrPrint("Parameter is not matched\n");
3528 ret = LB_STATUS_ERROR_INVALID;
3534 * Trust the package name which are sent by the client.
3535 * The package has to be a livebox package name.
3537 inst = package_find_instance_by_id(pkgname, id);
3539 ErrPrint("Instance[%s] is not exists\n", id);
3540 ret = LB_STATUS_ERROR_NOT_EXIST;
3544 pkg = instance_package(inst);
3546 ErrPrint("Package[%s] info is not exists\n", pkgname);
3547 ret = LB_STATUS_ERROR_FAULT;
3551 if (package_is_fault(pkg)) {
3554 * If the package is registered as fault module,
3555 * slave has not load it, so we don't need to do anything at here!
3557 DbgPrint("Package[%s] is faulted\n", pkgname);
3558 ret = LB_STATUS_ERROR_FAULT;
3559 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3560 struct buffer_info *buffer;
3561 struct slave_node *slave;
3562 //struct packet *packet;
3564 buffer = instance_lb_buffer(inst);
3566 ErrPrint("Instance[%s] has no buffer\n", id);
3567 ret = LB_STATUS_ERROR_FAULT;
3571 slave = package_slave(pkg);
3573 ErrPrint("Package[%s] has no slave\n", pkgname);
3574 ret = LB_STATUS_ERROR_INVALID;
3579 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3581 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3582 ret = LB_STATUS_ERROR_FAULT;
3587 packet_ref((struct packet *)packet);
3588 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3589 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3590 struct script_info *script;
3593 script = instance_lb_script(inst);
3595 ret = LB_STATUS_ERROR_FAULT;
3599 e = script_handler_evas(script);
3601 ret = LB_STATUS_ERROR_FAULT;
3605 script_handler_update_pointer(script, x, y, -1);
3608 * \TODO: Feed up this KEY_UP event
3612 ErrPrint("Unsupported package\n");
3613 ret = LB_STATUS_ERROR_INVALID;
3617 /*! \note No reply packet */
3621 static int release_pixmap_cb(struct client_node *client, void *canvas)
3623 DbgPrint("Forcely unref the \"buffer\"\n");
3624 buffer_handler_pixmap_unref(canvas);
3625 return -1; /* Delete this callback */
3628 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 */
3630 struct packet *result;
3631 const char *pkgname;
3633 struct client_node *client;
3634 struct inst_info *inst;
3639 client = client_find_by_pid(pid);
3641 ErrPrint("Client %d is not exists\n", pid);
3645 ret = packet_get(packet, "ss", &pkgname, &id);
3647 ErrPrint("Parameter is not matched\n");
3653 * Trust the package name which are sent by the client.
3654 * The package has to be a livebox package name.
3656 inst = package_find_instance_by_id(pkgname, id);
3658 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3662 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3664 buf_ptr = buffer_handler_pixmap_ref(instance_lb_buffer(inst));
3666 ErrPrint("Failed to ref pixmap\n");
3670 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
3672 ErrPrint("Failed to add a new client deactivate callback\n");
3673 buffer_handler_pixmap_unref(buf_ptr);
3676 pixmap = buffer_handler_pixmap(instance_lb_buffer(inst));
3680 result = packet_create_reply(packet, "i", pixmap);
3682 ErrPrint("Failed to create a reply packet\n");
3687 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
3689 const char *pkgname;
3691 struct client_node *client;
3692 struct inst_info *inst;
3697 client = client_find_by_pid(pid);
3699 ErrPrint("Client %d is not exists\n", pid);
3703 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
3705 ErrPrint("Parameter is not matched\n");
3708 DbgPrint("pid[%d] pkgname[%s] id[%s] Pixmap[0x%X]\n", pid, pkgname, id, pixmap);
3712 * Trust the package name which are sent by the client.
3713 * The package has to be a livebox package name.
3715 inst = package_find_instance_by_id(pkgname, id);
3717 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3721 buf_ptr = buffer_handler_pixmap_find(pixmap);
3723 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
3727 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
3728 buffer_handler_pixmap_unref(buf_ptr);
3731 /*! \note No reply packet */
3735 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 */
3737 struct packet *result;
3738 const char *pkgname;
3740 struct client_node *client;
3741 struct inst_info *inst;
3746 client = client_find_by_pid(pid);
3748 ErrPrint("Client %d is not exists\n", pid);
3752 ret = packet_get(packet, "ss", &pkgname, &id);
3754 ErrPrint("Parameter is not matched\n");
3760 * Trust the package name which are sent by the client.
3761 * The package has to be a livebox package name.
3763 inst = package_find_instance_by_id(pkgname, id);
3765 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3769 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3771 buf_ptr = buffer_handler_pixmap_ref(instance_pd_buffer(inst));
3773 ErrPrint("Failed to ref pixmap\n");
3777 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
3779 buffer_handler_pixmap_unref(buf_ptr);
3781 pixmap = buffer_handler_pixmap(instance_pd_buffer(inst));
3783 result = packet_create_reply(packet, "i", pixmap);
3785 ErrPrint("Failed to create a reply packet\n");
3790 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
3792 const char *pkgname;
3794 struct client_node *client;
3795 struct inst_info *inst;
3800 client = client_find_by_pid(pid);
3802 ErrPrint("Client %d is not exists\n", pid);
3806 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
3808 ErrPrint("Parameter is not matched\n");
3811 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3815 * Trust the package name which are sent by the client.
3816 * The package has to be a livebox package name.
3818 inst = package_find_instance_by_id(pkgname, id);
3820 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3824 buf_ptr = buffer_handler_pixmap_find(pixmap);
3826 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
3830 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
3831 buffer_handler_pixmap_unref(buf_ptr);
3834 /*! \note No reply packet */
3838 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
3840 struct client_node *client;
3841 struct packet *result;
3842 const char *pkgname;
3846 struct inst_info *inst;
3848 client = client_find_by_pid(pid);
3850 ErrPrint("Client %d is not exists\n", pid);
3851 ret = LB_STATUS_ERROR_NOT_EXIST;
3856 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
3858 ErrPrint("Parameter is not matched\n");
3859 ret = LB_STATUS_ERROR_INVALID;
3864 DbgPrint("pid[%d] pkgname[%s] id[%s] pinup[%d]\n", pid, pkgname, id, pinup);
3868 * Trust the package name which are sent by the client.
3869 * The package has to be a livebox package name.
3871 inst = package_find_instance_by_id(pkgname, id);
3873 ret = LB_STATUS_ERROR_NOT_EXIST;
3874 else if (package_is_fault(instance_package(inst)))
3875 ret = LB_STATUS_ERROR_FAULT;
3877 ret = instance_set_pinup(inst, pinup);
3880 result = packet_create_reply(packet, "i", ret);
3882 ErrPrint("Failed to create a packet\n");
3887 static Eina_Bool lazy_pd_created_cb(void *data)
3891 ret = instance_client_pd_created(data, LB_STATUS_SUCCESS);
3892 DbgPrint("Send PD Create event (%d)\n", ret);
3894 instance_unref(data);
3895 return ECORE_CALLBACK_CANCEL;
3898 static Eina_Bool lazy_pd_destroyed_cb(void *data)
3900 DbgPrint("Send PD Destroy event\n");
3901 instance_client_pd_destroyed(data, LB_STATUS_SUCCESS);
3903 instance_unref(data);
3904 return ECORE_CALLBACK_CANCEL;
3907 static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
3909 struct client_node *client;
3910 struct inst_info *inst;
3911 const char *pkgname;
3917 client = client_find_by_pid(pid);
3919 ErrPrint("Client %d is not exists\n", pid);
3920 ret = LB_STATUS_ERROR_NOT_EXIST;
3924 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
3926 ErrPrint("Parameter is not correct\n");
3927 ret = LB_STATUS_ERROR_INVALID;
3931 DbgPrint("pid[%d] pkgname[%s] id[%s] %lfx%lf\n", pid, pkgname, id, x, y);
3933 inst = package_find_instance_by_id(pkgname, id);
3935 ret = LB_STATUS_ERROR_NOT_EXIST;
3936 else if (package_is_fault(instance_package(inst)))
3937 ret = LB_STATUS_ERROR_FAULT;
3938 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
3939 instance_slave_set_pd_pos(inst, x, y);
3940 ret = instance_signal_emit(inst,
3941 "pd,move", util_uri_to_path(instance_id(inst)),
3942 0.0, 0.0, 0.0, 0.0, x, y, 0);
3943 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
3947 instance_slave_set_pd_pos(inst, x, y);
3948 ix = x * instance_pd_width(inst);
3949 iy = y * instance_pd_height(inst);
3950 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
3951 ret = instance_signal_emit(inst,
3952 "pd,move", util_uri_to_path(instance_id(inst)),
3953 0.0, 0.0, 0.0, 0.0, x, y, 0);
3955 ErrPrint("Invalid PD type\n");
3956 ret = LB_STATUS_ERROR_INVALID;
3959 DbgPrint("Update PD position: %lfx%lf (%d)\n", x, y, ret);
3963 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
3965 struct client_node *client;
3966 struct packet *result;
3967 const char *pkgname;
3970 struct inst_info *inst;
3974 client = client_find_by_pid(pid);
3976 ErrPrint("Client %d is not exists\n", pid);
3977 ret = LB_STATUS_ERROR_NOT_EXIST;
3981 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
3983 ErrPrint("Parameter is not matched\n");
3984 ret = LB_STATUS_ERROR_INVALID;
3988 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3992 * Trust the package name which are sent by the client.
3993 * The package has to be a livebox package name.
3995 inst = package_find_instance_by_id(pkgname, id);
3997 ret = LB_STATUS_ERROR_NOT_EXIST;
3998 else if (package_is_fault(instance_package(inst)))
3999 ret = LB_STATUS_ERROR_FAULT;
4000 else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
4001 ret = LB_STATUS_ERROR_NO_SPACE;
4002 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4003 instance_slave_set_pd_pos(inst, x, y);
4004 ret = instance_slave_open_pd(inst, client);
4005 ret = instance_signal_emit(inst,
4006 "pd,show", util_uri_to_path(instance_id(inst)),
4007 0.0, 0.0, 0.0, 0.0, x, y, 0);
4010 * PD craeted event will be send by the acquire_buffer function.
4011 * Because the slave will make request the acquire_buffer to
4014 * instance_client_pd_created(inst);
4016 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4021 * ret value should be cared but in this case,
4022 * we ignore this for this moment, so we have to handle this error later.
4024 * if ret is less than 0, the slave has some problem.
4025 * but the script mode doesn't need slave for rendering default view of PD
4026 * so we can hanle it later.
4028 instance_slave_set_pd_pos(inst, x, y);
4029 ix = x * instance_pd_width(inst);
4030 iy = y * instance_pd_height(inst);
4032 script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
4034 ret = instance_slave_open_pd(inst, client);
4035 if (ret == LB_STATUS_SUCCESS) {
4036 ret = script_handler_load(instance_pd_script(inst), 1);
4040 * Send the PD created event to the clients,
4042 if (ret == LB_STATUS_SUCCESS) {
4045 * But the created event has to be send afte return
4046 * from this function or the viewer couldn't care
4047 * the event correctly.
4049 inst = instance_ref(inst); /* To guarantee the inst */
4050 if (!ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst)) {
4051 instance_unref(inst);
4052 script_handler_unload(instance_pd_script(inst), 1);
4053 instance_slave_close_pd(inst, client);
4055 ErrPrint("Failed to add delayed timer\n");
4056 ret = LB_STATUS_ERROR_FAULT;
4059 instance_slave_close_pd(inst, client);
4062 ErrPrint("Failed to request open PD to the slave\n");
4065 ErrPrint("Invalid PD TYPE\n");
4066 ret = LB_STATUS_ERROR_INVALID;
4070 result = packet_create_reply(packet, "i", ret);
4072 ErrPrint("Failed to create a packet\n");
4077 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
4079 struct client_node *client;
4080 struct packet *result;
4081 const char *pkgname;
4084 struct inst_info *inst;
4086 client = client_find_by_pid(pid);
4088 ErrPrint("Client %d is not exists\n", pid);
4089 ret = LB_STATUS_ERROR_NOT_EXIST;
4093 ret = packet_get(packet, "ss", &pkgname, &id);
4095 ErrPrint("Parameter is not matched\n");
4096 ret = LB_STATUS_ERROR_INVALID;
4100 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
4104 * Trust the package name which are sent by the client.
4105 * The package has to be a livebox package name.
4107 inst = package_find_instance_by_id(pkgname, id);
4109 ret = LB_STATUS_ERROR_NOT_EXIST;
4110 else if (package_is_fault(instance_package(inst)))
4111 ret = LB_STATUS_ERROR_FAULT;
4112 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
4113 ret = instance_signal_emit(inst,
4114 "pd,hide", util_uri_to_path(instance_id(inst)),
4115 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
4116 ret = instance_slave_close_pd(inst, client);
4120 * release_buffer will be called by the slave after this.
4121 * Then it will send the "pd_destroyed" event to the client
4123 * instance_client_pd_destroyed(inst);
4126 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
4127 ret = script_handler_unload(instance_pd_script(inst), 1);
4128 ret = instance_slave_close_pd(inst, client);
4132 * Send the destroyed PD event to the client
4135 inst = instance_ref(inst);
4136 if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst))
4137 instance_unref(inst);
4140 ErrPrint("Invalid PD TYPE\n");
4141 ret = LB_STATUS_ERROR_INVALID;
4145 result = packet_create_reply(packet, "i", ret);
4147 ErrPrint("Failed to create a packet\n");
4152 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
4154 struct client_node *client;
4155 struct packet *result;
4156 const char *pkgname;
4158 struct pkg_info *info;
4160 client = client_find_by_pid(pid);
4162 ErrPrint("Client %d is not exists\n", pid);
4163 ret = LB_STATUS_ERROR_NOT_EXIST;
4168 ret = packet_get(packet, "s", &pkgname);
4170 ErrPrint("Parameter is not matched\n");
4171 ret = LB_STATUS_ERROR_INVALID;
4176 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
4180 * Validate the livebox package name.
4182 if (!package_is_lb_pkgname(pkgname)) {
4183 ErrPrint("%s is not a valid livebox package\n", pkgname);
4185 ret = LB_STATUS_ERROR_INVALID;
4189 info = package_find(pkgname);
4191 ret = LB_STATUS_ERROR_NOT_EXIST;
4193 ret = package_clear_fault(info);
4196 result = packet_create_reply(packet, "is", ret, pkgname);
4198 ErrPrint("Failed to create a packet\n");
4203 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
4205 const char *cluster;
4206 const char *category;
4207 struct client_node *client;
4210 client = client_find_by_pid(pid);
4212 ErrPrint("Client %d is not exists\n", pid);
4213 ret = LB_STATUS_ERROR_NOT_EXIST;
4217 ret = packet_get(packet, "ss", &cluster, &category);
4219 ErrPrint("Invalid argument\n");
4220 ret = LB_STATUS_ERROR_INVALID;
4224 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
4225 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4226 ErrPrint("Invalid cluster name\n");
4232 * SUBSCRIBE cluster & sub-cluster for a client.
4234 ret = client_subscribe(client, cluster, category);
4236 package_alter_instances_to_client(client, ALTER_CREATE);
4239 /*! \note No reply packet */
4243 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
4245 const char *cluster;
4246 struct client_node *client;
4247 struct packet *result;
4250 client = client_find_by_pid(pid);
4252 ErrPrint("Client %d is not exists\n", pid);
4253 ret = LB_STATUS_ERROR_NOT_EXIST;
4257 ret = packet_get(packet, "s", &cluster);
4259 ErrPrint("Invalid parameters\n");
4260 ret = LB_STATUS_ERROR_INVALID;
4264 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
4266 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4267 ErrPrint("Invalid cluster: %s\n", cluster);
4268 ret = LB_STATUS_ERROR_INVALID;
4275 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
4278 result = packet_create_reply(packet, "i", ret);
4280 ErrPrint("Failed to create a packet\n");
4284 static inline int update_pkg_cb(struct category *category, const char *pkgname)
4289 c_name = group_cluster_name_by_category(category);
4290 s_name = group_category_name(category);
4292 if (!c_name || !s_name || !pkgname) {
4293 ErrPrint("Name is not valid\n");
4294 return EXIT_FAILURE;
4297 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
4298 slave_rpc_request_update(pkgname, "", c_name, s_name);
4300 /* Just try to create a new package */
4301 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
4303 struct inst_info *inst;
4305 timestamp = util_timestamp();
4308 * Don't need to check the subscribed clients.
4309 * Because this callback is called by the requests of clients.
4310 * It means. some clients wants to handle this instances ;)
4312 inst = instance_create(NULL, timestamp, pkgname, DEFAULT_CONTENT, c_name, s_name, DEFAULT_PERIOD, 0, 0);
4314 ErrPrint("Failed to create a new instance\n");
4316 ErrPrint("Not enough space\n");
4318 return EXIT_SUCCESS;
4321 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
4323 struct inst_info *inst;
4324 struct client_node *client;
4325 const char *pkgname;
4329 client = client_find_by_pid(pid);
4331 ErrPrint("Cilent %d is not exists\n", pid);
4335 ret = packet_get(packet, "ss", &pkgname, &id);
4337 ErrPrint("Invalid argument\n");
4341 inst = package_find_instance_by_id(pkgname, id);
4343 } else if (package_is_fault(instance_package(inst))) {
4344 } else if (instance_client(inst) != client) {
4346 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
4350 /*! \note No reply packet */
4354 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
4356 const char *cluster_id;
4357 const char *category_id;
4358 struct client_node *client;
4360 struct cluster *cluster;
4361 struct category *category;
4362 struct context_info *info;
4363 Eina_List *info_list;
4366 client = client_find_by_pid(pid);
4368 ErrPrint("Cilent %d is not exists\n", pid);
4372 ret = packet_get(packet, "ss", &cluster_id, &category_id);
4374 ErrPrint("Invalid parameter\n");
4378 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
4380 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
4381 ErrPrint("Invalid cluster name: %s\n", cluster_id);
4385 cluster = group_find_cluster(cluster_id);
4387 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
4391 category = group_find_category(cluster, category_id);
4393 ErrPrint("Category [%s] is not registered\n", category_id);
4397 info_list = group_context_info_list(category);
4398 EINA_LIST_FOREACH(info_list, l, info) {
4399 update_pkg_cb(category, group_pkgname_from_context_info(info));
4403 /*! \note No reply packet */
4407 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
4409 const char *cluster;
4410 const char *category;
4411 struct client_node *client;
4412 struct packet *result;
4415 client = client_find_by_pid(pid);
4417 ErrPrint("Client %d is not exists\n", pid);
4418 ret = LB_STATUS_ERROR_NOT_EXIST;
4422 ret = packet_get(packet, "ss", &cluster, &category);
4424 ErrPrint("Invalid paramenters\n");
4425 ret = LB_STATUS_ERROR_INVALID;
4429 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
4430 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4431 ErrPrint("Invalid cluster: %s\n", cluster);
4432 ret = LB_STATUS_ERROR_INVALID;
4439 ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
4442 result = packet_create_reply(packet, "i", ret);
4444 ErrPrint("Failed to create a packet\n");
4448 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
4450 const char *cluster;
4451 const char *category;
4452 struct client_node *client;
4455 client = client_find_by_pid(pid);
4457 ErrPrint("Client %d is not exists\n", pid);
4458 ret = LB_STATUS_ERROR_NOT_EXIST;
4462 ret = packet_get(packet, "ss", &cluster, &category);
4464 ErrPrint("Invalid argument\n");
4465 ret = LB_STATUS_ERROR_INVALID;
4469 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
4471 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4472 ErrPrint("Invalid cluster name: %s\n", cluster);
4478 * UNSUBSCRIBE cluster & sub-cluster for a client.
4480 ret = client_unsubscribe(client, cluster, category);
4482 package_alter_instances_to_client(client, ALTER_DESTROY);
4485 /*! \note No reply packet */
4489 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
4491 struct slave_node *slave;
4492 const char *slavename;
4495 ret = packet_get(packet, "s", &slavename);
4497 ErrPrint("Parameter is not matched\n");
4501 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
4503 slave = slave_find_by_pid(pid);
4506 char pkgname[pathconf("/", _PC_PATH_MAX)];
4509 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
4510 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
4511 slave = slave_find_by_name(slavename);
4512 pkgname[0] = '\0'; /* Reset the pkgname */
4514 slave = slave_find_by_pkgname(pkgname);
4518 abi = abi_find_by_pkgname(pkgname);
4521 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
4524 slave = slave_create(slavename, 1, abi, pkgname);
4526 ErrPrint("Failed to create a new slave for %s\n", slavename);
4530 DbgPrint("New slave is created\n");
4532 DbgPrint("Registered slave is replaced with this new one\n");
4533 abi = slave_abi(slave);
4536 slave_set_pid(slave, pid);
4537 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
4539 ErrPrint("Slave[%d] is not exists\n", pid);
4546 * After updating handle,
4547 * slave activated callback will be called.
4549 slave_rpc_update_handle(slave, handle);
4555 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
4557 struct slave_node *slave;
4558 const char *slavename;
4561 slave = slave_find_by_pid(pid);
4563 ErrPrint("Slave %d is not exists\n", pid);
4567 ret = packet_get(packet, "s", &slavename);
4569 ErrPrint("Parameter is not matched\n");
4571 slave_rpc_ping(slave);
4577 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
4579 struct slave_node *slave;
4580 struct inst_info *inst;
4581 const char *slavename;
4582 const char *pkgname;
4587 slave = slave_find_by_pid(pid);
4589 ErrPrint("Slave %d is not exists\n", pid);
4593 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4595 ErrPrint("Parameter is not matched\n");
4599 ret = fault_info_set(slave, pkgname, id, func);
4600 DbgPrint("Slave Faulted: %s (%d)\n", slavename, ret);
4602 inst = package_find_instance_by_id(pkgname, id);
4604 DbgPrint("There is a no such instance(%s)\n", id);
4605 } else if (instance_state(inst) == INST_DESTROYED) {
4606 ErrPrint("Instance(%s) is already destroyed\n", id);
4608 ret = instance_destroy(inst);
4609 DbgPrint("Destroy instance(%s) %d\n", id, ret);
4616 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
4618 struct slave_node *slave;
4619 const char *slavename;
4620 const char *pkgname;
4625 slave = slave_find_by_pid(pid);
4627 ErrPrint("Slave %d is not exists\n", pid);
4631 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4633 ErrPrint("Parameter is not matched\n");
4637 ret = fault_func_call(slave, pkgname, id, func);
4638 slave_give_more_ttl(slave);
4644 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
4646 struct slave_node *slave;
4647 const char *slavename;
4648 const char *pkgname;
4653 slave = slave_find_by_pid(pid);
4655 ErrPrint("Slave %d is not exists\n", pid);
4659 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4661 ErrPrint("Parameter is not matched\n");
4665 ret = fault_func_ret(slave, pkgname, id, func);
4666 slave_give_more_ttl(slave);
4672 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
4674 struct slave_node *slave;
4675 const char *slavename;
4676 const char *pkgname;
4678 const char *content_info;
4684 struct inst_info *inst;
4686 slave = slave_find_by_pid(pid);
4688 ErrPrint("Slave %d is not exists\n", pid);
4692 ret = packet_get(packet, "sssiidss", &slavename, &pkgname, &id,
4694 &content_info, &title);
4696 ErrPrint("Parameter is not matched\n");
4700 inst = package_find_instance_by_id(pkgname, id);
4702 } else if (package_is_fault(instance_package(inst))) {
4703 ErrPrint("Faulted instance cannot make any event.\n");
4704 } else if (instance_state(inst) == INST_DESTROYED) {
4705 ErrPrint("Instance is already destroyed\n");
4709 switch (package_lb_type(instance_package(inst))) {
4710 case LB_TYPE_SCRIPT:
4711 script_handler_resize(instance_lb_script(inst), w, h);
4712 filename = util_get_file_kept_in_safe(id);
4714 (void)script_handler_parse_desc(pkgname, id,
4718 (void)script_handler_parse_desc(pkgname, id,
4719 util_uri_to_path(id), 0);
4722 case LB_TYPE_BUFFER:
4726 * text format (inst)
4728 instance_set_lb_info(inst, w, h, priority, content_info, title);
4729 instance_lb_updated_by_instance(inst);
4733 slave_give_more_ttl(slave);
4740 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
4742 struct slave_node *slave;
4743 const char *slavename;
4744 const char *pkgname;
4746 const char *descfile;
4748 struct inst_info *inst;
4750 slave = slave_find_by_pid(pid);
4752 ErrPrint("Slave %d is not exists\n", pid);
4756 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &descfile);
4758 ErrPrint("Parameter is not matched\n");
4762 inst = package_find_instance_by_id(pkgname, id);
4764 } else if (package_is_fault(instance_package(inst))) {
4765 ErrPrint("Faulted package cannot make event\n");
4766 } else if (instance_state(inst) == INST_DESTROYED) {
4767 ErrPrint("Instance is already destroyed\n");
4769 switch (package_pd_type(instance_package(inst))) {
4770 case PD_TYPE_SCRIPT:
4771 DbgPrint("Script (%s)\n", id);
4772 if (script_handler_is_loaded(instance_pd_script(inst))) {
4773 (void)script_handler_parse_desc(pkgname, id,
4778 instance_set_pd_info(inst, 0, 0);
4779 case PD_TYPE_BUFFER:
4780 instance_pd_updated(pkgname, id, descfile);
4783 DbgPrint("Ignore updated DESC(%s - %s - %s)\n",
4784 pkgname, id, descfile);
4793 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
4795 struct slave_node *slave;
4796 const char *slavename;
4797 const char *pkgname;
4800 struct inst_info *inst;
4802 slave = slave_find_by_pid(pid);
4804 ErrPrint("Slave %d is not exists\n", pid);
4808 ret = packet_get(packet, "sss", &slavename, &pkgname, &id);
4810 ErrPrint("Parameter is not matched\n");
4814 inst = package_find_instance_by_id(pkgname, id);
4816 } else if (package_is_fault(instance_package(inst))) {
4818 ret = instance_destroyed(inst);
4819 DbgPrint("Destroy instance %d\n", ret);
4827 * \note for the BUFFER Type slave
4829 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
4831 enum target_type target;
4832 const char *slavename;
4833 const char *pkgname;
4838 struct packet *result;
4839 struct slave_node *slave;
4840 struct inst_info *inst;
4841 const struct pkg_info *pkg;
4844 slave = slave_find_by_pid(pid);
4846 ErrPrint("Failed to find a slave\n");
4848 ret = LB_STATUS_ERROR_NOT_EXIST;
4852 ret = packet_get(packet, "isssiii", &target, &slavename, &pkgname, &id, &w, &h, &pixel_size);
4854 ErrPrint("Invalid argument\n");
4856 ret = LB_STATUS_ERROR_INVALID;
4860 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
4861 DbgPrint("No space\n");
4862 ret = LB_STATUS_ERROR_NO_SPACE;
4868 inst = package_find_instance_by_id(pkgname, id);
4870 DbgPrint("Package[%s] Id[%s] is not found\n", pkgname, id);
4871 ret = LB_STATUS_ERROR_INVALID;
4876 pkg = instance_package(inst);
4878 ret = LB_STATUS_ERROR_INVALID;
4879 if (target == TYPE_LB) {
4880 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4881 struct buffer_info *info;
4883 info = instance_lb_buffer(inst);
4885 if (!instance_create_lb_buffer(inst)) {
4886 ErrPrint("Failed to create a LB buffer\n");
4888 info = instance_lb_buffer(inst);
4890 ErrPrint("LB buffer is not valid\n");
4891 ret = LB_STATUS_ERROR_INVALID;
4898 ret = buffer_handler_resize(info, w, h);
4899 DbgPrint("Buffer resize returns %d\n", ret);
4901 ret = buffer_handler_load(info);
4903 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
4904 id = buffer_handler_id(info);
4905 DbgPrint("Buffer handler ID: %s\n", id);
4907 DbgPrint("Failed to load a buffer(%d)\n", ret);
4910 } else if (target == TYPE_PD) {
4911 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
4912 struct buffer_info *info;
4914 DbgPrint("Slave acquire buffer for PD\n");
4916 info = instance_pd_buffer(inst);
4918 if (!instance_create_pd_buffer(inst)) {
4919 ErrPrint("Failed to create a PD buffer\n");
4921 info = instance_pd_buffer(inst);
4923 ErrPrint("PD buffer is not valid\n");
4924 ret = LB_STATUS_ERROR_INVALID;
4926 instance_client_pd_created(inst, ret);
4932 ret = buffer_handler_resize(info, w, h);
4933 DbgPrint("Buffer resize returns %d\n", ret);
4935 ret = buffer_handler_load(info);
4937 instance_set_pd_info(inst, w, h);
4938 id = buffer_handler_id(info);
4939 DbgPrint("Buffer handler ID: %s\n", id);
4941 DbgPrint("Failed to load a buffer (%d)\n", ret);
4945 * Send the PD created event to the client
4947 instance_client_pd_created(inst, ret);
4952 result = packet_create_reply(packet, "is", ret, id);
4954 ErrPrint("Failed to create a packet\n");
4959 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
4961 struct slave_node *slave;
4962 struct packet *result;
4963 enum target_type type;
4964 const char *slavename;
4965 const char *pkgname;
4969 struct inst_info *inst;
4970 const struct pkg_info *pkg;
4973 slave = slave_find_by_pid(pid);
4975 ErrPrint("Failed to find a slave\n");
4976 ret = LB_STATUS_ERROR_NOT_EXIST;
4981 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
4982 ErrPrint("Not enough space\n");
4983 ret = LB_STATUS_ERROR_NO_SPACE;
4988 ret = packet_get(packet, "isssii", &type, &slavename, &pkgname, &id, &w, &h);
4990 ErrPrint("Invalid argument\n");
4991 ret = LB_STATUS_ERROR_INVALID;
4996 inst = package_find_instance_by_id(pkgname, id);
4998 DbgPrint("Instance is not found[%s] [%s]\n", pkgname, id);
4999 ret = LB_STATUS_ERROR_NOT_EXIST;
5004 pkg = instance_package(inst);
5008 * THIS statement should not be entered.
5010 ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
5011 ret = LB_STATUS_ERROR_FAULT;
5016 ret = LB_STATUS_ERROR_INVALID;
5019 * Reset "id", It will be re-used from here
5022 if (type == TYPE_LB) {
5023 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
5024 struct buffer_info *info;
5026 info = instance_lb_buffer(inst);
5028 ret = buffer_handler_resize(info, w, h);
5031 * id is resued for newly assigned ID
5034 id = buffer_handler_id(info);
5035 instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
5039 } else if (type == TYPE_PD) {
5040 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
5041 struct buffer_info *info;
5043 info = instance_pd_buffer(inst);
5045 ret = buffer_handler_resize(info, w, h);
5048 * id is resued for newly assigned ID
5051 id = buffer_handler_id(info);
5052 instance_set_pd_info(inst, w, h);
5059 result = packet_create_reply(packet, "is", ret, id);
5061 ErrPrint("Failed to create a packet\n");
5066 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
5068 enum target_type type;
5069 const char *slavename;
5070 const char *pkgname;
5072 struct packet *result;
5073 struct slave_node *slave;
5074 struct inst_info *inst;
5077 slave = slave_find_by_pid(pid);
5079 ErrPrint("Failed to find a slave\n");
5080 ret = LB_STATUS_ERROR_NOT_EXIST;
5084 if (packet_get(packet, "isss", &type, &slavename, &pkgname, &id) != 4) {
5085 ErrPrint("Inavlid argument\n");
5086 ret = LB_STATUS_ERROR_INVALID;
5090 inst = package_find_instance_by_id(pkgname, id);
5092 ErrPrint("Instance is not found [%s - %s]\n", pkgname, id);
5093 ret = LB_STATUS_ERROR_NOT_EXIST;
5097 ret = LB_STATUS_ERROR_INVALID;
5098 if (type == TYPE_LB) {
5099 struct buffer_info *info;
5101 info = instance_lb_buffer(inst);
5102 ret = buffer_handler_unload(info);
5103 } else if (type == TYPE_PD) {
5104 struct buffer_info *info;
5106 DbgPrint("Slave release buffer for PD\n");
5108 info = instance_pd_buffer(inst);
5109 ret = buffer_handler_unload(info);
5113 * Send the PD destroyed event to the client
5115 instance_client_pd_destroyed(inst, ret);
5119 result = packet_create_reply(packet, "i", ret);
5121 ErrPrint("Failed to create a packet\n");
5126 static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
5128 struct inst_info *inst;
5129 struct packet *result;
5130 const char *pkgname;
5135 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
5137 ErrPrint("Invalid packet\n");
5138 ret = LB_STATUS_ERROR_INVALID;
5143 struct pkg_info *pkg;
5145 pkg = package_find(pkgname);
5147 ret = LB_STATUS_ERROR_NOT_EXIST;
5148 } else if (package_is_fault(pkg)) {
5149 ret = LB_STATUS_ERROR_FAULT;
5151 Eina_List *inst_list;
5154 inst_list = package_instance_list(pkg);
5155 EINA_LIST_FOREACH(inst_list, l, inst) {
5156 ret = instance_set_period(inst, period);
5158 DbgPrint("Failed to change the period of %s to (%lf)\n", instance_id(inst), period);
5162 inst = package_find_instance_by_id(pkgname, id);
5164 ret = LB_STATUS_ERROR_NOT_EXIST;
5165 else if (package_is_fault(instance_package(inst)))
5166 ret = LB_STATUS_ERROR_FAULT;
5168 ret = instance_set_period(inst, period);
5171 DbgPrint("Change the update period: %s(%s), %lf : %d\n", pkgname, id, period, ret);
5173 result = packet_create_reply(packet, "i", ret);
5175 ErrPrint("Failed to create a packet\n");
5180 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
5182 struct pkg_info *pkg;
5183 struct packet *result;
5184 const char *pkgname;
5186 const char *cluster;
5187 const char *category;
5191 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
5193 ErrPrint("Invalid Packet\n");
5194 ret = LB_STATUS_ERROR_INVALID;
5198 lb_pkgname = package_lb_pkgname(pkgname);
5200 ErrPrint("Invalid package %s\n", pkgname);
5201 ret = LB_STATUS_ERROR_INVALID;
5205 pkg = package_find(lb_pkgname);
5207 ret = LB_STATUS_ERROR_NOT_EXIST;
5211 if (package_is_fault(pkg)) {
5212 ret = LB_STATUS_ERROR_FAULT;
5218 * Validate the update requstor.
5220 slave_rpc_request_update(lb_pkgname, id, cluster, category);
5221 DbgFree(lb_pkgname);
5225 result = packet_create_reply(packet, "i", ret);
5227 ErrPrint("Failed to create a packet\n");
5232 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
5234 struct liveinfo *info;
5235 struct packet *result;
5237 const char *fifo_name;
5240 DbgPrint("Request arrived from %d\n", pid);
5242 if (packet_get(packet, "d", ×tamp) != 1) {
5243 ErrPrint("Invalid packet\n");
5245 ret = LB_STATUS_ERROR_INVALID;
5249 info = liveinfo_create(pid, handle);
5251 ErrPrint("Failed to create a liveinfo object\n");
5253 ret = LB_STATUS_ERROR_INVALID;
5258 fifo_name = liveinfo_filename(info);
5259 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
5262 result = packet_create_reply(packet, "si", fifo_name, ret);
5264 ErrPrint("Failed to create a result packet\n");
5269 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
5273 struct liveinfo *info;
5274 struct slave_node *slave;
5278 if (packet_get(packet, "d", ×tamp) != 1) {
5279 ErrPrint("Invalid argument\n");
5283 info = liveinfo_find_by_pid(pid);
5285 ErrPrint("Invalid request\n");
5289 liveinfo_open_fifo(info);
5290 fp = liveinfo_fifo(info);
5292 liveinfo_close_fifo(info);
5296 list = (Eina_List *)slave_list();
5297 EINA_LIST_FOREACH(list, l, slave) {
5298 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
5301 slave_pkgname(slave),
5303 slave_is_secured(slave),
5304 slave_refcnt(slave),
5305 slave_fault_count(slave),
5306 slave_state_string(slave),
5307 slave_loaded_instance(slave),
5308 slave_loaded_package(slave),
5313 fprintf(fp, "EOD\n");
5314 liveinfo_close_fifo(info);
5319 static inline const char *visible_state_string(enum livebox_visible_state state)
5326 case LB_HIDE_WITH_PAUSE:
5335 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
5337 const char *pkgname;
5338 struct liveinfo *info;
5339 struct pkg_info *pkg;
5341 Eina_List *inst_list;
5342 struct inst_info *inst;
5345 if (packet_get(packet, "s", &pkgname) != 1) {
5346 ErrPrint("Invalid argument\n");
5350 info = liveinfo_find_by_pid(pid);
5352 ErrPrint("Invalid request\n");
5356 liveinfo_open_fifo(info);
5357 fp = liveinfo_fifo(info);
5359 ErrPrint("Invalid fp\n");
5360 liveinfo_close_fifo(info);
5364 if (!package_is_lb_pkgname(pkgname)) {
5365 ErrPrint("Invalid package name\n");
5369 pkg = package_find(pkgname);
5371 ErrPrint("Package is not exists\n");
5375 inst_list = package_instance_list(pkg);
5376 EINA_LIST_FOREACH(inst_list, l, inst) {
5377 fprintf(fp, "%s %s %s %lf %s %d %d\n",
5379 instance_cluster(inst),
5380 instance_category(inst),
5381 instance_period(inst),
5382 visible_state_string(instance_visible_state(inst)),
5383 instance_lb_width(inst),
5384 instance_lb_height(inst));
5388 fprintf(fp, "EOD\n");
5389 liveinfo_close_fifo(info);
5395 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
5399 Eina_List *inst_list;
5400 struct liveinfo *info;
5401 struct pkg_info *pkg;
5402 struct slave_node *slave;
5404 const char *slavename;
5407 if (packet_get(packet, "d", ×tamp) != 1) {
5408 ErrPrint("Invalid argument\n");
5412 info = liveinfo_find_by_pid(pid);
5414 ErrPrint("Invalid request\n");
5418 liveinfo_open_fifo(info);
5419 fp = liveinfo_fifo(info);
5421 liveinfo_close_fifo(info);
5425 list = (Eina_List *)package_list();
5426 EINA_LIST_FOREACH(list, l, pkg) {
5427 slave = package_slave(pkg);
5430 slavename = slave_name(slave);
5431 pid = slave_pid(slave);
5437 inst_list = (Eina_List *)package_instance_list(pkg);
5438 fprintf(fp, "%d %s %s %s %d %d %d\n",
5440 strlen(slavename) ? slavename : "(none)",
5443 package_refcnt(pkg),
5444 package_fault_count(pkg),
5445 eina_list_count(inst_list)
5449 fprintf(fp, "EOD\n");
5450 liveinfo_close_fifo(info);
5455 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
5460 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
5462 struct liveinfo *info;
5468 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
5469 ErrPrint("Invalid argument\n");
5473 info = liveinfo_find_by_pid(pid);
5475 ErrPrint("Invalid request\n");
5479 liveinfo_open_fifo(info);
5480 fp = liveinfo_fifo(info);
5482 liveinfo_close_fifo(info);
5486 if (!strcmp(cmd, "rmpack")) {
5487 fprintf(fp, "%d\n", ENOSYS);
5488 } else if (!strcmp(cmd, "rminst")) {
5489 struct inst_info *inst;
5490 inst = package_find_instance_by_id(pkgname, id);
5492 fprintf(fp, "%d\n", ENOENT);
5494 instance_destroy(inst);
5495 fprintf(fp, "%d\n", 0);
5499 fprintf(fp, "EOD\n");
5500 liveinfo_close_fifo(info);
5506 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
5508 struct liveinfo *info;
5513 int ret = LB_STATUS_ERROR_INVALID;
5515 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
5516 ErrPrint("Invalid argument\n");
5520 info = liveinfo_find_by_pid(pid);
5522 ErrPrint("Invalid request\n");
5526 if (!strcasecmp(var, "debug")) {
5527 if (!strcasecmp(cmd, "set")) {
5528 g_conf.debug_mode = !strcasecmp(val, "on");
5529 } else if (!strcasecmp(cmd, "get")) {
5531 ret = g_conf.debug_mode;
5532 } else if (!strcasecmp(var, "slave_max_load")) {
5533 if (!strcasecmp(cmd, "set")) {
5534 g_conf.slave_max_load = atoi(val);
5535 } else if (!strcasecmp(cmd, "get")) {
5537 ret = g_conf.slave_max_load;
5540 liveinfo_open_fifo(info);
5541 fp = liveinfo_fifo(info);
5543 liveinfo_close_fifo(info);
5546 fprintf(fp, "%d\nEOD\n", ret);
5547 liveinfo_close_fifo(info);
5553 static struct method s_info_table[] = {
5555 .cmd = "liveinfo_hello",
5556 .handler = liveinfo_hello,
5559 .cmd = "slave_list",
5560 .handler = liveinfo_slave_list,
5564 .handler = liveinfo_pkg_list,
5568 .handler = liveinfo_inst_list,
5571 .cmd = "slave_ctrl",
5572 .handler = liveinfo_slave_ctrl,
5576 .handler = liveinfo_pkg_ctrl,
5579 .cmd = "master_ctrl",
5580 .handler = liveinfo_master_ctrl,
5588 static struct method s_client_table[] = {
5590 .cmd = "pd_mouse_move",
5591 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5594 .cmd = "lb_mouse_move",
5595 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5598 .cmd = "pd_mouse_down",
5599 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5602 .cmd = "pd_mouse_up",
5603 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5606 .cmd = "lb_mouse_down",
5607 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5610 .cmd = "lb_mouse_up",
5611 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5614 .cmd = "pd_mouse_enter",
5615 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5618 .cmd = "pd_mouse_leave",
5619 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5622 .cmd = "lb_mouse_enter",
5623 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5626 .cmd = "lb_mouse_leave",
5627 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5630 .cmd = "lb_mouse_set",
5631 .handler = client_lb_mouse_set,
5634 .cmd = "lb_mouse_unset",
5635 .handler = client_lb_mouse_unset,
5638 .cmd = "pd_mouse_set",
5639 .handler = client_pd_mouse_set,
5642 .cmd = "pd_mouse_unset",
5643 .handler = client_pd_mouse_unset,
5646 .cmd = "change,visibility",
5647 .handler = client_change_visibility,
5650 .cmd = "lb_acquire_pixmap",
5651 .handler = client_lb_acquire_pixmap,
5654 .cmd = "lb_release_pixmap",
5655 .handler = client_lb_release_pixmap,
5658 .cmd = "pd_acquire_pixmap",
5659 .handler = client_pd_acquire_pixmap,
5662 .cmd = "pd_release_pixmap",
5663 .handler = client_pd_release_pixmap,
5667 .handler = client_acquire, /*!< pid, ret */
5671 .handler = cilent_release, /*!< pid, ret */
5675 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
5678 .cmd = "text_signal",
5679 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
5683 .handler = client_delete, /* pid, pkgname, filename, ret */
5687 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
5691 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
5694 .cmd = "set_period",
5695 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
5698 .cmd = "change_group",
5699 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
5702 .cmd = "pinup_changed",
5703 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
5707 .handler = client_create_pd, /* pid, pkgname, filename, ret */
5711 .handler = client_pd_move, /* pkgname, id, x, y */
5714 .cmd = "destroy_pd",
5715 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
5718 .cmd = "activate_package",
5719 .handler = client_activate_package, /* pid, pkgname, ret */
5722 .cmd = "subscribe", /* pid, cluster, sub-cluster */
5723 .handler = client_subscribed,
5726 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
5727 .handler = client_unsubscribed,
5730 .cmd = "delete_cluster",
5731 .handler = client_delete_cluster,
5734 .cmd = "delete_category",
5735 .handler = client_delete_category,
5738 .cmd = "refresh_group",
5739 .handler = client_refresh_group,
5743 .handler = client_update,
5747 .cmd = "pd_access_read",
5748 .handler = client_pd_access_read,
5751 .cmd = "pd_access_read_prev",
5752 .handler = client_pd_access_read_prev,
5755 .cmd = "pd_access_read_next",
5756 .handler = client_pd_access_read_next,
5759 .cmd = "pd_access_activate",
5760 .handler = client_pd_access_activate,
5764 .cmd = "lb_access_read",
5765 .handler = client_lb_access_read,
5768 .cmd = "lb_access_read_prev",
5769 .handler = client_lb_access_read_prev,
5772 .cmd = "lb_access_read_next",
5773 .handler = client_lb_access_read_next,
5776 .cmd = "lb_access_activate",
5777 .handler = client_lb_access_activate,
5781 .cmd = "lb_key_down",
5782 .handler = client_lb_key_down,
5786 .handler = client_lb_key_up,
5790 .cmd = "pd_key_down",
5791 .handler = client_pd_key_down,
5795 .handler = client_pd_key_up,
5799 .cmd = "client_paused",
5800 .handler = client_pause_request,
5803 .cmd = "client_resumed",
5804 .handler = client_resume_request,
5813 static struct method s_service_table[] = {
5815 .cmd = "service_update",
5816 .handler = service_update,
5819 .cmd = "service_change_period",
5820 .handler = service_change_period,
5828 static struct method s_slave_table[] = {
5831 .handler = slave_hello, /* slave_name, ret */
5835 .handler = slave_ping, /* slave_name, ret */
5839 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
5843 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
5847 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
5850 .cmd = "desc_updated",
5851 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
5855 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
5858 .cmd = "acquire_buffer",
5859 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
5862 .cmd = "resize_buffer",
5863 .handler = slave_resize_buffer,
5866 .cmd = "release_buffer",
5867 .handler = slave_release_buffer, /* slave_name, id - ret */
5871 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
5879 HAPI int server_init(void)
5881 com_core_packet_use_thread(COM_CORE_THREAD);
5883 if (unlink(INFO_SOCKET) < 0)
5884 ErrPrint("info socket: %s\n", strerror(errno));
5886 if (unlink(SLAVE_SOCKET) < 0)
5887 ErrPrint("slave socket: %s\n", strerror(errno));
5889 if (unlink(CLIENT_SOCKET) < 0)
5890 ErrPrint("client socket: %s\n", strerror(errno));
5892 if (unlink(SERVICE_SOCKET) < 0)
5893 ErrPrint("service socket: %s\n", strerror(errno));
5895 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
5896 if (s_info.info_fd < 0)
5897 ErrPrint("Failed to create a info socket\n");
5899 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
5900 if (s_info.slave_fd < 0)
5901 ErrPrint("Failed to create a slave socket\n");
5903 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
5904 if (s_info.client_fd < 0)
5905 ErrPrint("Failed to create a client socket\n");
5907 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
5908 if (s_info.service_fd < 0)
5909 ErrPrint("Faild to create a service socket\n");
5911 if (chmod(INFO_SOCKET, 0600) < 0)
5912 ErrPrint("info socket: %s\n", strerror(errno));
5914 if (chmod(SLAVE_SOCKET, 0666) < 0)
5915 ErrPrint("slave socket: %s\n", strerror(errno));
5917 if (chmod(CLIENT_SOCKET, 0666) < 0)
5918 ErrPrint("client socket: %s\n", strerror(errno));
5920 if (chmod(SERVICE_SOCKET, 0666) < 0)
5921 ErrPrint("service socket: %s\n", strerror(errno));
5926 HAPI int server_fini(void)
5928 if (s_info.info_fd > 0) {
5929 com_core_packet_server_fini(s_info.info_fd);
5930 s_info.info_fd = -1;
5933 if (s_info.slave_fd > 0) {
5934 com_core_packet_server_fini(s_info.slave_fd);
5935 s_info.slave_fd = -1;
5938 if (s_info.client_fd > 0) {
5939 com_core_packet_server_fini(s_info.client_fd);
5940 s_info.client_fd = -1;
5943 if (s_info.service_fd > 0) {
5944 com_core_packet_server_fini(s_info.service_fd);
5945 s_info.service_fd = -1;