2 * Copyright 2012 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>
33 #include "slave_life.h"
34 #include "slave_rpc.h"
35 #include "client_life.h"
37 #include "client_rpc.h"
39 #include "script_handler.h"
40 #include "buffer_handler.h"
42 #include "fault_manager.h"
43 #include "fb.h" /* fb_type */
62 /* Share this with provider */
70 struct client_node *client;
71 struct inst_info *inst;
74 static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
76 struct client_node *client;
77 struct packet *result;
81 client = client_find_by_pid(pid);
83 ErrPrint("Client is already exists %d\n", pid);
88 if (packet_get(packet, "d", ×tamp) != 1) {
89 ErrPrint("Invalid arguemnt\n");
94 DbgPrint("Acquired %lf\n", timestamp);
99 * client_create will invoke the client created callback
101 client = client_create(pid, handle);
103 ErrPrint("Failed to create a new client for %d\n", pid);
108 result = packet_create_reply(packet, "i", ret);
110 ErrPrint("Failed to create a packet\n");
115 static struct packet *cilent_release(pid_t pid, int handle, const struct packet *packet) /*!< pid, ret */
117 struct client_node *client;
118 struct packet *result;
121 client = client_find_by_pid(pid);
123 ErrPrint("Client %d is not exists\n", pid);
128 client_destroy(client);
132 result = packet_create_reply(packet, "i", ret);
134 ErrPrint("Failed to create a packet\n");
139 /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
140 static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
142 struct client_node *client;
150 struct inst_info *inst;
152 client = client_find_by_pid(pid);
154 ErrPrint("Client %d is not exists\n", pid);
159 ret = packet_get(packet, "sssddd", &pkgname, &id, &event, ×tamp, &x, &y);
161 ErrPrint("Parameter is not matched\n");
166 DbgPrint("pid[%d] pkgname[%s] id[%s] event[%s] timestamp[%lf] x[%lf] y[%lf]\n", pid, pkgname, id, event, timestamp, x, y);
170 * Trust the package name which are sent by the client.
171 * The package has to be a livebox package name.
173 inst = package_find_instance_by_id(pkgname, id);
176 else if (package_is_fault(instance_package(inst)))
179 ret = instance_clicked(inst, event, timestamp, x, y);
182 /*! \note No reply packet */
186 /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
187 static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
189 struct client_node *client;
190 struct packet *result;
193 const char *emission;
199 struct inst_info *inst;
202 client = client_find_by_pid(pid);
204 ErrPrint("Client %d is not exists\n", pid);
209 ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
211 ErrPrint("Parameter is not matched\n");
216 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);
220 * Trust the package name which are sent by the client.
221 * The package has to be a livebox package name.
223 inst = package_find_instance_by_id(pkgname, id);
226 else if (package_is_fault(instance_package(inst)))
229 ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
232 result = packet_create_reply(packet, "i", ret);
234 ErrPrint("Failed to create a packet\n");
239 static Eina_Bool lazy_delete_cb(void *data)
241 struct deleted_item *item = data;
243 DbgPrint("Send delete event to the client\n");
246 * Before invoke this callback, the instance is able to already remove this client
249 if (instance_has_client(item->inst, item->client)) {
250 instance_unicast_deleted_event(item->inst, item->client);
251 instance_del_client(item->inst, item->client);
254 client_unref(item->client);
255 instance_unref(item->inst);
257 return ECORE_CALLBACK_CANCEL;
260 static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
262 struct client_node *client;
263 struct packet *result;
266 struct inst_info *inst;
269 client = client_find_by_pid(pid);
271 ErrPrint("Client %d is not exists\n", pid);
276 ret = packet_get(packet, "ss", &pkgname, &id);
278 ErrPrint("Parameter is not matched\n");
283 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
287 * Trust the package name which are sent by the client.
288 * The package has to be a livebox package name.
290 inst = package_find_instance_by_id(pkgname, id);
293 } else if (package_is_fault(instance_package(inst))) {
295 } else if (instance_client(inst) != client) {
296 if (instance_has_client(inst, client)) {
297 struct deleted_item *item;
299 item = malloc(sizeof(*item));
301 ErrPrint("Heap: %s\n", strerror(errno));
307 * Send DELETED EVENT to the client.
308 * after return from this function.
310 * Client will prepare the deleted event after get this function's return value.
311 * So We have to make a delay to send a deleted event.
314 item->client = client_ref(client);
315 item->inst = instance_ref(inst);
317 if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
318 ErrPrint("Failed to add a delayzed delete callback\n");
319 client_unref(client);
320 instance_unref(inst);
329 ret = instance_destroy(inst);
333 result = packet_create_reply(packet, "i", ret);
335 ErrPrint("Failed to create a packet\n");
340 static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
342 struct client_node *client;
343 struct packet *result;
348 struct inst_info *inst;
351 client = client_find_by_pid(pid);
353 ErrPrint("Client %d is not exists\n", pid);
358 ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
360 ErrPrint("Parameter is not matched\n");
365 DbgPrint("pid[%d] pkgname[%s] id[%s] w[%d] h[%d]\n", pid, pkgname, id, w, h);
369 * Trust the package name which are sent by the client.
370 * The package has to be a livebox package name.
372 inst = package_find_instance_by_id(pkgname, id);
375 } else if (package_is_fault(instance_package(inst))) {
377 } else if (instance_client(inst) != client) {
380 ret = instance_resize(inst, w, h);
384 result = packet_create_reply(packet, "i", ret);
386 ErrPrint("Failed to create a packet\n");
391 static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
393 struct client_node *client;
394 struct packet *result;
398 const char *category;
402 struct pkg_info *info;
407 client = client_find_by_pid(pid);
409 ErrPrint("Client %d is not exists\n", pid);
414 ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
416 ErrPrint("Parameter is not matched\n");
421 DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
422 pid, timestamp, pkgname, content, cluster, category, period);
424 lb_pkgname = package_lb_pkgname(pkgname);
426 ErrPrint("This %s has no livebox package\n", pkgname);
431 info = package_find(lb_pkgname);
433 info = package_create(lb_pkgname);
437 } else if (package_is_fault(info)) {
439 } else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
440 ErrPrint("Not enough space\n");
443 struct inst_info *inst;
445 if (period > 0.0f && period < MINIMUM_PERIOD)
446 period = MINIMUM_PERIOD;
448 if (!strlen(content))
449 content = DEFAULT_CONTENT;
451 inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
454 * Using the "inst" without validate its value is at my disposal. ;)
456 ret = inst ? 0 : -EFAULT;
462 result = packet_create_reply(packet, "i", ret);
464 ErrPrint("Failed to create a packet\n");
469 static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
471 struct client_node *client;
474 enum livebox_visible_state state;
476 struct inst_info *inst;
478 client = client_find_by_pid(pid);
480 ErrPrint("Client %d is not exists\n", pid);
485 ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
487 ErrPrint("Parameter is not matched\n");
492 DbgPrint("pid[%d] pkgname[%s] id[%s] state[%d]\n", pid, pkgname, id, state);
496 * Trust the package name which are sent by the client.
497 * The package has to be a livebox package name.
499 inst = package_find_instance_by_id(pkgname, id);
502 } else if (package_is_fault(instance_package(inst))) {
504 } else if (instance_client(inst) != client) {
507 ret = instance_set_visible_state(inst, state);
511 /*! \note No reply packet */
515 static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
517 struct client_node *client;
518 struct packet *result;
523 struct inst_info *inst;
525 client = client_find_by_pid(pid);
527 ErrPrint("Client %d is not exists\n", pid);
532 ret = packet_get(packet, "ssd", &pkgname, &id, &period);
534 ErrPrint("Parameter is not matched\n");
539 DbgPrint("pid[%d] pkgname[%s] id[%s] period[%lf]\n", pid, pkgname, id, period);
543 * Trust the package name which are sent by the client.
544 * The package has to be a livebox package name.
546 inst = package_find_instance_by_id(pkgname, id);
549 } else if (package_is_fault(instance_package(inst))) {
551 } else if (instance_client(inst) != client) {
554 ret = instance_set_period(inst, period);
558 result = packet_create_reply(packet, "i", ret);
560 ErrPrint("Failed to create a packet\n");
565 static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
567 struct client_node *client;
568 struct packet *result;
572 const char *category;
573 struct inst_info *inst;
576 client = client_find_by_pid(pid);
578 ErrPrint("Client %d is not exists\n", pid);
583 ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
585 ErrPrint("Parameter is not matched\n");
590 DbgPrint("pid[%d] pkgname[%s] id[%s] cluster[%s] category[%s]\n", pid, pkgname, id, cluster, category);
594 * Trust the package name which are sent by the client.
595 * The package has to be a livebox package name.
597 inst = package_find_instance_by_id(pkgname, id);
600 } else if (package_is_fault(instance_package(inst))) {
602 } else if (instance_client(inst) != client) {
605 ret = instance_change_group(inst, cluster, category);
609 result = packet_create_reply(packet, "i", ret);
611 ErrPrint("Failed to create a packet\n");
616 static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
618 struct client_node *client;
627 struct inst_info *inst;
628 const struct pkg_info *pkg;
630 client = client_find_by_pid(pid);
632 ErrPrint("Client %d is not exists\n", pid);
637 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
639 ErrPrint("Invalid parameter\n");
646 * Trust the package name which are sent by the client.
647 * The package has to be a livebox package name.
649 inst = package_find_instance_by_id(pkgname, id);
651 ErrPrint("Instance[%s] is not exists\n", id);
656 pkg = instance_package(inst);
658 ErrPrint("Package[%s] info is not found\n", pkgname);
663 if (package_is_fault(pkg)) {
666 * If the package is registered as fault module,
667 * slave has not load it, so we don't need to do anything at here!
669 DbgPrint("Package[%s] is faulted\n", pkgname);
671 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
672 struct buffer_info *buffer;
673 struct slave_node *slave;
674 // struct packet *packet;
676 buffer = instance_pd_buffer(inst);
678 ErrPrint("Instance[%s] has no buffer\n", id);
683 slave = package_slave(pkg);
685 ErrPrint("Package[%s] has no slave\n", pkgname);
691 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
693 ErrPrint("Failed to create a packet[%s]\n", pkgname);
699 packet_ref((struct packet *)packet);
700 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
701 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
702 struct script_info *script;
705 script = instance_pd_script(inst);
711 e = script_handler_evas(script);
717 script_handler_update_pointer(script, x, y, -1);
718 evas_event_feed_mouse_in(e, timestamp, NULL);
721 ErrPrint("Unsupported package\n");
726 /*! \note No reply packet */
730 static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
732 struct client_node *client;
741 struct inst_info *inst;
742 const struct pkg_info *pkg;
744 client = client_find_by_pid(pid);
746 ErrPrint("Client %d is not exists\n", pid);
751 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
753 ErrPrint("Parameter is not matched\n");
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 ErrPrint("Instance[%s] is not exists\n", id);
770 pkg = instance_package(inst);
772 ErrPrint("Package[%s] info is not found\n", pkgname);
777 if (package_is_fault(pkg)) {
780 * If the package is registered as fault module,
781 * slave has not load it, so we don't need to do anything at here!
783 DbgPrint("Package[%s] is faulted\n", pkgname);
785 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
786 struct buffer_info *buffer;
787 struct slave_node *slave;
788 // struct packet *packet;
790 buffer = instance_pd_buffer(inst);
792 ErrPrint("Instance[%s] has no buffer\n", id);
797 slave = package_slave(pkg);
799 ErrPrint("Package[%s] has no slave\n", pkgname);
805 packet = packet_create_noack("pd_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
807 ErrPrint("Failed to create a packet[%s]\n", pkgname);
813 packet_ref((struct packet *)packet);
814 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
815 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
816 struct script_info *script;
819 script = instance_pd_script(inst);
825 e = script_handler_evas(script);
831 script_handler_update_pointer(script, x, y, -1);
832 evas_event_feed_mouse_out(e, timestamp, NULL);
835 ErrPrint("Unsupported package\n");
840 /*! \note No reply packet */
844 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 */
846 struct client_node *client;
855 struct inst_info *inst;
856 const struct pkg_info *pkg;
858 client = client_find_by_pid(pid);
860 ErrPrint("Client %d is not exists\n", pid);
865 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
867 ErrPrint("Parameter is not matched\n");
874 * Trust the package name which are sent by the client.
875 * The package has to be a livebox package name.
877 inst = package_find_instance_by_id(pkgname, id);
879 ErrPrint("Instance[%s] is not exists\n", id);
884 pkg = instance_package(inst);
886 ErrPrint("Package[%s] info is not found\n", pkgname);
891 if (package_is_fault(pkg)) {
894 * If the package is registered as fault module,
895 * slave has not load it, so we don't need to do anything at here!
897 DbgPrint("Package[%s] is faulted\n", pkgname);
899 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
900 struct buffer_info *buffer;
901 struct slave_node *slave;
902 // struct packet *packet;
904 buffer = instance_pd_buffer(inst);
906 ErrPrint("Instance[%s] has no buffer\n", id);
911 slave = package_slave(pkg);
913 ErrPrint("Package[%s] has no slave\n", pkgname);
919 packet = packet_create_noack("pd_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
921 ErrPrint("Failed to create a packet[%s]\n", pkgname);
927 packet_ref((struct packet *)packet);
928 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
929 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
930 struct script_info *script;
933 script = instance_pd_script(inst);
939 e = script_handler_evas(script);
945 script_handler_update_pointer(script, x, y, 1);
946 evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
947 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
950 ErrPrint("Unsupported package\n");
955 /*! \note No reply packet */
959 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 */
961 struct client_node *client;
970 struct inst_info *inst;
971 const struct pkg_info *pkg;
973 client = client_find_by_pid(pid);
975 ErrPrint("Client %d is not exists\n", pid);
980 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
982 ErrPrint("Parameter is not matched\n");
989 * Trust the package name which are sent by the client.
990 * The package has to be a livebox package name.
992 inst = package_find_instance_by_id(pkgname, id);
994 ErrPrint("Instance[%s] is not exists\n", id);
999 pkg = instance_package(inst);
1001 ErrPrint("Package[%s] info is not exists\n", pkgname);
1006 if (package_is_fault(pkg)) {
1009 * If the package is registered as fault module,
1010 * slave has not load it, so we don't need to do anything at here!
1012 DbgPrint("Package[%s] is faulted\n", pkgname);
1014 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1015 struct buffer_info *buffer;
1016 struct slave_node *slave;
1017 //struct packet *packet;
1019 buffer = instance_pd_buffer(inst);
1021 ErrPrint("Instance[%s] has no buffer\n", id);
1026 slave = package_slave(pkg);
1028 ErrPrint("Package[%s] has no slave\n", pkgname);
1034 packet = packet_create_noack("pd_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1036 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1042 packet_ref((struct packet *)packet);
1043 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1044 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1045 struct script_info *script;
1048 script = instance_pd_script(inst);
1054 e = script_handler_evas(script);
1060 script_handler_update_pointer(script, x, y, 0);
1061 evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
1062 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
1065 ErrPrint("Unsupported package\n");
1070 /*! \note No reply packet */
1074 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 */
1076 struct client_node *client;
1077 const char *pkgname;
1085 struct inst_info *inst;
1086 const struct pkg_info *pkg;
1088 client = client_find_by_pid(pid);
1090 ErrPrint("Client %d is not exists\n", pid);
1095 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1097 ErrPrint("Parameter is not matched\n");
1104 * Trust the package name which are sent by the client.
1105 * The package has to be a livebox package name.
1107 inst = package_find_instance_by_id(pkgname, id);
1109 ErrPrint("Instance[%s] is not exists\n", id);
1114 pkg = instance_package(inst);
1116 ErrPrint("Package[%s] info is not exists\n", pkgname);
1121 if (package_is_fault(pkg)) {
1124 * If the package is registered as fault module,
1125 * slave has not load it, so we don't need to do anything at here!
1127 DbgPrint("Package[%s] is faulted\n", pkgname);
1129 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1130 struct buffer_info *buffer;
1131 struct slave_node *slave;
1132 //struct packet *packet;
1134 buffer = instance_pd_buffer(inst);
1136 ErrPrint("Instance[%s] has no buffer\n", id);
1141 slave = package_slave(pkg);
1143 ErrPrint("Package[%s] has no slave\n", pkgname);
1150 packet = packet_create_noack("pd_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1152 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1157 packet_ref((struct packet *)packet);
1158 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1159 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1160 struct script_info *script;
1163 script = instance_pd_script(inst);
1169 e = script_handler_evas(script);
1175 script_handler_update_pointer(script, x, y, -1);
1176 evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
1179 ErrPrint("Unsupported package\n");
1184 /*! \note No reply packet */
1188 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 */
1190 struct client_node *client;
1191 const char *pkgname;
1199 struct inst_info *inst;
1200 const struct pkg_info *pkg;
1202 client = client_find_by_pid(pid);
1204 ErrPrint("Client %d is not exists\n", pid);
1209 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1211 ErrPrint("Parameter is not matched\n");
1218 * Trust the package name which are sent by the client.
1219 * The package has to be a livebox package name.
1221 inst = package_find_instance_by_id(pkgname, id);
1223 ErrPrint("Instance[%s] is not exists\n", id);
1228 pkg = instance_package(inst);
1230 ErrPrint("Package[%s] info is not exists\n", pkgname);
1235 if (package_is_fault(pkg)) {
1238 * If the package is registered as fault module,
1239 * slave has not load it, so we don't need to do anything at here!
1241 DbgPrint("Package[%s] is faulted\n", pkgname);
1243 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1244 struct buffer_info *buffer;
1245 struct slave_node *slave;
1246 //struct packet *packet;
1248 buffer = instance_lb_buffer(inst);
1250 ErrPrint("Instance[%s] has no buffer\n", id);
1255 slave = package_slave(pkg);
1257 ErrPrint("Package[%s] has no slave\n", pkgname);
1263 packet = packet_create_noack("lb_mouse_move", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1265 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1270 packet_ref((struct packet *)packet);
1271 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1272 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1273 struct script_info *script;
1276 script = instance_lb_script(inst);
1282 e = script_handler_evas(script);
1288 script_handler_update_pointer(script, x, y, -1);
1289 evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
1292 ErrPrint("Unsupported package\n");
1297 /*! \note No reply packet */
1301 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 */
1303 struct client_node *client;
1304 const char *pkgname;
1312 struct inst_info *inst;
1313 const struct pkg_info *pkg;
1315 client = client_find_by_pid(pid);
1317 ErrPrint("Client %d is not exists\n", pid);
1322 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1324 ErrPrint("Parameter is not matched\n");
1331 * Trust the package name which are sent by the client.
1332 * The package has to be a livebox package name.
1334 inst = package_find_instance_by_id(pkgname, id);
1336 ErrPrint("Instance[%s] is not exists\n", id);
1341 pkg = instance_package(inst);
1343 ErrPrint("Package[%s] info is not exists\n", pkgname);
1348 if (package_is_fault(pkg)) {
1351 * If the package is registered as fault module,
1352 * slave has not load it, so we don't need to do anything at here!
1354 DbgPrint("Package[%s] is faulted\n", pkgname);
1356 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1357 struct buffer_info *buffer;
1358 struct slave_node *slave;
1359 //struct packet *packet;
1361 buffer = instance_lb_buffer(inst);
1363 ErrPrint("Instance[%s] has no buffer\n", id);
1368 slave = package_slave(pkg);
1370 ErrPrint("Package[%s] has no slave\n", pkgname);
1376 packet = packet_create_noack("lb_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1378 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1383 packet_ref((struct packet *)packet);
1384 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1385 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1386 struct script_info *script;
1389 script = instance_lb_script(inst);
1395 e = script_handler_evas(script);
1401 script_handler_update_pointer(script, x, y, -1);
1402 evas_event_feed_mouse_in(e, timestamp, NULL);
1405 ErrPrint("Unsupported package\n");
1410 /*! \note No reply packet */
1414 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 */
1416 struct client_node *client;
1417 const char *pkgname;
1425 struct inst_info *inst;
1426 const struct pkg_info *pkg;
1428 client = client_find_by_pid(pid);
1430 ErrPrint("Client %d is not exists\n", pid);
1435 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1437 ErrPrint("Parameter is not matched\n");
1444 * Trust the package name which are sent by the client.
1445 * The package has to be a livebox package name.
1447 inst = package_find_instance_by_id(pkgname, id);
1449 ErrPrint("Instance[%s] is not exists\n", id);
1454 pkg = instance_package(inst);
1456 ErrPrint("Package[%s] info is not exists\n", pkgname);
1461 if (package_is_fault(pkg)) {
1464 * If the package is registered as fault module,
1465 * slave has not load it, so we don't need to do anything at here!
1467 DbgPrint("Package[%s] is faulted\n", pkgname);
1469 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1470 struct buffer_info *buffer;
1471 struct slave_node *slave;
1472 //struct packet *packet;
1474 buffer = instance_lb_buffer(inst);
1476 ErrPrint("Instance[%s] has no buffer\n", id);
1481 slave = package_slave(pkg);
1483 ErrPrint("Package[%s] has no slave\n", pkgname);
1489 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1491 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1497 packet_ref((struct packet *)packet);
1498 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1499 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1500 struct script_info *script;
1503 script = instance_lb_script(inst);
1509 e = script_handler_evas(script);
1515 script_handler_update_pointer(script, x, y, -1);
1516 evas_event_feed_mouse_out(e, timestamp, NULL);
1519 ErrPrint("Unsupported package\n");
1524 /*! \note No reply packet */
1528 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 */
1530 struct client_node *client;
1531 const char *pkgname;
1539 struct inst_info *inst;
1540 const struct pkg_info *pkg;
1542 client = client_find_by_pid(pid);
1544 ErrPrint("Client %d is not exists\n", pid);
1549 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1551 ErrPrint("Parameter is not matched\n");
1558 * Trust the package name which are sent by the client.
1559 * The package has to be a livebox package name.
1561 inst = package_find_instance_by_id(pkgname, id);
1563 ErrPrint("Instance[%s] is not exists\n", id);
1568 pkg = instance_package(inst);
1570 ErrPrint("Package[%s] info is not exists\n", pkgname);
1575 if (package_is_fault(pkg)) {
1578 * If the package is registered as fault module,
1579 * slave has not load it, so we don't need to do anything at here!
1581 DbgPrint("Package[%s] is faulted\n", pkgname);
1583 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1584 struct buffer_info *buffer;
1585 struct slave_node *slave;
1586 // struct packet *packet;
1588 buffer = instance_lb_buffer(inst);
1590 ErrPrint("Instance[%s] has no buffer\n", id);
1595 slave = package_slave(pkg);
1597 ErrPrint("Package[%s] has no slave\n", pkgname);
1603 packet = packet_create_noack("lb_mouse_down", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1605 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1611 packet_ref((struct packet *)packet);
1612 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1613 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1614 struct script_info *script;
1617 script = instance_lb_script(inst);
1623 e = script_handler_evas(script);
1629 script_handler_update_pointer(script, x, y, 1);
1630 evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
1631 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
1634 ErrPrint("Unsupported package\n");
1639 /*! \note No reply packet */
1643 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 */
1645 struct client_node *client;
1646 const char *pkgname;
1654 struct inst_info *inst;
1655 const struct pkg_info *pkg;
1657 client = client_find_by_pid(pid);
1659 ErrPrint("Client %d is not exists\n", pid);
1664 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1666 ErrPrint("Parameter is not matched\n");
1673 * Trust the package name which are sent by the client.
1674 * The package has to be a livebox package name.
1676 inst = package_find_instance_by_id(pkgname, id);
1678 ErrPrint("Instance[%s] is not exists\n", id);
1683 pkg = instance_package(inst);
1685 ErrPrint("Package[%s] info is not exists\n", pkgname);
1690 if (package_is_fault(pkg)) {
1693 * If the package is registered as fault module,
1694 * slave has not load it, so we don't need to do anything at here!
1696 DbgPrint("Package[%s] is faulted\n", pkgname);
1698 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
1699 struct buffer_info *buffer;
1700 struct slave_node *slave;
1701 //struct packet *packet;
1703 buffer = instance_lb_buffer(inst);
1705 ErrPrint("Instance[%s] has no buffer\n", id);
1710 slave = package_slave(pkg);
1712 ErrPrint("Package[%s] has no slave\n", pkgname);
1718 packet = packet_create_noack("lb_mouse_up", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1720 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1726 packet_ref((struct packet *)packet);
1727 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1728 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
1729 struct script_info *script;
1732 script = instance_lb_script(inst);
1738 e = script_handler_evas(script);
1744 script_handler_update_pointer(script, x, y, 0);
1745 evas_event_feed_mouse_move(e, x * w, y * h, timestamp, NULL);
1746 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
1749 ErrPrint("Unsupported package\n");
1754 /*! \note No reply packet */
1758 static struct packet *client_pd_access_read(pid_t pid, int handle, const struct packet *packet)
1760 struct client_node *client;
1761 const char *pkgname;
1769 struct inst_info *inst;
1770 const struct pkg_info *pkg;
1772 client = client_find_by_pid(pid);
1774 ErrPrint("Client %d is not exists\n", pid);
1779 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1781 ErrPrint("Invalid parameter\n");
1788 * Trust the package name which are sent by the client.
1789 * The package has to be a livebox package name.
1791 inst = package_find_instance_by_id(pkgname, id);
1793 ErrPrint("Instance[%s] is not exists\n", id);
1798 pkg = instance_package(inst);
1800 ErrPrint("Package[%s] info is not found\n", pkgname);
1805 if (package_is_fault(pkg)) {
1808 * If the package is registered as fault module,
1809 * slave has not load it, so we don't need to do anything at here!
1811 DbgPrint("Package[%s] is faulted\n", pkgname);
1813 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1814 struct buffer_info *buffer;
1815 struct slave_node *slave;
1816 // struct packet *packet;
1818 buffer = instance_pd_buffer(inst);
1820 ErrPrint("Instance[%s] has no buffer\n", id);
1825 slave = package_slave(pkg);
1827 ErrPrint("Package[%s] has no slave\n", pkgname);
1833 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1835 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1841 packet_ref((struct packet *)packet);
1842 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1843 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1844 struct script_info *script;
1847 script = instance_pd_script(inst);
1853 e = script_handler_evas(script);
1859 script_handler_update_pointer(script, x, y, -1);
1861 * \TODO: Push up the ACCESS_READ event
1865 ErrPrint("Unsupported package\n");
1870 /*! \note No reply packet */
1874 static struct packet *client_pd_access_read_prev(pid_t pid, int handle, const struct packet *packet)
1876 struct client_node *client;
1877 const char *pkgname;
1885 struct inst_info *inst;
1886 const struct pkg_info *pkg;
1888 client = client_find_by_pid(pid);
1890 ErrPrint("Client %d is not exists\n", pid);
1895 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
1897 ErrPrint("Invalid parameter\n");
1904 * Trust the package name which are sent by the client.
1905 * The package has to be a livebox package name.
1907 inst = package_find_instance_by_id(pkgname, id);
1909 ErrPrint("Instance[%s] is not exists\n", id);
1914 pkg = instance_package(inst);
1916 ErrPrint("Package[%s] info is not found\n", pkgname);
1921 if (package_is_fault(pkg)) {
1924 * If the package is registered as fault module,
1925 * slave has not load it, so we don't need to do anything at here!
1927 DbgPrint("Package[%s] is faulted\n", pkgname);
1929 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
1930 struct buffer_info *buffer;
1931 struct slave_node *slave;
1932 // struct packet *packet;
1934 buffer = instance_pd_buffer(inst);
1936 ErrPrint("Instance[%s] has no buffer\n", id);
1941 slave = package_slave(pkg);
1943 ErrPrint("Package[%s] has no slave\n", pkgname);
1949 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
1951 ErrPrint("Failed to create a packet[%s]\n", pkgname);
1957 packet_ref((struct packet *)packet);
1958 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
1959 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
1960 struct script_info *script;
1963 script = instance_pd_script(inst);
1969 e = script_handler_evas(script);
1975 script_handler_update_pointer(script, x, y, -1);
1977 * \TODO: Push up the ACCESS_READ_PREV event
1981 ErrPrint("Unsupported package\n");
1986 /*! \note No reply packet */
1990 static struct packet *client_pd_access_read_next(pid_t pid, int handle, const struct packet *packet)
1992 struct client_node *client;
1993 const char *pkgname;
2001 struct inst_info *inst;
2002 const struct pkg_info *pkg;
2004 client = client_find_by_pid(pid);
2006 ErrPrint("Client %d is not exists\n", pid);
2011 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2013 ErrPrint("Invalid parameter\n");
2020 * Trust the package name which are sent by the client.
2021 * The package has to be a livebox package name.
2023 inst = package_find_instance_by_id(pkgname, id);
2025 ErrPrint("Instance[%s] is not exists\n", id);
2030 pkg = instance_package(inst);
2032 ErrPrint("Package[%s] info is not found\n", pkgname);
2037 if (package_is_fault(pkg)) {
2040 * If the package is registered as fault module,
2041 * slave has not load it, so we don't need to do anything at here!
2043 DbgPrint("Package[%s] is faulted\n", pkgname);
2045 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2046 struct buffer_info *buffer;
2047 struct slave_node *slave;
2048 // struct packet *packet;
2050 buffer = instance_pd_buffer(inst);
2052 ErrPrint("Instance[%s] has no buffer\n", id);
2057 slave = package_slave(pkg);
2059 ErrPrint("Package[%s] has no slave\n", pkgname);
2065 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2067 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2073 packet_ref((struct packet *)packet);
2074 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2075 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2076 struct script_info *script;
2079 script = instance_pd_script(inst);
2085 e = script_handler_evas(script);
2091 script_handler_update_pointer(script, x, y, -1);
2093 * \TODO: Push up the ACCESS_READ_NEXT event
2097 ErrPrint("Unsupported package\n");
2102 /*! \note No reply packet */
2106 static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
2108 struct client_node *client;
2109 const char *pkgname;
2117 struct inst_info *inst;
2118 const struct pkg_info *pkg;
2120 client = client_find_by_pid(pid);
2122 ErrPrint("Client %d is not exists\n", pid);
2127 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2129 ErrPrint("Invalid parameter\n");
2136 * Trust the package name which are sent by the client.
2137 * The package has to be a livebox package name.
2139 inst = package_find_instance_by_id(pkgname, id);
2141 ErrPrint("Instance[%s] is not exists\n", id);
2146 pkg = instance_package(inst);
2148 ErrPrint("Package[%s] info is not found\n", pkgname);
2153 if (package_is_fault(pkg)) {
2156 * If the package is registered as fault module,
2157 * slave has not load it, so we don't need to do anything at here!
2159 DbgPrint("Package[%s] is faulted\n", pkgname);
2161 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2162 struct buffer_info *buffer;
2163 struct slave_node *slave;
2164 // struct packet *packet;
2166 buffer = instance_pd_buffer(inst);
2168 ErrPrint("Instance[%s] has no buffer\n", id);
2173 slave = package_slave(pkg);
2175 ErrPrint("Package[%s] has no slave\n", pkgname);
2181 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2183 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2189 packet_ref((struct packet *)packet);
2190 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2191 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2192 struct script_info *script;
2195 script = instance_pd_script(inst);
2201 e = script_handler_evas(script);
2207 script_handler_update_pointer(script, x, y, -1);
2209 * \TODO: Push up the ACCESS_READ_ACTIVATE event
2213 ErrPrint("Unsupported package\n");
2218 /*! \note No reply packet */
2222 static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
2224 struct client_node *client;
2225 const char *pkgname;
2233 struct inst_info *inst;
2234 const struct pkg_info *pkg;
2236 client = client_find_by_pid(pid);
2238 ErrPrint("Client %d is not exists\n", pid);
2243 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2245 ErrPrint("Invalid parameter\n");
2252 * Trust the package name which are sent by the client.
2253 * The package has to be a livebox package name.
2255 inst = package_find_instance_by_id(pkgname, id);
2257 ErrPrint("Instance[%s] is not exists\n", id);
2262 pkg = instance_package(inst);
2264 ErrPrint("Package[%s] info is not found\n", pkgname);
2269 if (package_is_fault(pkg)) {
2272 * If the package is registered as fault module,
2273 * slave has not load it, so we don't need to do anything at here!
2275 DbgPrint("Package[%s] is faulted\n", pkgname);
2277 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2278 struct buffer_info *buffer;
2279 struct slave_node *slave;
2280 // struct packet *packet;
2282 buffer = instance_pd_buffer(inst);
2284 ErrPrint("Instance[%s] has no buffer\n", id);
2289 slave = package_slave(pkg);
2291 ErrPrint("Package[%s] has no slave\n", pkgname);
2297 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2299 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2305 packet_ref((struct packet *)packet);
2306 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2307 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2308 struct script_info *script;
2311 script = instance_pd_script(inst);
2317 e = script_handler_evas(script);
2323 script_handler_update_pointer(script, x, y, -1);
2325 * \TODO: Push up the KEY_DOWN event
2329 ErrPrint("Unsupported package\n");
2334 /*! \note No reply packet */
2338 static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
2340 struct client_node *client;
2344 client = client_find_by_pid(pid);
2346 ErrPrint("Client %d is paused - manually reported\n", pid);
2351 ret = packet_get(packet, "d", ×tamp);
2353 ErrPrint("Invalid parameter\n");
2359 DbgPrint("XMONITOR enabled. ignore client paused request\n");
2361 xmonitor_pause(client);
2367 static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
2369 struct client_node *client;
2373 client = client_find_by_pid(pid);
2375 ErrPrint("Client %d is paused - manually reported\n", pid);
2380 ret = packet_get(packet, "d", ×tamp);
2382 ErrPrint("Invalid parameter\n");
2388 DbgPrint("XMONITOR enabled. ignore client resumed request\n");
2390 xmonitor_resume(client);
2396 static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
2398 struct client_node *client;
2399 const char *pkgname;
2407 struct inst_info *inst;
2408 const struct pkg_info *pkg;
2410 client = client_find_by_pid(pid);
2412 ErrPrint("Client %d is not exists\n", pid);
2417 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2419 ErrPrint("Invalid parameter\n");
2426 * Trust the package name which are sent by the client.
2427 * The package has to be a livebox package name.
2429 inst = package_find_instance_by_id(pkgname, id);
2431 ErrPrint("Instance[%s] is not exists\n", id);
2436 pkg = instance_package(inst);
2438 ErrPrint("Package[%s] info is not found\n", pkgname);
2443 if (package_is_fault(pkg)) {
2446 * If the package is registered as fault module,
2447 * slave has not load it, so we don't need to do anything at here!
2449 DbgPrint("Package[%s] is faulted\n", pkgname);
2451 } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
2452 struct buffer_info *buffer;
2453 struct slave_node *slave;
2454 // struct packet *packet;
2456 buffer = instance_pd_buffer(inst);
2458 ErrPrint("Instance[%s] has no buffer\n", id);
2463 slave = package_slave(pkg);
2465 ErrPrint("Package[%s] has no slave\n", pkgname);
2471 packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2473 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2479 packet_ref((struct packet *)packet);
2480 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2481 } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
2482 struct script_info *script;
2485 script = instance_pd_script(inst);
2491 e = script_handler_evas(script);
2497 script_handler_update_pointer(script, x, y, -1);
2499 * \TODO: Push up the KEY_UP event
2503 ErrPrint("Unsupported package\n");
2508 /*! \note No reply packet */
2512 static struct packet *client_lb_access_read(pid_t pid, int handle, const struct packet *packet)
2514 struct client_node *client;
2515 const char *pkgname;
2523 struct inst_info *inst;
2524 const struct pkg_info *pkg;
2526 client = client_find_by_pid(pid);
2528 ErrPrint("Client %d is not exists\n", pid);
2533 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2535 ErrPrint("Parameter is not matched\n");
2542 * Trust the package name which are sent by the client.
2543 * The package has to be a livebox package name.
2545 inst = package_find_instance_by_id(pkgname, id);
2547 ErrPrint("Instance[%s] is not exists\n", id);
2552 pkg = instance_package(inst);
2554 ErrPrint("Package[%s] info is not exists\n", pkgname);
2559 if (package_is_fault(pkg)) {
2562 * If the package is registered as fault module,
2563 * slave has not load it, so we don't need to do anything at here!
2565 DbgPrint("Package[%s] is faulted\n", pkgname);
2567 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2568 struct buffer_info *buffer;
2569 struct slave_node *slave;
2570 //struct packet *packet;
2572 buffer = instance_lb_buffer(inst);
2574 ErrPrint("Instance[%s] has no buffer\n", id);
2579 slave = package_slave(pkg);
2581 ErrPrint("Package[%s] has no slave\n", pkgname);
2587 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2589 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2595 packet_ref((struct packet *)packet);
2596 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2597 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2598 struct script_info *script;
2601 script = instance_lb_script(inst);
2607 e = script_handler_evas(script);
2613 script_handler_update_pointer(script, x, y, -1);
2616 * \TODO: Feed up this ACCESS_READ event
2620 ErrPrint("Unsupported package\n");
2625 /*! \note No reply packet */
2629 static struct packet *client_lb_access_read_prev(pid_t pid, int handle, const struct packet *packet)
2631 struct client_node *client;
2632 const char *pkgname;
2640 struct inst_info *inst;
2641 const struct pkg_info *pkg;
2643 client = client_find_by_pid(pid);
2645 ErrPrint("Client %d is not exists\n", pid);
2650 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2652 ErrPrint("Parameter is not matched\n");
2659 * Trust the package name which are sent by the client.
2660 * The package has to be a livebox package name.
2662 inst = package_find_instance_by_id(pkgname, id);
2664 ErrPrint("Instance[%s] is not exists\n", id);
2669 pkg = instance_package(inst);
2671 ErrPrint("Package[%s] info is not exists\n", pkgname);
2676 if (package_is_fault(pkg)) {
2679 * If the package is registered as fault module,
2680 * slave has not load it, so we don't need to do anything at here!
2682 DbgPrint("Package[%s] is faulted\n", pkgname);
2684 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2685 struct buffer_info *buffer;
2686 struct slave_node *slave;
2687 //struct packet *packet;
2689 buffer = instance_lb_buffer(inst);
2691 ErrPrint("Instance[%s] has no buffer\n", id);
2696 slave = package_slave(pkg);
2698 ErrPrint("Package[%s] has no slave\n", pkgname);
2704 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2706 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2712 packet_ref((struct packet *)packet);
2713 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2714 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2715 struct script_info *script;
2718 script = instance_lb_script(inst);
2724 e = script_handler_evas(script);
2730 script_handler_update_pointer(script, x, y, -1);
2733 * \TODO: Feed up this ACCESS_READ_PREV event
2737 ErrPrint("Unsupported package\n");
2742 /*! \note No reply packet */
2746 static struct packet *client_lb_access_read_next(pid_t pid, int handle, const struct packet *packet)
2748 struct client_node *client;
2749 const char *pkgname;
2757 struct inst_info *inst;
2758 const struct pkg_info *pkg;
2760 client = client_find_by_pid(pid);
2762 ErrPrint("Client %d is not exists\n", pid);
2767 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2769 ErrPrint("Parameter is not matched\n");
2776 * Trust the package name which are sent by the client.
2777 * The package has to be a livebox package name.
2779 inst = package_find_instance_by_id(pkgname, id);
2781 ErrPrint("Instance[%s] is not exists\n", id);
2786 pkg = instance_package(inst);
2788 ErrPrint("Package[%s] info is not exists\n", pkgname);
2793 if (package_is_fault(pkg)) {
2796 * If the package is registered as fault module,
2797 * slave has not load it, so we don't need to do anything at here!
2799 DbgPrint("Package[%s] is faulted\n", pkgname);
2801 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2802 struct buffer_info *buffer;
2803 struct slave_node *slave;
2804 //struct packet *packet;
2806 buffer = instance_lb_buffer(inst);
2808 ErrPrint("Instance[%s] has no buffer\n", id);
2813 slave = package_slave(pkg);
2815 ErrPrint("Package[%s] has no slave\n", pkgname);
2821 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2823 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2829 packet_ref((struct packet *)packet);
2830 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2831 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2832 struct script_info *script;
2835 script = instance_lb_script(inst);
2841 e = script_handler_evas(script);
2847 script_handler_update_pointer(script, x, y, -1);
2850 * \TODO: Feed up this ACCESS_READ_NEXT event
2854 ErrPrint("Unsupported package\n");
2859 /*! \note No reply packet */
2863 static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
2865 struct client_node *client;
2866 const char *pkgname;
2874 struct inst_info *inst;
2875 const struct pkg_info *pkg;
2877 client = client_find_by_pid(pid);
2879 ErrPrint("Client %d is not exists\n", pid);
2884 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
2886 ErrPrint("Parameter is not matched\n");
2893 * Trust the package name which are sent by the client.
2894 * The package has to be a livebox package name.
2896 inst = package_find_instance_by_id(pkgname, id);
2898 ErrPrint("Instance[%s] is not exists\n", id);
2903 pkg = instance_package(inst);
2905 ErrPrint("Package[%s] info is not exists\n", pkgname);
2910 if (package_is_fault(pkg)) {
2913 * If the package is registered as fault module,
2914 * slave has not load it, so we don't need to do anything at here!
2916 DbgPrint("Package[%s] is faulted\n", pkgname);
2918 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
2919 struct buffer_info *buffer;
2920 struct slave_node *slave;
2921 //struct packet *packet;
2923 buffer = instance_lb_buffer(inst);
2925 ErrPrint("Instance[%s] has no buffer\n", id);
2930 slave = package_slave(pkg);
2932 ErrPrint("Package[%s] has no slave\n", pkgname);
2938 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
2940 ErrPrint("Failed to create a packet[%s]\n", pkgname);
2946 packet_ref((struct packet *)packet);
2947 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
2948 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
2949 struct script_info *script;
2952 script = instance_lb_script(inst);
2958 e = script_handler_evas(script);
2964 script_handler_update_pointer(script, x, y, -1);
2967 * \TODO: Feed up this ACCESS_ACTIVATE event
2971 ErrPrint("Unsupported package\n");
2976 /*! \note No reply packet */
2980 static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
2982 struct client_node *client;
2983 const char *pkgname;
2991 struct inst_info *inst;
2992 const struct pkg_info *pkg;
2994 client = client_find_by_pid(pid);
2996 ErrPrint("Client %d is not exists\n", pid);
3001 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
3003 ErrPrint("Parameter is not matched\n");
3010 * Trust the package name which are sent by the client.
3011 * The package has to be a livebox package name.
3013 inst = package_find_instance_by_id(pkgname, id);
3015 ErrPrint("Instance[%s] is not exists\n", id);
3020 pkg = instance_package(inst);
3022 ErrPrint("Package[%s] info is not exists\n", pkgname);
3027 if (package_is_fault(pkg)) {
3030 * If the package is registered as fault module,
3031 * slave has not load it, so we don't need to do anything at here!
3033 DbgPrint("Package[%s] is faulted\n", pkgname);
3035 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3036 struct buffer_info *buffer;
3037 struct slave_node *slave;
3038 //struct packet *packet;
3040 buffer = instance_lb_buffer(inst);
3042 ErrPrint("Instance[%s] has no buffer\n", id);
3047 slave = package_slave(pkg);
3049 ErrPrint("Package[%s] has no slave\n", pkgname);
3055 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3057 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3063 packet_ref((struct packet *)packet);
3064 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3065 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3066 struct script_info *script;
3069 script = instance_lb_script(inst);
3075 e = script_handler_evas(script);
3081 script_handler_update_pointer(script, x, y, -1);
3084 * \TODO: Feed up this KEY_DOWN event
3088 ErrPrint("Unsupported package\n");
3093 /*! \note No reply packet */
3097 static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
3099 struct client_node *client;
3100 const char *pkgname;
3108 struct inst_info *inst;
3109 const struct pkg_info *pkg;
3111 client = client_find_by_pid(pid);
3113 ErrPrint("Client %d is not exists\n", pid);
3118 ret = packet_get(packet, "ssiiddd", &pkgname, &id, &w, &h, ×tamp, &x, &y);
3120 ErrPrint("Parameter is not matched\n");
3127 * Trust the package name which are sent by the client.
3128 * The package has to be a livebox package name.
3130 inst = package_find_instance_by_id(pkgname, id);
3132 ErrPrint("Instance[%s] is not exists\n", id);
3137 pkg = instance_package(inst);
3139 ErrPrint("Package[%s] info is not exists\n", pkgname);
3144 if (package_is_fault(pkg)) {
3147 * If the package is registered as fault module,
3148 * slave has not load it, so we don't need to do anything at here!
3150 DbgPrint("Package[%s] is faulted\n", pkgname);
3152 } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
3153 struct buffer_info *buffer;
3154 struct slave_node *slave;
3155 //struct packet *packet;
3157 buffer = instance_lb_buffer(inst);
3159 ErrPrint("Instance[%s] has no buffer\n", id);
3164 slave = package_slave(pkg);
3166 ErrPrint("Package[%s] has no slave\n", pkgname);
3172 packet = packet_create_noack("lb_mouse_leave", "ssiiddd", pkgname, id, w, h, timestamp, x, y);
3174 ErrPrint("Failed to create a packet[%s]\n", pkgname);
3180 packet_ref((struct packet *)packet);
3181 ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
3182 } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
3183 struct script_info *script;
3186 script = instance_lb_script(inst);
3192 e = script_handler_evas(script);
3198 script_handler_update_pointer(script, x, y, -1);
3201 * \TODO: Feed up this KEY_UP event
3205 ErrPrint("Unsupported package\n");
3210 /*! \note No reply packet */
3214 static int release_pixmap_cb(struct client_node *client, void *canvas)
3216 DbgPrint("Forcely unref the \"buffer\"\n");
3217 buffer_handler_pixmap_unref(canvas);
3218 return -1; /* Delete this callback */
3221 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 */
3223 struct packet *result;
3224 const char *pkgname;
3226 struct client_node *client;
3227 struct inst_info *inst;
3232 client = client_find_by_pid(pid);
3234 ErrPrint("Client %d is not exists\n", pid);
3238 ret = packet_get(packet, "ss", &pkgname, &id);
3240 ErrPrint("Parameter is not matched\n");
3246 * Trust the package name which are sent by the client.
3247 * The package has to be a livebox package name.
3249 inst = package_find_instance_by_id(pkgname, id);
3251 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3255 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3257 buf_ptr = buffer_handler_pixmap_ref(instance_lb_buffer(inst));
3259 ErrPrint("Failed to ref pixmap\n");
3263 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
3265 ErrPrint("Failed to add a new client deactivate callback\n");
3266 buffer_handler_pixmap_unref(buf_ptr);
3269 pixmap = buffer_handler_pixmap(instance_lb_buffer(inst));
3273 result = packet_create_reply(packet, "i", pixmap);
3275 ErrPrint("Failed to create a reply packet\n");
3280 static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
3282 const char *pkgname;
3284 struct client_node *client;
3285 struct inst_info *inst;
3290 client = client_find_by_pid(pid);
3292 ErrPrint("Client %d is not exists\n", pid);
3296 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
3298 ErrPrint("Parameter is not matched\n");
3301 DbgPrint("pid[%d] pkgname[%s] id[%s] Pixmap[0x%X]\n", pid, pkgname, id, pixmap);
3305 * Trust the package name which are sent by the client.
3306 * The package has to be a livebox package name.
3308 inst = package_find_instance_by_id(pkgname, id);
3310 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3314 buf_ptr = buffer_handler_pixmap_find(pixmap);
3316 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
3320 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
3321 buffer_handler_pixmap_unref(buf_ptr);
3324 /*! \note No reply packet */
3328 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 */
3330 struct packet *result;
3331 const char *pkgname;
3333 struct client_node *client;
3334 struct inst_info *inst;
3339 client = client_find_by_pid(pid);
3341 ErrPrint("Client %d is not exists\n", pid);
3345 ret = packet_get(packet, "ss", &pkgname, &id);
3347 ErrPrint("Parameter is not matched\n");
3353 * Trust the package name which are sent by the client.
3354 * The package has to be a livebox package name.
3356 inst = package_find_instance_by_id(pkgname, id);
3358 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3362 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3364 buf_ptr = buffer_handler_pixmap_ref(instance_pd_buffer(inst));
3366 ErrPrint("Failed to ref pixmap\n");
3370 ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
3372 buffer_handler_pixmap_unref(buf_ptr);
3374 pixmap = buffer_handler_pixmap(instance_pd_buffer(inst));
3376 result = packet_create_reply(packet, "i", pixmap);
3378 ErrPrint("Failed to create a reply packet\n");
3383 static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
3385 const char *pkgname;
3387 struct client_node *client;
3388 struct inst_info *inst;
3393 client = client_find_by_pid(pid);
3395 ErrPrint("Client %d is not exists\n", pid);
3399 ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
3401 ErrPrint("Parameter is not matched\n");
3404 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3408 * Trust the package name which are sent by the client.
3409 * The package has to be a livebox package name.
3411 inst = package_find_instance_by_id(pkgname, id);
3413 ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
3417 buf_ptr = buffer_handler_pixmap_find(pixmap);
3419 ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
3423 if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0)
3424 buffer_handler_pixmap_unref(buf_ptr);
3427 /*! \note No reply packet */
3431 static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
3433 struct client_node *client;
3434 struct packet *result;
3435 const char *pkgname;
3439 struct inst_info *inst;
3441 client = client_find_by_pid(pid);
3443 ErrPrint("Client %d is not exists\n", pid);
3449 ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
3451 ErrPrint("Parameter is not matched\n");
3457 DbgPrint("pid[%d] pkgname[%s] id[%s] pinup[%d]\n", pid, pkgname, id, pinup);
3461 * Trust the package name which are sent by the client.
3462 * The package has to be a livebox package name.
3464 inst = package_find_instance_by_id(pkgname, id);
3467 else if (package_is_fault(instance_package(inst)))
3470 ret = instance_set_pinup(inst, pinup);
3473 result = packet_create_reply(packet, "i", ret);
3475 ErrPrint("Failed to create a packet\n");
3480 static Eina_Bool lazy_pd_created_cb(void *data)
3482 DbgPrint("Send PD Create event\n");
3483 instance_client_pd_created(data, 0);
3485 instance_unref(data);
3486 return ECORE_CALLBACK_CANCEL;
3489 static Eina_Bool lazy_pd_destroyed_cb(void *data)
3491 DbgPrint("Send PD Destroy event\n");
3492 instance_client_pd_destroyed(data, 0);
3494 instance_unref(data);
3495 return ECORE_CALLBACK_CANCEL;
3498 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
3500 struct client_node *client;
3501 struct packet *result;
3502 const char *pkgname;
3505 struct inst_info *inst;
3509 client = client_find_by_pid(pid);
3511 ErrPrint("Client %d is not exists\n", pid);
3516 ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
3518 ErrPrint("Parameter is not matched\n");
3523 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3527 * Trust the package name which are sent by the client.
3528 * The package has to be a livebox package name.
3530 inst = package_find_instance_by_id(pkgname, id);
3533 else if (package_is_fault(instance_package(inst)))
3535 else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
3537 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
3538 instance_slave_set_pd_pos(inst, x, y);
3539 ret = instance_slave_open_pd(inst, client);
3540 ret = instance_signal_emit(inst,
3541 "pd,show", util_uri_to_path(instance_id(inst)),
3542 0.0, 0.0, 0.0, 0.0, x, y, 0);
3545 * PD craeted event will be send by the acquire_buffer function.
3546 * Because the slave will make request the acquire_buffer to
3549 * instance_client_pd_created(inst);
3551 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
3554 * ret value should be cared but in this case,
3555 * we ignore this for this moment, so we have to handle this error later.
3557 * if ret is less than 0, the slave has some problem.
3558 * but the script mode doesn't need slave for rendering default view of PD
3559 * so we can hanle it later.
3561 instance_slave_set_pd_pos(inst, x, y);
3562 ret = instance_slave_open_pd(inst, client);
3563 script_handler_update_pointer(instance_pd_script(inst), x, y, 0);
3564 ret = script_handler_load(instance_pd_script(inst), 1);
3568 * Send the PD created event to the clients,
3573 * But the created event has to be send afte return
3574 * from this function or the viewer couldn't care
3575 * the event correctly.
3577 inst = instance_ref(inst); /* To guarantee the inst */
3578 if (!ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst))
3579 instance_unref(inst);
3582 ErrPrint("Invalid PD TYPE\n");
3587 result = packet_create_reply(packet, "i", ret);
3589 ErrPrint("Failed to create a packet\n");
3594 static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
3596 struct client_node *client;
3597 struct packet *result;
3598 const char *pkgname;
3601 struct inst_info *inst;
3603 client = client_find_by_pid(pid);
3605 ErrPrint("Client %d is not exists\n", pid);
3610 ret = packet_get(packet, "ss", &pkgname, &id);
3612 ErrPrint("Parameter is not matched\n");
3617 DbgPrint("pid[%d] pkgname[%s] id[%s]\n", pid, pkgname, id);
3621 * Trust the package name which are sent by the client.
3622 * The package has to be a livebox package name.
3624 inst = package_find_instance_by_id(pkgname, id);
3627 else if (package_is_fault(instance_package(inst)))
3629 else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
3630 ret = instance_signal_emit(inst,
3631 "pd,hide", util_uri_to_path(instance_id(inst)),
3632 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
3633 ret = instance_slave_close_pd(inst, client);
3637 * release_buffer will be called by the slave after this.
3638 * Then it will send the "pd_destroyed" event to the client
3640 * instance_client_pd_destroyed(inst);
3643 } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
3644 ret = instance_slave_close_pd(inst, client);
3646 ret = script_handler_unload(instance_pd_script(inst), 1);
3650 * Send the destroyed PD event to the client
3653 inst = instance_ref(inst);
3654 if (!ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, inst))
3655 instance_unref(inst);
3658 ErrPrint("Invalid PD TYPE\n");
3663 result = packet_create_reply(packet, "i", ret);
3665 ErrPrint("Failed to create a packet\n");
3670 static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
3672 struct client_node *client;
3673 struct packet *result;
3674 const char *pkgname;
3676 struct pkg_info *info;
3678 client = client_find_by_pid(pid);
3680 ErrPrint("Client %d is not exists\n", pid);
3686 ret = packet_get(packet, "s", &pkgname);
3688 ErrPrint("Parameter is not matched\n");
3694 DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
3698 * Validate the livebox package name.
3700 if (!package_is_lb_pkgname(pkgname)) {
3701 ErrPrint("%s is not a valid livebox package\n", pkgname);
3707 info = package_find(pkgname);
3711 ret = package_clear_fault(info);
3714 result = packet_create_reply(packet, "is", ret, pkgname);
3716 ErrPrint("Failed to create a packet\n");
3721 static struct packet *client_subscribed(pid_t pid, int handle, const struct packet *packet)
3723 const char *cluster;
3724 const char *category;
3725 struct client_node *client;
3728 client = client_find_by_pid(pid);
3730 ErrPrint("Client %d is not exists\n", pid);
3735 ret = packet_get(packet, "ss", &cluster, &category);
3737 ErrPrint("Invalid argument\n");
3742 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
3743 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
3744 ErrPrint("Invalid cluster name\n");
3750 * SUBSCRIBE cluster & sub-cluster for a client.
3752 ret = client_subscribe(client, cluster, category);
3754 package_alter_instances_to_client(client, ALTER_CREATE);
3757 /*! \note No reply packet */
3761 static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
3763 const char *cluster;
3764 struct client_node *client;
3765 struct packet *result;
3768 client = client_find_by_pid(pid);
3770 ErrPrint("Client %d is not exists\n", pid);
3775 ret = packet_get(packet, "s", &cluster);
3777 ErrPrint("Invalid parameters\n");
3782 DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
3784 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
3785 ErrPrint("Invalid cluster: %s\n", cluster);
3796 result = packet_create_reply(packet, "i", ret);
3798 ErrPrint("Failed to create a packet\n");
3802 static inline int update_pkg_cb(struct category *category, const char *pkgname)
3807 c_name = group_cluster_name_by_category(category);
3808 s_name = group_category_name(category);
3810 if (!c_name || !s_name || !pkgname) {
3811 ErrPrint("Name is not valid\n");
3812 return EXIT_FAILURE;
3815 DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
3816 slave_rpc_request_update(pkgname, "", c_name, s_name);
3818 /* Just try to create a new package */
3819 if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
3821 struct inst_info *inst;
3823 timestamp = util_timestamp();
3826 * Don't need to check the subscribed clients.
3827 * Because this callback is called by the requests of clients.
3828 * It means. some clients wants to handle this instances ;)
3830 inst = instance_create(NULL, timestamp, pkgname, DEFAULT_CONTENT, c_name, s_name, DEFAULT_PERIOD, 0, 0);
3832 ErrPrint("Failed to create a new instance\n");
3834 ErrPrint("Not enough space\n");
3836 return EXIT_SUCCESS;
3839 static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
3841 struct inst_info *inst;
3842 struct client_node *client;
3843 const char *pkgname;
3847 client = client_find_by_pid(pid);
3849 ErrPrint("Cilent %d is not exists\n", pid);
3854 ret = packet_get(packet, "ss", &pkgname, &id);
3856 ErrPrint("Invalid argument\n");
3861 inst = package_find_instance_by_id(pkgname, id);
3864 } else if (package_is_fault(instance_package(inst))) {
3866 } else if (instance_client(inst) != client) {
3869 slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
3873 /*! \note No reply packet */
3877 static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
3879 const char *cluster_id;
3880 const char *category_id;
3881 struct client_node *client;
3883 struct cluster *cluster;
3884 struct category *category;
3885 struct context_info *info;
3886 Eina_List *info_list;
3889 client = client_find_by_pid(pid);
3891 ErrPrint("Cilent %d is not exists\n", pid);
3896 ret = packet_get(packet, "ss", &cluster_id, &category_id);
3898 ErrPrint("Invalid parameter\n");
3903 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
3905 if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
3906 ErrPrint("Invalid cluster name: %s\n", cluster_id);
3911 cluster = group_find_cluster(cluster_id);
3913 ErrPrint("Cluster [%s] is not registered\n", cluster_id);
3918 category = group_find_category(cluster, category_id);
3920 ErrPrint("Category [%s] is not registered\n", category_id);
3925 info_list = group_context_info_list(category);
3926 EINA_LIST_FOREACH(info_list, l, info) {
3927 update_pkg_cb(category, group_pkgname_from_context_info(info));
3931 /*! \note No reply packet */
3935 static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
3937 const char *cluster;
3938 const char *category;
3939 struct client_node *client;
3940 struct packet *result;
3943 client = client_find_by_pid(pid);
3945 ErrPrint("Client %d is not exists\n", pid);
3950 ret = packet_get(packet, "ss", &cluster, &category);
3952 ErrPrint("Invalid paramenters\n");
3957 DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
3958 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
3959 ErrPrint("Invalid cluster: %s\n", cluster);
3970 result = packet_create_reply(packet, "i", ret);
3972 ErrPrint("Failed to create a packet\n");
3976 static struct packet *client_unsubscribed(pid_t pid, int handle, const struct packet *packet)
3978 const char *cluster;
3979 const char *category;
3980 struct client_node *client;
3983 client = client_find_by_pid(pid);
3985 ErrPrint("Client %d is not exists\n", pid);
3990 ret = packet_get(packet, "ss", &cluster, &category);
3992 ErrPrint("Invalid argument\n");
3997 DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
3999 if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
4000 ErrPrint("Invalid cluster name: %s\n", cluster);
4006 * UNSUBSCRIBE cluster & sub-cluster for a client.
4008 ret = client_unsubscribe(client, cluster, category);
4010 package_alter_instances_to_client(client, ALTER_DESTROY);
4013 /*! \note No reply packet */
4017 static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
4019 struct slave_node *slave;
4020 const char *slavename;
4023 ret = packet_get(packet, "s", &slavename);
4025 ErrPrint("Parameter is not matched\n");
4030 DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
4032 slave = slave_find_by_pid(pid);
4035 char pkgname[pathconf("/", _PC_PATH_MAX)];
4038 if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
4039 ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
4040 slave = slave_find_by_name(slavename);
4041 pkgname[0] = '\0'; /* Reset the pkgname */
4043 slave = slave_find_by_pkgname(pkgname);
4047 abi = abi_find_by_pkgname(pkgname);
4050 DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
4053 slave = slave_create(slavename, 1, abi, pkgname);
4055 ErrPrint("Failed to create a new slave for %s\n", slavename);
4060 DbgPrint("New slave is created\n");
4062 DbgPrint("Registered slave is replaced with this new one\n");
4063 abi = slave_abi(slave);
4066 slave_set_pid(slave, pid);
4067 DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
4069 ErrPrint("Slave[%d] is not exists\n", pid);
4077 * After updating handle,
4078 * slave activated callback will be called.
4080 slave_rpc_update_handle(slave, handle);
4086 static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
4088 struct slave_node *slave;
4089 const char *slavename;
4092 slave = slave_find_by_pid(pid);
4094 ErrPrint("Slave %d is not exists\n", pid);
4099 ret = packet_get(packet, "s", &slavename);
4101 ErrPrint("Parameter is not matched\n");
4106 slave_rpc_ping(slave);
4112 static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
4114 struct slave_node *slave;
4115 struct inst_info *inst;
4116 const char *slavename;
4117 const char *pkgname;
4122 slave = slave_find_by_pid(pid);
4124 ErrPrint("Slave %d is not exists\n", pid);
4129 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4131 ErrPrint("Parameter is not matched\n");
4136 ret = fault_info_set(slave, pkgname, id, func);
4137 DbgPrint("Slave Faulted: %s (%d)\n", slavename, ret);
4139 inst = package_find_instance_by_id(pkgname, id);
4141 DbgPrint("There is a no such instance(%s)\n", id);
4143 } else if (instance_state(inst) == INST_DESTROYED) {
4144 ErrPrint("Instance(%s) is already destroyed\n", id);
4147 DbgPrint("Destroy instance(%s)\n", id);
4148 ret = instance_destroy(inst);
4155 static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
4157 struct slave_node *slave;
4158 const char *slavename;
4159 const char *pkgname;
4164 slave = slave_find_by_pid(pid);
4166 ErrPrint("Slave %d is not exists\n", pid);
4171 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4173 ErrPrint("Parameter is not matched\n");
4178 ret = fault_func_call(slave, pkgname, id, func);
4179 slave_give_more_ttl(slave);
4185 static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
4187 struct slave_node *slave;
4188 const char *slavename;
4189 const char *pkgname;
4194 slave = slave_find_by_pid(pid);
4196 ErrPrint("Slave %d is not exists\n", pid);
4201 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &func);
4203 ErrPrint("Parameter is not matched\n");
4208 ret = fault_func_ret(slave, pkgname, id, func);
4209 slave_give_more_ttl(slave);
4215 static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
4217 struct slave_node *slave;
4218 const char *slavename;
4219 const char *pkgname;
4221 const char *content_info;
4227 struct inst_info *inst;
4229 slave = slave_find_by_pid(pid);
4231 ErrPrint("Slave %d is not exists\n", pid);
4236 ret = packet_get(packet, "sssiidss", &slavename, &pkgname, &id,
4238 &content_info, &title);
4240 ErrPrint("Parameter is not matched\n");
4245 inst = package_find_instance_by_id(pkgname, id);
4248 } else if (package_is_fault(instance_package(inst))) {
4249 ErrPrint("Faulted instance cannot make any event.\n");
4251 } else if (instance_state(inst) == INST_DESTROYED) {
4252 ErrPrint("Instance is already destroyed\n");
4258 resized = (instance_lb_width(inst) != w) || (instance_lb_height(inst) != h);
4259 instance_set_lb_info(inst, w, h, priority, content_info, title);
4261 switch (package_lb_type(instance_package(inst))) {
4262 case LB_TYPE_SCRIPT:
4263 script_handler_resize(instance_lb_script(inst), w, h);
4265 filename = util_get_file_kept_in_safe(id);
4267 ret = script_handler_parse_desc(pkgname, id,
4271 ret = script_handler_parse_desc(pkgname, id,
4272 util_uri_to_path(id), 0);
4275 case LB_TYPE_BUFFER:
4279 * text format (inst)
4282 instance_send_resized_event(inst, IS_LB, w, h, 0);
4283 instance_lb_updated_by_instance(inst);
4288 slave_give_more_ttl(slave);
4295 static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
4297 struct slave_node *slave;
4298 const char *slavename;
4299 const char *pkgname;
4301 const char *descfile;
4303 struct inst_info *inst;
4305 slave = slave_find_by_pid(pid);
4307 ErrPrint("Slave %d is not exists\n", pid);
4312 ret = packet_get(packet, "ssss", &slavename, &pkgname, &id, &descfile);
4314 ErrPrint("Parameter is not matched\n");
4319 inst = package_find_instance_by_id(pkgname, id);
4322 } else if (package_is_fault(instance_package(inst))) {
4323 ErrPrint("Faulted package cannot make event\n");
4325 } else if (instance_state(inst) == INST_DESTROYED) {
4326 ErrPrint("Instance is already destroyed\n");
4329 switch (package_pd_type(instance_package(inst))) {
4330 case PD_TYPE_SCRIPT:
4331 DbgPrint("Script (%s)\n", id);
4332 if (script_handler_is_loaded(instance_pd_script(inst))) {
4333 ret = script_handler_parse_desc(pkgname, id,
4338 instance_set_pd_info(inst, 0, 0);
4339 case PD_TYPE_BUFFER:
4340 instance_pd_updated(pkgname, id, descfile);
4344 DbgPrint("Ignore updated DESC(%s - %s - %s)\n",
4345 pkgname, id, descfile);
4355 static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
4357 struct slave_node *slave;
4358 const char *slavename;
4359 const char *pkgname;
4362 struct inst_info *inst;
4364 slave = slave_find_by_pid(pid);
4366 ErrPrint("Slave %d is not exists\n", pid);
4371 ret = packet_get(packet, "sss", &slavename, &pkgname, &id);
4373 ErrPrint("Parameter is not matched\n");
4378 inst = package_find_instance_by_id(pkgname, id);
4381 else if (package_is_fault(instance_package(inst)))
4384 ret = instance_destroyed(inst);
4391 * \note for the BUFFER Type slave
4393 static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
4395 enum target_type target;
4396 const char *slavename;
4397 const char *pkgname;
4402 struct packet *result;
4403 struct slave_node *slave;
4404 struct inst_info *inst;
4405 const struct pkg_info *pkg;
4408 slave = slave_find_by_pid(pid);
4410 ErrPrint("Failed to find a slave\n");
4416 ret = packet_get(packet, "isssiii", &target, &slavename, &pkgname, &id, &w, &h, &pixel_size);
4418 ErrPrint("Invalid argument\n");
4424 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
4425 DbgPrint("No space\n");
4432 inst = package_find_instance_by_id(pkgname, id);
4434 DbgPrint("Package[%s] Id[%s] is not found\n", pkgname, id);
4440 pkg = instance_package(inst);
4443 if (target == TYPE_LB) {
4444 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4445 struct buffer_info *info;
4447 info = instance_lb_buffer(inst);
4449 if (!instance_create_lb_buffer(inst)) {
4450 ErrPrint("Failed to create a LB buffer\n");
4452 info = instance_lb_buffer(inst);
4454 ErrPrint("LB buffer is not valid\n");
4462 ret = buffer_handler_resize(info, w, h);
4463 DbgPrint("Buffer resize returns %d\n", ret);
4465 ret = buffer_handler_load(info);
4468 resized = (instance_lb_width(inst) != w) || (instance_lb_height(inst) != h);
4469 instance_set_lb_info(inst, w, h, -1.0f, NULL, NULL);
4470 id = buffer_handler_id(info);
4472 instance_send_resized_event(inst, IS_LB, w, h, 0);
4473 DbgPrint("Buffer handler ID: %s\n", id);
4475 DbgPrint("Failed to load a buffer(%d)\n", ret);
4478 } else if (target == TYPE_PD) {
4479 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
4480 struct buffer_info *info;
4482 DbgPrint("Slave acquire buffer for PD\n");
4484 info = instance_pd_buffer(inst);
4486 if (!instance_create_pd_buffer(inst)) {
4487 ErrPrint("Failed to create a PD buffer\n");
4489 info = instance_pd_buffer(inst);
4491 ErrPrint("PD buffer is not valid\n");
4494 instance_client_pd_created(inst, ret);
4500 ret = buffer_handler_resize(info, w, h);
4501 DbgPrint("Buffer resize returns %d\n", ret);
4503 ret = buffer_handler_load(info);
4506 resized = (instance_pd_width(inst) != w) || (instance_pd_height(inst) != h);
4507 instance_set_pd_info(inst, w, h);
4508 id = buffer_handler_id(info);
4510 instance_send_resized_event(inst, IS_PD, w, h, 0);
4511 DbgPrint("Buffer handler ID: %s\n", id);
4513 DbgPrint("Failed to load a buffer (%d)\n", ret);
4517 * Send the PD created event to the client
4519 instance_client_pd_created(inst, ret);
4524 result = packet_create_reply(packet, "is", ret, id);
4526 ErrPrint("Failed to create a packet\n");
4531 static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
4533 struct slave_node *slave;
4534 struct packet *result;
4535 enum target_type type;
4536 const char *slavename;
4537 const char *pkgname;
4541 struct inst_info *inst;
4542 const struct pkg_info *pkg;
4545 slave = slave_find_by_pid(pid);
4547 ErrPrint("Failed to find a slave\n");
4553 if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
4554 ErrPrint("Not enough space\n");
4560 ret = packet_get(packet, "isssii", &type, &slavename, &pkgname, &id, &w, &h);
4562 ErrPrint("Invalid argument\n");
4568 inst = package_find_instance_by_id(pkgname, id);
4570 DbgPrint("Instance is not found[%s] [%s]\n", pkgname, id);
4576 pkg = instance_package(inst);
4580 * THIS statement should not be entered.
4582 ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
4591 * Reset "id", It will be re-used from here
4594 if (type == TYPE_LB) {
4595 if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
4596 struct buffer_info *info;
4598 info = instance_lb_buffer(inst);
4600 ret = buffer_handler_resize(info, w, h);
4603 * id is resued for newly assigned ID
4608 id = buffer_handler_id(info);
4609 resized = (instance_lb_width(inst) != w) || (instance_lb_height(inst) != h);
4610 instance_set_lb_info(inst, w, h, -1.0f, NULL, NULL);
4612 instance_send_resized_event(inst, IS_LB, w, h, 0);
4616 } else if (type == TYPE_PD) {
4617 if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
4618 struct buffer_info *info;
4620 info = instance_pd_buffer(inst);
4622 ret = buffer_handler_resize(info, w, h);
4625 * id is resued for newly assigned ID
4629 id = buffer_handler_id(info);
4630 resized = (instance_pd_width(inst) != w) || (instance_pd_height(inst) != h);
4631 instance_set_pd_info(inst, w, h);
4633 instance_send_resized_event(inst, IS_PD, w, h, 0);
4640 result = packet_create_reply(packet, "is", ret, id);
4642 ErrPrint("Failed to create a packet\n");
4647 static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
4649 enum target_type type;
4650 const char *slavename;
4651 const char *pkgname;
4653 struct packet *result;
4654 struct slave_node *slave;
4655 struct inst_info *inst;
4658 slave = slave_find_by_pid(pid);
4660 ErrPrint("Failed to find a slave\n");
4665 if (packet_get(packet, "isss", &type, &slavename, &pkgname, &id) != 4) {
4666 ErrPrint("Inavlid argument\n");
4671 inst = package_find_instance_by_id(pkgname, id);
4673 ErrPrint("Instance is not found [%s - %s]\n", pkgname, id);
4679 if (type == TYPE_LB) {
4680 struct buffer_info *info;
4682 info = instance_lb_buffer(inst);
4683 ret = buffer_handler_unload(info);
4684 } else if (type == TYPE_PD) {
4685 struct buffer_info *info;
4687 DbgPrint("Slave release buffer for PD\n");
4689 info = instance_pd_buffer(inst);
4690 ret = buffer_handler_unload(info);
4694 * Send the PD destroyed event to the client
4696 instance_client_pd_destroyed(inst, ret);
4700 result = packet_create_reply(packet, "i", ret);
4702 ErrPrint("Failed to create a packet\n");
4707 static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
4709 struct packet *result;
4710 const char *pkgname;
4711 const char *cluster;
4712 const char *category;
4716 ret = packet_get(packet, "sss", &pkgname, &cluster, &category);
4718 ErrPrint("Invalid Packet\n");
4723 lb_pkgname = package_lb_pkgname(pkgname);
4725 ErrPrint("Invalid package %s\n", pkgname);
4732 * Validate the update requstor.
4734 slave_rpc_request_update(lb_pkgname, "", cluster, category);
4735 DbgFree(lb_pkgname);
4739 result = packet_create_reply(packet, "i", ret);
4741 ErrPrint("Failed to create a packet\n");
4746 static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
4748 struct liveinfo *info;
4749 struct packet *result;
4751 const char *fifo_name;
4754 DbgPrint("Request arrived from %d\n", pid);
4756 if (packet_get(packet, "d", ×tamp) != 1) {
4757 ErrPrint("Invalid packet\n");
4763 info = liveinfo_create(pid, handle);
4765 ErrPrint("Failed to create a liveinfo object\n");
4772 fifo_name = liveinfo_filename(info);
4773 DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
4776 result = packet_create_reply(packet, "si", fifo_name, ret);
4778 ErrPrint("Failed to create a result packet\n");
4783 static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
4787 struct liveinfo *info;
4788 struct slave_node *slave;
4792 if (packet_get(packet, "d", ×tamp) != 1) {
4793 ErrPrint("Invalid argument\n");
4797 info = liveinfo_find_by_pid(pid);
4799 ErrPrint("Invalid request\n");
4803 liveinfo_open_fifo(info);
4804 fp = liveinfo_fifo(info);
4806 liveinfo_close_fifo(info);
4810 list = (Eina_List *)slave_list();
4811 EINA_LIST_FOREACH(list, l, slave) {
4812 fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
4815 slave_pkgname(slave),
4817 slave_is_secured(slave),
4818 slave_refcnt(slave),
4819 slave_fault_count(slave),
4820 slave_state_string(slave),
4821 slave_loaded_instance(slave),
4822 slave_loaded_package(slave),
4827 fprintf(fp, "EOD\n");
4828 liveinfo_close_fifo(info);
4833 static inline const char *visible_state_string(enum livebox_visible_state state)
4840 case LB_HIDE_WITH_PAUSE:
4849 static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
4851 const char *pkgname;
4852 struct liveinfo *info;
4853 struct pkg_info *pkg;
4855 Eina_List *inst_list;
4856 struct inst_info *inst;
4859 if (packet_get(packet, "s", &pkgname) != 1) {
4860 ErrPrint("Invalid argument\n");
4864 info = liveinfo_find_by_pid(pid);
4866 ErrPrint("Invalid request\n");
4870 liveinfo_open_fifo(info);
4871 fp = liveinfo_fifo(info);
4873 ErrPrint("Invalid fp\n");
4874 liveinfo_close_fifo(info);
4878 if (!package_is_lb_pkgname(pkgname)) {
4879 ErrPrint("Invalid package name\n");
4883 pkg = package_find(pkgname);
4885 ErrPrint("Package is not exists\n");
4889 inst_list = package_instance_list(pkg);
4890 EINA_LIST_FOREACH(inst_list, l, inst) {
4891 fprintf(fp, "%s %s %s %lf %s %d %d\n",
4893 instance_cluster(inst),
4894 instance_category(inst),
4895 instance_period(inst),
4896 visible_state_string(instance_visible_state(inst)),
4897 instance_lb_width(inst),
4898 instance_lb_height(inst));
4902 fprintf(fp, "EOD\n");
4903 liveinfo_close_fifo(info);
4909 static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
4913 Eina_List *inst_list;
4914 struct liveinfo *info;
4915 struct pkg_info *pkg;
4916 struct slave_node *slave;
4918 const char *slavename;
4921 if (packet_get(packet, "d", ×tamp) != 1) {
4922 ErrPrint("Invalid argument\n");
4926 info = liveinfo_find_by_pid(pid);
4928 ErrPrint("Invalid request\n");
4932 liveinfo_open_fifo(info);
4933 fp = liveinfo_fifo(info);
4935 liveinfo_close_fifo(info);
4939 list = (Eina_List *)package_list();
4940 EINA_LIST_FOREACH(list, l, pkg) {
4941 slave = package_slave(pkg);
4944 slavename = slave_name(slave);
4945 pid = slave_pid(slave);
4951 inst_list = (Eina_List *)package_instance_list(pkg);
4952 fprintf(fp, "%d %s %s %s %d %d %d\n",
4954 strlen(slavename) ? slavename : "(none)",
4957 package_refcnt(pkg),
4958 package_fault_count(pkg),
4959 eina_list_count(inst_list)
4963 fprintf(fp, "EOD\n");
4964 liveinfo_close_fifo(info);
4969 static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
4974 static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
4976 struct liveinfo *info;
4982 if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
4983 ErrPrint("Invalid argument\n");
4987 info = liveinfo_find_by_pid(pid);
4989 ErrPrint("Invalid request\n");
4993 liveinfo_open_fifo(info);
4994 fp = liveinfo_fifo(info);
4996 liveinfo_close_fifo(info);
5000 if (!strcmp(cmd, "rmpack")) {
5001 fprintf(fp, "%d\n", ENOSYS);
5002 } else if (!strcmp(cmd, "rminst")) {
5003 struct inst_info *inst;
5004 inst = package_find_instance_by_id(pkgname, id);
5006 fprintf(fp, "%d\n", ENOENT);
5008 instance_destroy(inst);
5009 fprintf(fp, "%d\n", 0);
5013 fprintf(fp, "EOD\n");
5014 liveinfo_close_fifo(info);
5020 static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
5022 struct liveinfo *info;
5029 if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
5030 ErrPrint("Invalid argument\n");
5034 info = liveinfo_find_by_pid(pid);
5036 ErrPrint("Invalid request\n");
5040 if (!strcasecmp(var, "debug")) {
5041 if (!strcasecmp(cmd, "set")) {
5042 g_conf.debug_mode = !strcasecmp(val, "on");
5043 } else if (!strcasecmp(cmd, "get")) {
5045 ret = g_conf.debug_mode;
5046 } else if (!strcasecmp(var, "slave_max_load")) {
5047 if (!strcasecmp(cmd, "set")) {
5048 g_conf.slave_max_load = atoi(val);
5049 } else if (!strcasecmp(cmd, "get")) {
5051 ret = g_conf.slave_max_load;
5054 liveinfo_open_fifo(info);
5055 fp = liveinfo_fifo(info);
5057 liveinfo_close_fifo(info);
5060 fprintf(fp, "%d\nEOD\n", ret);
5061 liveinfo_close_fifo(info);
5067 static struct method s_info_table[] = {
5069 .cmd = "liveinfo_hello",
5070 .handler = liveinfo_hello,
5073 .cmd = "slave_list",
5074 .handler = liveinfo_slave_list,
5078 .handler = liveinfo_pkg_list,
5082 .handler = liveinfo_inst_list,
5085 .cmd = "slave_ctrl",
5086 .handler = liveinfo_slave_ctrl,
5090 .handler = liveinfo_pkg_ctrl,
5093 .cmd = "master_ctrl",
5094 .handler = liveinfo_master_ctrl,
5102 static struct method s_client_table[] = {
5104 .cmd = "pd_mouse_move",
5105 .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5108 .cmd = "lb_mouse_move",
5109 .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5112 .cmd = "pd_mouse_down",
5113 .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5116 .cmd = "pd_mouse_up",
5117 .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5120 .cmd = "lb_mouse_down",
5121 .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5124 .cmd = "lb_mouse_up",
5125 .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5128 .cmd = "pd_mouse_enter",
5129 .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5132 .cmd = "pd_mouse_leave",
5133 .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
5136 .cmd = "lb_mouse_enter",
5137 .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5140 .cmd = "lb_mouse_leave",
5141 .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
5144 .cmd = "change,visibility",
5145 .handler = client_change_visibility,
5148 .cmd = "lb_acquire_pixmap",
5149 .handler = client_lb_acquire_pixmap,
5152 .cmd = "lb_release_pixmap",
5153 .handler = client_lb_release_pixmap,
5156 .cmd = "pd_acquire_pixmap",
5157 .handler = client_pd_acquire_pixmap,
5160 .cmd = "pd_release_pixmap",
5161 .handler = client_pd_release_pixmap,
5165 .handler = client_acquire, /*!< pid, ret */
5169 .handler = cilent_release, /*!< pid, ret */
5173 .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
5176 .cmd = "text_signal",
5177 .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
5181 .handler = client_delete, /* pid, pkgname, filename, ret */
5185 .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
5189 .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
5192 .cmd = "set_period",
5193 .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
5196 .cmd = "change_group",
5197 .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
5200 .cmd = "pinup_changed",
5201 .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
5205 .handler = client_create_pd, /* pid, pkgname, filename, ret */
5208 .cmd = "destroy_pd",
5209 .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
5212 .cmd = "activate_package",
5213 .handler = client_activate_package, /* pid, pkgname, ret */
5216 .cmd = "subscribe", /* pid, cluster, sub-cluster */
5217 .handler = client_subscribed,
5220 .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
5221 .handler = client_unsubscribed,
5224 .cmd = "delete_cluster",
5225 .handler = client_delete_cluster,
5228 .cmd = "delete_category",
5229 .handler = client_delete_category,
5232 .cmd = "refresh_group",
5233 .handler = client_refresh_group,
5237 .handler = client_update,
5241 .cmd = "pd_access_read",
5242 .handler = client_pd_access_read,
5245 .cmd = "pd_access_read_prev",
5246 .handler = client_pd_access_read_prev,
5249 .cmd = "pd_access_read_next",
5250 .handler = client_pd_access_read_next,
5253 .cmd = "pd_access_activate",
5254 .handler = client_pd_access_activate,
5258 .cmd = "lb_access_read",
5259 .handler = client_lb_access_read,
5262 .cmd = "lb_access_read_prev",
5263 .handler = client_lb_access_read_prev,
5266 .cmd = "lb_access_read_next",
5267 .handler = client_lb_access_read_next,
5270 .cmd = "lb_access_activate",
5271 .handler = client_lb_access_activate,
5275 .cmd = "lb_key_down",
5276 .handler = client_lb_key_down,
5280 .handler = client_lb_key_up,
5284 .cmd = "pd_key_down",
5285 .handler = client_pd_key_down,
5289 .handler = client_pd_key_up,
5293 .cmd = "client_paused",
5294 .handler = client_pause_request,
5297 .cmd = "client_resumed",
5298 .handler = client_resume_request,
5307 static struct method s_service_table[] = {
5309 .cmd = "service_update",
5310 .handler = service_update,
5318 static struct method s_slave_table[] = {
5321 .handler = slave_hello, /* slave_name, ret */
5325 .handler = slave_ping, /* slave_name, ret */
5329 .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
5333 .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
5337 .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
5340 .cmd = "desc_updated",
5341 .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
5345 .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
5348 .cmd = "acquire_buffer",
5349 .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
5352 .cmd = "resize_buffer",
5353 .handler = slave_resize_buffer,
5356 .cmd = "release_buffer",
5357 .handler = slave_release_buffer, /* slave_name, id - ret */
5361 .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
5369 HAPI int server_init(void)
5371 com_core_packet_use_thread(COM_CORE_THREAD);
5373 if (unlink(INFO_SOCKET) < 0)
5374 ErrPrint("info socket: %s\n", strerror(errno));
5376 if (unlink(SLAVE_SOCKET) < 0)
5377 ErrPrint("slave socket: %s\n", strerror(errno));
5379 if (unlink(CLIENT_SOCKET) < 0)
5380 ErrPrint("client socket: %s\n", strerror(errno));
5382 if (unlink(SERVICE_SOCKET) < 0)
5383 ErrPrint("service socket: %s\n", strerror(errno));
5385 s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
5386 if (s_info.info_fd < 0)
5387 ErrPrint("Failed to create a info socket\n");
5389 s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
5390 if (s_info.slave_fd < 0)
5391 ErrPrint("Failed to create a slave socket\n");
5393 s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
5394 if (s_info.client_fd < 0)
5395 ErrPrint("Failed to create a client socket\n");
5397 s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
5398 if (s_info.service_fd < 0)
5399 ErrPrint("Faild to create a service socket\n");
5401 if (chmod(INFO_SOCKET, 0600) < 0)
5402 ErrPrint("info socket: %s\n", strerror(errno));
5404 if (chmod(SLAVE_SOCKET, 0666) < 0)
5405 ErrPrint("slave socket: %s\n", strerror(errno));
5407 if (chmod(CLIENT_SOCKET, 0666) < 0)
5408 ErrPrint("client socket: %s\n", strerror(errno));
5410 if (chmod(SERVICE_SOCKET, 0666) < 0)
5411 ErrPrint("service socket: %s\n", strerror(errno));
5416 HAPI int server_fini(void)
5418 if (s_info.info_fd > 0) {
5419 com_core_packet_server_fini(s_info.info_fd);
5420 s_info.info_fd = -1;
5423 if (s_info.slave_fd > 0) {
5424 com_core_packet_server_fini(s_info.slave_fd);
5425 s_info.slave_fd = -1;
5428 if (s_info.client_fd > 0) {
5429 com_core_packet_server_fini(s_info.client_fd);
5430 s_info.client_fd = -1;
5433 if (s_info.service_fd > 0) {
5434 com_core_packet_server_fini(s_info.service_fd);
5435 s_info.service_fd = -1;