2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <stdlib.h> /* malloc */
20 #include <string.h> /* strdup */
27 #include <com-core_packet.h>
29 #include <livebox-service.h>
30 #include <livebox-errno.h>
35 #include "livebox_internal.h"
38 #include "master_rpc.h"
40 #include "critical_log.h"
42 #define EAPI __attribute__((visibility("default")))
43 #define MINIMUM_EVENT s_info.event_filter
50 struct dlist *livebox_list;
51 struct dlist *event_list;
52 struct dlist *fault_list;
54 int prevent_overwrite;
61 .prevent_overwrite = 0,
62 .event_filter = 0.01f,
71 int (*handler)(struct livebox *handler, enum livebox_event_type event, void *data);
76 int (*handler)(enum livebox_fault_type event, const char *pkgname, const char *filename, const char *func, void *data);
80 static inline void default_create_cb(struct livebox *handler, int ret, void *data)
82 DbgPrint("Default created event handler: %d\n", ret);
85 static inline void default_delete_cb(struct livebox *handler, int ret, void *data)
87 DbgPrint("Default deleted event handler: %d\n", ret);
90 static inline void default_pinup_cb(struct livebox *handler, int ret, void *data)
92 DbgPrint("Default pinup event handler: %d\n", ret);
95 static inline void default_group_changed_cb(struct livebox *handler, int ret, void *data)
97 DbgPrint("Default group changed event handler: %d\n", ret);
100 static inline void default_period_changed_cb(struct livebox *handler, int ret, void *data)
102 DbgPrint("Default period changed event handler: %d\n", ret);
105 static inline void default_pd_created_cb(struct livebox *handler, int ret, void *data)
107 DbgPrint("Default PD created event handler: %d\n", ret);
110 static inline void default_pd_destroyed_cb(struct livebox *handler, int ret, void *data)
112 DbgPrint("Default PD destroyed event handler: %d\n", ret);
115 static inline void default_lb_size_changed_cb(struct livebox *handler, int ret, void *data)
117 DbgPrint("Default LB size changed event handler: %d\n", ret);
120 static inline void default_update_mode_cb(struct livebox *handler, int ret, void *data)
122 DbgPrint("Default update mode set event handler: %d\n", ret);
125 static inline void default_access_event_cb(struct livebox *handler, int ret, void *data)
127 DbgPrint("Default access event handler: %d\n", ret);
130 static inline __attribute__((always_inline)) struct cb_info *create_cb_info(ret_cb_t cb, void *data)
132 struct cb_info *info;
134 info = malloc(sizeof(*info));
136 CRITICAL_LOG("Heap: %s\n", strerror(errno));
145 static inline void destroy_cb_info(struct cb_info *info)
150 static void update_mode_cb(struct livebox *handler, const struct packet *result, void *data)
155 ret = LB_STATUS_ERROR_FAULT;
157 } else if (packet_get(result, "i", &ret) != 1) {
158 ErrPrint("Invalid argument\n");
159 ret = LB_STATUS_ERROR_INVALID;
164 ErrPrint("Resize request is failed: %d\n", ret);
171 handler->update_mode_cb(handler, ret, handler->update_mode_cbdata);
172 handler->update_mode_cb = NULL;
173 handler->update_mode_cbdata = NULL;
177 static void resize_cb(struct livebox *handler, const struct packet *result, void *data)
182 ret = LB_STATUS_ERROR_FAULT;
184 } else if (packet_get(result, "i", &ret) != 1) {
185 ErrPrint("Invalid argument\n");
186 ret = LB_STATUS_ERROR_INVALID;
192 * In case of resize request,
193 * The livebox handler will not have resized value right after this callback,
194 * It can only get the new size when it makes updates.
196 * So the user can only get the resized value(result) from the first update event
197 * after this request.
200 ErrPrint("Resize request is failed: %d\n", ret);
207 handler->size_changed_cb(handler, ret, handler->size_cbdata);
208 handler->size_changed_cb = NULL;
209 handler->size_cbdata = NULL;
212 static void text_signal_cb(struct livebox *handler, const struct packet *result, void *data)
216 struct cb_info *info = data;
221 destroy_cb_info(info);
224 ret = LB_STATUS_ERROR_FAULT;
225 } else if (packet_get(result, "i", &ret) != 1) {
226 ErrPrint("Invalid argument\n");
227 ret = LB_STATUS_ERROR_INVALID;
231 cb(handler, ret, cbdata);
236 static void set_group_ret_cb(struct livebox *handler, const struct packet *result, void *data)
241 ret = LB_STATUS_ERROR_FAULT;
243 } else if (packet_get(result, "i", &ret) != 1) {
244 ErrPrint("Invalid argument\n");
245 ret = LB_STATUS_ERROR_INVALID;
256 handler->group_changed_cb(handler, ret, handler->group_cbdata);
257 handler->group_changed_cb = NULL;
258 handler->group_cbdata = NULL;
261 static void period_ret_cb(struct livebox *handler, const struct packet *result, void *data)
266 ret = LB_STATUS_ERROR_FAULT;
268 } else if (packet_get(result, "i", &ret) != 1) {
269 ErrPrint("Invalid argument\n");
270 ret = LB_STATUS_ERROR_INVALID;
281 handler->period_changed_cb(handler, ret, handler->period_cbdata);
282 handler->period_changed_cb = NULL;
283 handler->period_cbdata = NULL;
286 static void del_ret_cb(struct livebox *handler, const struct packet *result, void *data)
288 struct cb_info *info = data;
295 destroy_cb_info(info);
298 ErrPrint("Connection lost?\n");
299 ret = LB_STATUS_ERROR_FAULT;
300 } else if (packet_get(result, "i", &ret) != 1) {
301 ErrPrint("Invalid argument\n");
302 ret = LB_STATUS_ERROR_INVALID;
306 handler->deleted_cb = cb;
307 handler->deleted_cbdata = cbdata;
309 cb(handler, ret, cbdata);
314 * Do not call the deleted callback from here.
315 * master will send the "deleted" event.
316 * Then invoke this callback.
318 * if (handler->deleted_cb)
319 * handler->deleted_cb(handler, ret, handler->deleted_cbdata);
323 static void new_ret_cb(struct livebox *handler, const struct packet *result, void *data)
326 struct cb_info *info = data;
332 destroy_cb_info(info);
335 ret = LB_STATUS_ERROR_FAULT;
336 } else if (packet_get(result, "i", &ret) != 1) {
337 ret = LB_STATUS_ERROR_INVALID;
341 handler->created_cb = cb;
342 handler->created_cbdata = cbdata;
346 * Don't go anymore ;)
352 * It means the current instance is not created,
353 * so user has to know about this.
354 * notice it to user using "deleted" event.
356 cb(handler, ret, cbdata);
362 static void pd_create_cb(struct livebox *handler, const struct packet *result, void *data)
367 ret = LB_STATUS_ERROR_FAULT;
369 } else if (packet_get(result, "i", &ret) != 1) {
370 ret = LB_STATUS_ERROR_INVALID;
375 ErrPrint("Failed to create a PD[%d]\n", ret);
382 handler->pd_created_cb(handler, ret, handler->pd_created_cbdata);
383 handler->pd_created_cb = NULL;
384 handler->pd_created_cbdata = NULL;
387 static void activated_cb(struct livebox *handler, const struct packet *result, void *data)
390 struct cb_info *info = data;
393 const char *pkgname = "";
397 destroy_cb_info(info);
400 ret = LB_STATUS_ERROR_FAULT;
401 } else if (packet_get(result, "is", &ret, &pkgname) != 2) {
402 ret = LB_STATUS_ERROR_INVALID;
406 cb(handler, ret, cbdata);
410 static void pd_destroy_cb(struct livebox *handler, const struct packet *result, void *data)
415 struct cb_info *info = data;
419 destroy_cb_info(info);
422 ErrPrint("Result is NIL (may connection lost)\n");
423 ret = LB_STATUS_ERROR_FAULT;
424 } else if (packet_get(result, "i", &ret) != 1) {
425 ErrPrint("Invalid parameter\n");
426 ret = LB_STATUS_ERROR_INVALID;
430 handler->pd_destroyed_cb = cb;
431 handler->pd_destroyed_cbdata = cbdata;
433 handler->is_pd_created = 0;
434 cb(handler, ret, cbdata);
438 static void delete_cluster_cb(struct livebox *handler, const struct packet *result, void *data)
440 struct cb_info *info = data;
447 destroy_cb_info(info);
450 ret = LB_STATUS_ERROR_FAULT;
451 } else if (packet_get(result, "i", &ret) != 1) {
452 ret = LB_STATUS_ERROR_INVALID;
456 cb(handler, ret, cbdata);
460 static void delete_category_cb(struct livebox *handler, const struct packet *result, void *data)
462 struct cb_info *info = data;
469 destroy_cb_info(info);
472 ret = LB_STATUS_ERROR_FAULT;
473 } else if (packet_get(result, "i", &ret) != 1) {
474 ret = LB_STATUS_ERROR_INVALID;
478 cb(handler, ret, cbdata);
482 static void lb_pixmap_acquired_cb(struct livebox *handler, const struct packet *result, void *data)
485 int ret = LB_STATUS_ERROR_INVALID;
488 struct cb_info *info = data;
492 destroy_cb_info(info);
495 pixmap = 0; /* PIXMAP 0 means error */
496 } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
500 if (ret == LB_STATUS_ERROR_BUSY) {
501 ret = livebox_acquire_lb_pixmap(handler, cb, cbdata);
502 DbgPrint("Busy, Try again: %d\n", ret);
506 cb(handler, pixmap, cbdata);
511 static void pd_pixmap_acquired_cb(struct livebox *handler, const struct packet *result, void *data)
517 struct cb_info *info = data;
521 destroy_cb_info(info);
524 pixmap = 0; /* PIXMAP 0 means error */
525 ret = LB_STATUS_ERROR_FAULT;
526 } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
528 ret = LB_STATUS_ERROR_INVALID;
531 if (ret == LB_STATUS_ERROR_BUSY) {
532 ret = livebox_acquire_pd_pixmap(handler, cb, cbdata);
533 DbgPrint("Busy, Try again: %d\n", ret);
537 DbgPrint("ret: %d, pixmap: %d\n", ret, pixmap);
538 cb(handler, pixmap, cbdata);
543 static void pinup_done_cb(struct livebox *handler, const struct packet *result, void *data)
548 ret = LB_STATUS_ERROR_FAULT;
550 } else if (packet_get(result, "i", &ret) != 1) {
561 handler->pinup_cb(handler, ret, handler->pinup_cbdata);
562 handler->pinup_cb = NULL;
563 handler->pinup_cbdata = NULL;
566 static void access_ret_cb(struct livebox *handler, const struct packet *result, void *data)
571 ret = LB_STATUS_ERROR_FAULT;
575 if (packet_get(result, "i", &ret) != 1) {
576 ret = LB_STATUS_ERROR_INVALID;
580 if (ret != LB_STATUS_SUCCESS) {
587 handler->access_event_cb(handler, ret, handler->access_event_cbdata);
588 handler->access_event_cb = NULL;
589 handler->access_event_cbdata = NULL;
593 static int send_access_event(struct livebox *handler, const char *event, int x, int y)
595 struct packet *packet;
598 timestamp = util_timestamp();
600 packet = packet_create(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y);
602 ErrPrint("Failed to build packet\n");
603 return LB_STATUS_ERROR_FAULT;
606 return master_rpc_async_request(handler, packet, 0, access_ret_cb, NULL);
609 static int send_mouse_event(struct livebox *handler, const char *event, int x, int y)
611 struct packet *packet;
614 timestamp = util_timestamp();
615 packet = packet_create_noack(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y);
617 ErrPrint("Failed to build param\n");
618 return LB_STATUS_ERROR_FAULT;
621 return master_rpc_request_only(handler, packet);
624 EAPI int livebox_init(void *disp)
628 if (s_info.init_count > 0) {
630 return LB_STATUS_SUCCESS;
632 env = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
633 if (env && !strcasecmp(env, "true")) {
634 s_info.prevent_overwrite = 1;
637 env = getenv("PROVIDER_EVENT_FILTER");
639 sscanf(env, "%lf", &MINIMUM_EVENT);
643 char filename[BUFSIZ];
644 snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
645 __file_log_fp = fopen(filename, "w+t");
646 if (!__file_log_fp) {
647 __file_log_fp = fdopen(1, "w+t");
650 critical_log_init("viewer");
651 livebox_service_init();
657 return LB_STATUS_SUCCESS;
660 EAPI int livebox_fini(void)
662 if (s_info.init_count <= 0) {
663 ErrPrint("Doesn't initialized\n");
664 return LB_STATUS_ERROR_INVALID;
668 if (s_info.init_count > 0) {
669 ErrPrint("init count : %d\n", s_info.init_count);
670 return LB_STATUS_SUCCESS;
675 livebox_service_fini();
677 return LB_STATUS_SUCCESS;
680 static inline char *lb_pkgname(const char *pkgname)
684 lb = livebox_service_pkgname(pkgname);
686 if (util_validate_livebox_package(pkgname) == 0) {
687 return strdup(pkgname);
695 * Just wrapping the livebox_add_with_size function.
697 EAPI struct livebox *livebox_add(const char *pkgname, const char *content, const char *cluster, const char *category, double period, ret_cb_t cb, void *data)
699 return livebox_add_with_size(pkgname, content, cluster, category, period, LB_SIZE_TYPE_UNKNOWN, cb, data);
702 EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int type, ret_cb_t cb, void *data)
704 struct livebox *handler;
705 struct packet *packet;
709 struct cb_info *cbinfo;
711 if (!pkgname || !cluster || !category) {
712 ErrPrint("Invalid arguments: pkgname[%p], cluster[%p], category[%p]\n",
713 pkgname, cluster, category);
717 if (type != LB_SIZE_TYPE_UNKNOWN) {
718 livebox_service_get_size(type, &width, &height);
721 handler = calloc(1, sizeof(*handler));
723 ErrPrint("Error: %s\n", strerror(errno));
727 handler->pkgname = lb_pkgname(pkgname);
728 if (!handler->pkgname) {
733 if (livebox_service_is_enabled(handler->pkgname) == 0) {
734 DbgPrint("Livebox [%s](%s) is disabled package\n", handler->pkgname, pkgname);
735 free(handler->pkgname);
740 if (content && strlen(content)) {
741 handler->content = strdup(content);
742 if (!handler->content) {
743 ErrPrint("Error: %s\n", strerror(errno));
744 free(handler->pkgname);
749 handler->content = livebox_service_content(handler->pkgname);
752 handler->cluster = strdup(cluster);
753 if (!handler->cluster) {
754 ErrPrint("Error: %s\n", strerror(errno));
755 free(handler->content);
756 free(handler->pkgname);
761 handler->category = strdup(category);
762 if (!handler->category) {
763 ErrPrint("Error: %s\n", strerror(errno));
764 free(handler->cluster);
765 free(handler->content);
766 free(handler->pkgname);
772 cb = default_create_cb;
775 /* Data provider will set this */
776 handler->lb.type = _LB_TYPE_FILE;
777 handler->pd.type = _PD_TYPE_SCRIPT;
778 handler->lb.period = period;
780 /* Used for handling the mouse event on a box */
781 handler->lb.mouse_event = livebox_service_mouse_event(handler->pkgname);
783 /* Cluster infomration is not determined yet */
784 handler->nr_of_sizes = 0x01;
786 handler->timestamp = util_timestamp();
787 handler->is_user = 1;
788 handler->visible = LB_SHOW;
790 s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
792 packet = packet_create("new", "dssssdii", handler->timestamp, handler->pkgname, handler->content, cluster, category, period, width, height);
794 ErrPrint("Failed to create a new packet\n");
795 free(handler->category);
796 free(handler->cluster);
797 free(handler->content);
798 free(handler->pkgname);
803 cbinfo = create_cb_info(cb, data);
805 ErrPrint("Failed to create a cbinfo\n");
806 packet_destroy(packet);
807 free(handler->category);
808 free(handler->cluster);
809 free(handler->content);
810 free(handler->pkgname);
815 ret = master_rpc_async_request(handler, packet, 0, new_ret_cb, cbinfo);
817 ErrPrint("Failed to send a new packet\n");
818 destroy_cb_info(cbinfo);
819 free(handler->category);
820 free(handler->cluster);
821 free(handler->content);
822 free(handler->pkgname);
827 handler->state = CREATE;
828 return lb_ref(handler);
831 EAPI double livebox_period(struct livebox *handler)
833 if (!handler || handler->state != CREATE || !handler->id) {
834 ErrPrint("Handler is not valid\n");
838 return handler->lb.period;
841 EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, void *data)
843 struct packet *packet;
846 if (!handler || handler->state != CREATE || !handler->id) {
847 ErrPrint("Handler is not valid\n");
848 return LB_STATUS_ERROR_INVALID;
851 if (handler->period_changed_cb) {
852 ErrPrint("Previous request for changing period is not finished\n");
853 return LB_STATUS_ERROR_BUSY;
856 if (!handler->is_user) {
857 ErrPrint("CA Livebox is not able to change the period\n");
858 return LB_STATUS_ERROR_PERMISSION;
861 if (handler->lb.period == period) {
862 DbgPrint("No changes\n");
863 return LB_STATUS_ERROR_ALREADY;
866 packet = packet_create("set_period", "ssd", handler->pkgname, handler->id, period);
868 ErrPrint("Failed to build a packet %s\n", handler->pkgname);
869 return LB_STATUS_ERROR_FAULT;
873 cb = default_period_changed_cb;
876 ret = master_rpc_async_request(handler, packet, 0, period_ret_cb, NULL);
877 if (ret == LB_STATUS_SUCCESS) {
878 handler->period_changed_cb = cb;
879 handler->period_cbdata = data;
885 EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data)
888 ErrPrint("Handler is NIL\n");
889 return LB_STATUS_ERROR_INVALID;
892 if (handler->state != CREATE) {
893 ErrPrint("Handler is already deleted\n");
894 return LB_STATUS_ERROR_INVALID;
897 handler->state = DELETE;
902 * The id is not determined yet.
903 * It means a user didn't receive created event yet.
904 * Then just stop to delete procedure from here.
905 * Because the "created" event handler will release this.
906 * By the way, if the user adds any callback for getting return status of this,
910 cb(handler, 0, data);
912 return LB_STATUS_SUCCESS;
916 cb = default_delete_cb;
919 return lb_send_delete(handler, cb, data);
922 EAPI int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *), void *data)
924 struct fault_info *info;
927 return LB_STATUS_ERROR_INVALID;
930 info = malloc(sizeof(*info));
932 CRITICAL_LOG("Heap: %s\n", strerror(errno));
933 return LB_STATUS_ERROR_MEMORY;
937 info->user_data = data;
939 s_info.fault_list = dlist_append(s_info.fault_list, info);
940 return LB_STATUS_SUCCESS;
943 EAPI void *livebox_unset_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *))
945 struct fault_info *info;
948 dlist_foreach(s_info.fault_list, l, info) {
949 if (info->handler == cb) {
952 s_info.fault_list = dlist_remove(s_info.fault_list, l);
953 data = info->user_data;
963 EAPI int livebox_set_event_handler(int (*cb)(struct livebox *, enum livebox_event_type, void *), void *data)
965 struct event_info *info;
968 ErrPrint("Invalid argument cb is nil\n");
969 return LB_STATUS_ERROR_INVALID;
972 info = malloc(sizeof(*info));
974 CRITICAL_LOG("Heap: %s\n", strerror(errno));
975 return LB_STATUS_ERROR_MEMORY;
979 info->user_data = data;
981 s_info.event_list = dlist_append(s_info.event_list, info);
982 return LB_STATUS_SUCCESS;
985 EAPI void *livebox_unset_event_handler(int (*cb)(struct livebox *, enum livebox_event_type, void *))
987 struct event_info *info;
990 dlist_foreach(s_info.event_list, l, info) {
991 if (info->handler == cb) {
994 s_info.event_list = dlist_remove(s_info.event_list, l);
995 data = info->user_data;
1005 EAPI int livebox_set_update_mode(struct livebox *handler, int active_update, ret_cb_t cb, void *data)
1007 struct packet *packet;
1011 ErrPrint("Handler is NIL\n");
1012 return LB_STATUS_ERROR_INVALID;
1015 if (handler->state != CREATE || !handler->id) {
1016 return LB_STATUS_ERROR_INVALID;
1019 if (handler->update_mode_cb) {
1020 ErrPrint("Previous update_mode cb is not finished yet\n");
1021 return LB_STATUS_ERROR_BUSY;
1024 if (handler->is_active_update == active_update) {
1025 return LB_STATUS_ERROR_ALREADY;
1028 if (!handler->is_user) {
1029 return LB_STATUS_ERROR_PERMISSION;
1032 packet = packet_create("update_mode", "ssi", handler->pkgname, handler->id, active_update);
1034 return LB_STATUS_ERROR_FAULT;
1038 cb = default_update_mode_cb;
1041 ret = master_rpc_async_request(handler, packet, 0, update_mode_cb, NULL);
1042 if (ret == LB_STATUS_SUCCESS) {
1043 handler->update_mode_cb = cb;
1044 handler->update_mode_cbdata = data;
1050 EAPI int livebox_is_active_update(struct livebox *handler)
1053 ErrPrint("Handler is NIL\n");
1054 return LB_STATUS_ERROR_INVALID;
1057 if (handler->state != CREATE || !handler->id) {
1058 return LB_STATUS_ERROR_INVALID;
1061 return handler->is_active_update;
1064 EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data)
1066 struct packet *packet;
1072 ErrPrint("Handler is NIL\n");
1073 return LB_STATUS_ERROR_INVALID;
1076 if (handler->state != CREATE || !handler->id) {
1077 ErrPrint("Handler is not valid\n");
1078 return LB_STATUS_ERROR_INVALID;
1081 if (handler->size_changed_cb) {
1082 ErrPrint("Previous resize request is not finished yet\n");
1083 return LB_STATUS_ERROR_BUSY;
1086 if (!handler->is_user) {
1087 ErrPrint("CA Livebox is not able to be resized\n");
1088 return LB_STATUS_ERROR_PERMISSION;
1091 if (livebox_service_get_size(type, &w, &h) != 0) {
1092 ErrPrint("Invalid size type\n");
1093 return LB_STATUS_ERROR_INVALID;
1096 if (handler->lb.width == w && handler->lb.height == h) {
1097 DbgPrint("No changes\n");
1098 return LB_STATUS_ERROR_ALREADY;
1101 packet = packet_create("resize", "ssii", handler->pkgname, handler->id, w, h);
1103 ErrPrint("Failed to build param\n");
1104 return LB_STATUS_ERROR_FAULT;
1108 cb = default_lb_size_changed_cb;
1111 ret = master_rpc_async_request(handler, packet, 0, resize_cb, NULL);
1112 if (ret == LB_STATUS_SUCCESS) {
1113 handler->size_changed_cb = cb;
1114 handler->size_cbdata = data;
1120 EAPI int livebox_click(struct livebox *handler, double x, double y)
1122 struct packet *packet;
1126 timestamp = util_timestamp();
1129 ErrPrint("Handler is NIL\n");
1130 return LB_STATUS_ERROR_INVALID;
1133 if (handler->state != CREATE || !handler->id) {
1134 ErrPrint("Handler is not valid\n");
1135 return LB_STATUS_ERROR_INVALID;
1138 if (handler->lb.auto_launch) {
1139 DbgPrint("AUTO_LAUNCH [%s]\n", handler->lb.auto_launch);
1140 if (aul_launch_app(handler->lb.auto_launch, NULL) < 0) {
1141 ErrPrint("Failed to launch app %s\n", handler->lb.auto_launch);
1145 packet = packet_create_noack("clicked", "sssddd", handler->pkgname, handler->id, "clicked", timestamp, x, y);
1147 ErrPrint("Failed to build param\n");
1148 return LB_STATUS_ERROR_FAULT;
1151 DbgPrint("CLICKED: %lf\n", timestamp);
1152 ret = master_rpc_request_only(handler, packet);
1154 if (!handler->lb.mouse_event && (handler->lb.type == _LB_TYPE_BUFFER || handler->lb.type == _LB_TYPE_SCRIPT)) {
1155 int ret; /* Shadow variable */
1156 ret = send_mouse_event(handler, "lb_mouse_down", x * handler->lb.width, y * handler->lb.height);
1158 ErrPrint("Failed to send Down: %d\n", ret);
1161 ret = send_mouse_event(handler, "lb_mouse_move", x * handler->lb.width, y * handler->lb.height);
1163 ErrPrint("Failed to send Move: %d\n", ret);
1166 ret = send_mouse_event(handler, "lb_mouse_up", x * handler->lb.width, y * handler->lb.height);
1168 ErrPrint("Failed to send Up: %d\n", ret);
1175 EAPI int livebox_has_pd(struct livebox *handler)
1178 ErrPrint("Handler is NIL\n");
1179 return LB_STATUS_ERROR_INVALID;
1182 if (handler->state != CREATE || !handler->id) {
1183 ErrPrint("Handler is not valid\n");
1184 return LB_STATUS_ERROR_INVALID;
1187 return !!handler->pd.data.fb;
1190 EAPI int livebox_pd_is_created(struct livebox *handler)
1193 ErrPrint("Handler is NIL\n");
1194 return LB_STATUS_ERROR_INVALID;
1197 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1198 ErrPrint("Handler is not valid\n");
1199 return LB_STATUS_ERROR_INVALID;
1202 return handler->is_pd_created;
1205 EAPI int livebox_create_pd(struct livebox *handler, ret_cb_t cb, void *data)
1207 return livebox_create_pd_with_position(handler, -1.0, -1.0, cb, data);
1210 EAPI int livebox_create_pd_with_position(struct livebox *handler, double x, double y, ret_cb_t cb, void *data)
1212 struct packet *packet;
1216 ErrPrint("Handler is NIL\n");
1217 return LB_STATUS_ERROR_INVALID;
1220 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1221 ErrPrint("Handler is not valid\n");
1222 return LB_STATUS_ERROR_INVALID;
1225 if (handler->is_pd_created == 1) {
1226 DbgPrint("PD already created\n");
1227 return LB_STATUS_SUCCESS;
1230 if (handler->pd_created_cb) {
1231 ErrPrint("Previous request is not completed yet\n");
1232 return LB_STATUS_ERROR_BUSY;
1235 packet = packet_create("create_pd", "ssdd", handler->pkgname, handler->id, x, y);
1237 ErrPrint("Failed to build param\n");
1238 return LB_STATUS_ERROR_FAULT;
1242 cb = default_pd_created_cb;
1245 DbgPrint("PERF_DBOX\n");
1246 ret = master_rpc_async_request(handler, packet, 0, pd_create_cb, NULL);
1247 if (ret == LB_STATUS_SUCCESS) {
1248 handler->pd_created_cb = cb;
1249 handler->pd_created_cbdata = data;
1255 EAPI int livebox_move_pd(struct livebox *handler, double x, double y)
1257 struct packet *packet;
1260 ErrPrint("Handler is NIL\n");
1261 return LB_STATUS_ERROR_INVALID;
1264 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1265 ErrPrint("Handler is not valid\n");
1266 return LB_STATUS_ERROR_INVALID;
1269 if (!handler->is_pd_created) {
1270 ErrPrint("PD is not created\n");
1271 return LB_STATUS_ERROR_INVALID;
1274 packet = packet_create_noack("pd_move", "ssdd", handler->pkgname, handler->id, x, y);
1276 ErrPrint("Failed to build param\n");
1277 return LB_STATUS_ERROR_FAULT;
1280 return master_rpc_request_only(handler, packet);
1283 EAPI int livebox_activate(const char *pkgname, ret_cb_t cb, void *data)
1285 struct packet *packet;
1286 struct cb_info *cbinfo;
1290 return LB_STATUS_ERROR_INVALID;
1293 packet = packet_create("activate_package", "s", pkgname);
1295 ErrPrint("Failed to build a param\n");
1296 return LB_STATUS_ERROR_FAULT;
1299 cbinfo = create_cb_info(cb, data);
1301 ErrPrint("Unable to create cbinfo\n");
1302 packet_destroy(packet);
1303 return LB_STATUS_ERROR_FAULT;
1306 ret = master_rpc_async_request(NULL, packet, 0, activated_cb, cbinfo);
1308 destroy_cb_info(cbinfo);
1314 EAPI int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data)
1316 struct packet *packet;
1317 struct cb_info *cbinfo;
1321 ErrPrint("Handler is NIL\n");
1322 return LB_STATUS_ERROR_INVALID;
1325 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1326 ErrPrint("Handler is not valid\n");
1327 return LB_STATUS_ERROR_INVALID;
1330 if (!handler->is_pd_created && !handler->pd_created_cb) {
1331 ErrPrint("PD is not created\n");
1332 return LB_STATUS_ERROR_INVALID;
1335 packet = packet_create("destroy_pd", "ss", handler->pkgname, handler->id);
1337 ErrPrint("Failed to build a param\n");
1338 return LB_STATUS_ERROR_FAULT;
1342 cb = default_pd_destroyed_cb;
1345 cbinfo = create_cb_info(cb, data);
1347 packet_destroy(packet);
1348 return LB_STATUS_ERROR_FAULT;
1351 ret = master_rpc_async_request(handler, packet, 0, pd_destroy_cb, cbinfo);
1353 destroy_cb_info(cbinfo);
1359 EAPI int livebox_access_event(struct livebox *handler, enum access_event_type type, double x, double y, ret_cb_t cb, void *data)
1363 char cmd[32] = { '\0', };
1368 ErrPrint("Handler is NIL\n");
1369 return LB_STATUS_ERROR_INVALID;
1372 if (handler->state != CREATE || !handler->id) {
1373 ErrPrint("Handler is not valid\n");
1374 return LB_STATUS_ERROR_INVALID;
1377 if (handler->access_event_cb) {
1378 ErrPrint("Previous access event is not yet done\n");
1379 return LB_STATUS_ERROR_BUSY;
1382 if (type & ACCESS_EVENT_PD_MASK) {
1383 if (!handler->is_pd_created) {
1384 ErrPrint("PD is not created\n");
1385 return LB_STATUS_ERROR_INVALID;
1389 w = handler->pd.width;
1390 h = handler->pd.height;
1391 } else if (type & ACCESS_EVENT_LB_MASK) {
1394 w = handler->lb.width;
1395 h = handler->lb.height;
1397 ErrPrint("Invalid event type\n");
1398 return LB_STATUS_ERROR_INVALID;
1401 switch (type & ~ACCESS_EVENT_PD_MASK) {
1402 case ACCESS_EVENT_HIGHLIGHT:
1403 strcpy(ptr, "_access_hl");
1405 case ACCESS_EVENT_HIGHLIGHT_NEXT:
1406 strcpy(ptr, "_access_hl_next");
1408 case ACCESS_EVENT_HIGHLIGHT_PREV:
1409 strcpy(ptr, "_access_hl_prev");
1411 case ACCESS_EVENT_ACTIVATE:
1412 strcpy(ptr, "_access_activate");
1414 case ACCESS_EVENT_ACTION_DOWN:
1415 strcpy(ptr, "_access_action_down");
1417 case ACCESS_EVENT_ACTION_UP:
1418 strcpy(ptr, "_access_action_up");
1420 case ACCESS_EVENT_UNHIGHLIGHT:
1421 strcpy(ptr, "_access_unhighlight");
1423 case ACCESS_EVENT_SCROLL_DOWN:
1424 strcpy(ptr, "_access_scroll_down");
1426 case ACCESS_EVENT_SCROLL_MOVE:
1427 strcpy(ptr, "_access_scroll_move");
1429 case ACCESS_EVENT_SCROLL_UP:
1430 strcpy(ptr, "_access_scroll_up");
1433 return LB_STATUS_ERROR_INVALID;
1437 cb = default_access_event_cb;
1440 ret = send_access_event(handler, cmd, x * w, y * h);
1441 if (ret == LB_STATUS_SUCCESS) {
1442 handler->access_event_cb = cb;
1443 handler->access_event_cbdata = data;
1449 EAPI int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y)
1453 char cmd[32] = { '\0', };
1457 ErrPrint("Handler is NIL\n");
1458 return LB_STATUS_ERROR_INVALID;
1461 if (handler->state != CREATE || !handler->id) {
1462 ErrPrint("Handler is not valid\n");
1463 return LB_STATUS_ERROR_INVALID;
1466 if (type & CONTENT_EVENT_PD_MASK) {
1469 if (!handler->is_pd_created) {
1470 ErrPrint("PD is not created\n");
1471 return LB_STATUS_ERROR_INVALID;
1474 if (type & CONTENT_EVENT_MOUSE_MASK) {
1475 if (!handler->pd.data.fb) {
1476 ErrPrint("Handler is not valid\n");
1477 return LB_STATUS_ERROR_INVALID;
1480 if (type & CONTENT_EVENT_MOUSE_MOVE) {
1481 if (fabs(x - handler->pd.x) < MINIMUM_EVENT && fabs(y - handler->pd.y) < MINIMUM_EVENT) {
1482 return LB_STATUS_ERROR_BUSY;
1484 } else if (type & CONTENT_EVENT_MOUSE_SET) {
1490 w = handler->pd.width;
1491 h = handler->pd.height;
1497 } else if (type & CONTENT_EVENT_LB_MASK) {
1500 if (type & CONTENT_EVENT_MOUSE_MASK) {
1501 if (!handler->lb.mouse_event) {
1502 return LB_STATUS_ERROR_INVALID;
1505 if (!handler->lb.data.fb) {
1506 ErrPrint("Handler is not valid\n");
1507 return LB_STATUS_ERROR_INVALID;
1510 if (type & CONTENT_EVENT_MOUSE_MOVE) {
1511 if (fabs(x - handler->lb.x) < MINIMUM_EVENT && fabs(y - handler->lb.y) < MINIMUM_EVENT) {
1512 return LB_STATUS_ERROR_BUSY;
1514 } else if (type & CONTENT_EVENT_MOUSE_SET) {
1520 w = handler->lb.width;
1521 h = handler->lb.height;
1528 ErrPrint("Invalid event type\n");
1529 return LB_STATUS_ERROR_INVALID;
1533 * Must be short than 29 bytes.
1535 switch ((type & ~(CONTENT_EVENT_PD_MASK | CONTENT_EVENT_LB_MASK))) {
1536 case CONTENT_EVENT_MOUSE_ENTER | CONTENT_EVENT_MOUSE_MASK:
1537 strcpy(ptr, "_mouse_enter");
1539 case CONTENT_EVENT_MOUSE_LEAVE | CONTENT_EVENT_MOUSE_MASK:
1540 strcpy(ptr, "_mouse_leave");
1542 case CONTENT_EVENT_MOUSE_UP | CONTENT_EVENT_MOUSE_MASK:
1543 strcpy(ptr, "_mouse_up");
1545 case CONTENT_EVENT_MOUSE_DOWN | CONTENT_EVENT_MOUSE_MASK:
1546 strcpy(ptr, "_mouse_down");
1548 case CONTENT_EVENT_MOUSE_MOVE | CONTENT_EVENT_MOUSE_MASK:
1549 strcpy(ptr, "_mouse_move");
1551 case CONTENT_EVENT_MOUSE_SET | CONTENT_EVENT_MOUSE_MASK:
1552 strcpy(ptr, "_mouse_set");
1554 case CONTENT_EVENT_MOUSE_UNSET | CONTENT_EVENT_MOUSE_MASK:
1555 strcpy(ptr, "_mouse_unset");
1557 case CONTENT_EVENT_KEY_DOWN | CONTENT_EVENT_KEY_MASK:
1558 strcpy(ptr, "_key_down");
1560 case CONTENT_EVENT_KEY_UP | CONTENT_EVENT_KEY_MASK:
1561 strcpy(ptr, "_key_up");
1564 ErrPrint("Invalid event type\n");
1565 return LB_STATUS_ERROR_INVALID;
1568 return send_mouse_event(handler, cmd, x * w, y * h);
1571 EAPI const char *livebox_filename(struct livebox *handler)
1574 ErrPrint("Handler is NIL\n");
1578 if (handler->state != CREATE || !handler->id) {
1579 ErrPrint("Handler is not valid\n");
1583 if (handler->filename) {
1584 return handler->filename;
1588 return util_uri_to_path(handler->id);
1591 EAPI int livebox_get_pdsize(struct livebox *handler, int *w, int *h)
1597 ErrPrint("Handler is NIL\n");
1598 return LB_STATUS_ERROR_INVALID;
1601 if (handler->state != CREATE || !handler->id) {
1602 ErrPrint("Handler is not valid\n");
1603 return LB_STATUS_ERROR_INVALID;
1613 if (!handler->is_pd_created) {
1614 *w = handler->pd.default_width;
1615 *h = handler->pd.default_height;
1617 *w = handler->pd.width;
1618 *h = handler->pd.height;
1621 return LB_STATUS_SUCCESS;
1624 EAPI int livebox_size(struct livebox *handler)
1630 ErrPrint("Handler is NIL\n");
1631 return LB_STATUS_ERROR_INVALID;
1634 if (handler->state != CREATE || !handler->id) {
1635 ErrPrint("Handler is not valid\n");
1636 return LB_STATUS_ERROR_INVALID;
1639 w = handler->lb.width;
1640 h = handler->lb.height;
1642 switch (handler->lb.type) {
1643 case _LB_TYPE_BUFFER:
1644 case _LB_TYPE_SCRIPT:
1645 if (!fb_is_created(handler->lb.data.fb)) {
1654 return livebox_service_size_type(w, h);
1657 EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const char *category, ret_cb_t cb, void *data)
1659 struct packet *packet;
1663 ErrPrint("Handler is NIL\n");
1664 return LB_STATUS_ERROR_INVALID;
1667 if (!cluster || !category || handler->state != CREATE || !handler->id) {
1668 ErrPrint("Invalid argument\n");
1669 return LB_STATUS_ERROR_INVALID;
1672 if (handler->group_changed_cb) {
1673 ErrPrint("Previous group changing request is not finished yet\n");
1674 return LB_STATUS_ERROR_BUSY;
1677 if (!handler->is_user) {
1678 ErrPrint("CA Livebox is not able to change the group\n");
1679 return LB_STATUS_ERROR_PERMISSION;
1682 if (!strcmp(handler->cluster, cluster) && !strcmp(handler->category, category)) {
1683 DbgPrint("No changes\n");
1684 return LB_STATUS_ERROR_ALREADY;
1687 packet = packet_create("change_group", "ssss", handler->pkgname, handler->id, cluster, category);
1689 ErrPrint("Failed to build a param\n");
1690 return LB_STATUS_ERROR_FAULT;
1694 cb = default_group_changed_cb;
1697 ret = master_rpc_async_request(handler, packet, 0, set_group_ret_cb, NULL);
1698 if (ret == LB_STATUS_SUCCESS) {
1699 handler->group_changed_cb = cb;
1700 handler->group_cbdata = data;
1706 EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category)
1709 ErrPrint("Handler is NIL\n");
1710 return LB_STATUS_ERROR_INVALID;
1713 if (!cluster || !category || handler->state != CREATE || !handler->id) {
1714 ErrPrint("Invalid argument\n");
1715 return LB_STATUS_ERROR_INVALID;
1718 *cluster = handler->cluster;
1719 *category = handler->category;
1720 return LB_STATUS_SUCCESS;
1723 EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list)
1728 if (!handler || !size_list) {
1729 ErrPrint("Invalid argument, handler(%p), size_list(%p)\n", handler, size_list);
1730 return LB_STATUS_ERROR_INVALID;
1733 if (!cnt || handler->state != CREATE || !handler->id) {
1734 ErrPrint("Handler is not valid\n");
1735 return LB_STATUS_ERROR_INVALID;
1738 for (j = i = 0; i < NR_OF_SIZE_LIST; i++) {
1739 if (handler->lb.size_list & (0x01 << i)) {
1744 size_list[j++] = (0x01 << i);
1749 return LB_STATUS_SUCCESS;
1752 EAPI const char *livebox_pkgname(struct livebox *handler)
1755 ErrPrint("Handler is NIL\n");
1759 if (handler->state != CREATE) {
1760 ErrPrint("Handler is not valid\n");
1764 return handler->pkgname;
1767 EAPI double livebox_priority(struct livebox *handler)
1770 ErrPrint("Handler is NIL\n");
1774 if (handler->state != CREATE || !handler->id) {
1775 ErrPrint("Handler is not valid (%p)\n", handler);
1779 return handler->lb.priority;
1782 EAPI int livebox_delete_cluster(const char *cluster, ret_cb_t cb, void *data)
1784 struct packet *packet;
1785 struct cb_info *cbinfo;
1788 packet = packet_create("delete_cluster", "s", cluster);
1790 ErrPrint("Failed to build a param\n");
1791 return LB_STATUS_ERROR_FAULT;
1794 cbinfo = create_cb_info(cb, data);
1796 packet_destroy(packet);
1797 return LB_STATUS_ERROR_FAULT;
1800 ret = master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, cbinfo);
1802 destroy_cb_info(cbinfo);
1808 EAPI int livebox_delete_category(const char *cluster, const char *category, ret_cb_t cb, void *data)
1810 struct packet *packet;
1811 struct cb_info *cbinfo;
1814 packet = packet_create("delete_category", "ss", cluster, category);
1816 ErrPrint("Failed to build a param\n");
1817 return LB_STATUS_ERROR_FAULT;
1820 cbinfo = create_cb_info(cb, data);
1822 packet_destroy(packet);
1823 return LB_STATUS_ERROR_FAULT;
1826 ret = master_rpc_async_request(NULL, packet, 0, delete_category_cb, cbinfo);
1828 destroy_cb_info(cbinfo);
1834 EAPI enum livebox_lb_type livebox_lb_type(struct livebox *handler)
1837 ErrPrint("Handler is NIL\n");
1838 return LB_TYPE_INVALID;
1841 if (handler->state != CREATE || !handler->id) {
1842 ErrPrint("Handler is not valid\n");
1843 return LB_TYPE_INVALID;
1846 switch (handler->lb.type) {
1848 return LB_TYPE_IMAGE;
1849 case _LB_TYPE_BUFFER:
1850 case _LB_TYPE_SCRIPT:
1853 id = fb_id(handler->lb.data.fb);
1854 if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
1855 return LB_TYPE_PIXMAP;
1858 return LB_TYPE_BUFFER;
1860 return LB_TYPE_TEXT;
1865 return LB_TYPE_INVALID;
1868 EAPI enum livebox_pd_type livebox_pd_type(struct livebox *handler)
1871 ErrPrint("Handler is NIL\n");
1872 return PD_TYPE_INVALID;
1875 if (handler->state != CREATE || !handler->id) {
1876 ErrPrint("Handler is not valid\n");
1877 return PD_TYPE_INVALID;
1880 switch (handler->pd.type) {
1882 return PD_TYPE_TEXT;
1883 case _PD_TYPE_BUFFER:
1884 case _PD_TYPE_SCRIPT:
1887 id = fb_id(handler->pd.data.fb);
1888 if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
1889 return PD_TYPE_PIXMAP;
1892 return PD_TYPE_BUFFER;
1897 return PD_TYPE_INVALID;
1900 EAPI int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_script_operators *ops)
1903 ErrPrint("Handler is NIL\n");
1904 return LB_STATUS_ERROR_INVALID;
1907 if (handler->state != CREATE) {
1908 ErrPrint("Handler is not valid\n");
1909 return LB_STATUS_ERROR_INVALID;
1912 memcpy(&handler->pd.data.ops, ops, sizeof(*ops));
1913 return LB_STATUS_SUCCESS;
1916 EAPI int livebox_set_text_handler(struct livebox *handler, struct livebox_script_operators *ops)
1919 ErrPrint("Handler is NIL\n");
1920 return LB_STATUS_ERROR_INVALID;
1923 if (handler->state != CREATE) {
1924 ErrPrint("Handler is not valid\n");
1925 return LB_STATUS_ERROR_INVALID;
1928 memcpy(&handler->lb.data.ops, ops, sizeof(*ops));
1929 return LB_STATUS_SUCCESS;
1932 EAPI int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
1934 struct packet *packet;
1935 struct cb_info *cbinfo;
1940 ErrPrint("Handler is NIL\n");
1941 return LB_STATUS_ERROR_INVALID;
1944 if (handler->state != CREATE || !handler->id) {
1945 ErrPrint("Invalid handle\n");
1946 return LB_STATUS_ERROR_INVALID;
1949 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
1950 ErrPrint("Handler is not valid type\n");
1951 return LB_STATUS_ERROR_INVALID;
1954 id = fb_id(handler->lb.data.fb);
1955 if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
1956 return LB_STATUS_ERROR_INVALID;
1959 packet = packet_create("lb_acquire_pixmap", "ss", handler->pkgname, handler->id);
1961 ErrPrint("Failed to build a param\n");
1962 return LB_STATUS_ERROR_FAULT;
1965 cbinfo = create_cb_info(cb, data);
1967 packet_destroy(packet);
1968 return LB_STATUS_ERROR_FAULT;
1971 ret = master_rpc_async_request(handler, packet, 0, lb_pixmap_acquired_cb, cbinfo);
1973 destroy_cb_info(cbinfo);
1979 EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
1981 struct packet *packet;
1983 if (!handler || pixmap == 0) {
1984 ErrPrint("Handler is NIL [%d]\n", pixmap);
1985 return LB_STATUS_ERROR_INVALID;
1988 if (handler->state != CREATE || !handler->id) {
1989 ErrPrint("Invalid handle\n");
1990 return LB_STATUS_ERROR_INVALID;
1993 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
1994 ErrPrint("Handler is not valid type\n");
1995 return LB_STATUS_ERROR_INVALID;
1998 packet = packet_create_noack("lb_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap);
2000 ErrPrint("Failed to build a param\n");
2001 return LB_STATUS_ERROR_INVALID;
2004 return master_rpc_request_only(handler, packet);
2007 EAPI int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
2009 struct packet *packet;
2010 struct cb_info *cbinfo;
2015 ErrPrint("Handler is NIL\n");
2016 return LB_STATUS_ERROR_INVALID;
2019 if (handler->state != CREATE || !handler->id) {
2020 ErrPrint("Invalid handle\n");
2021 return LB_STATUS_ERROR_INVALID;
2024 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
2025 ErrPrint("Handler is not valid type\n");
2026 return LB_STATUS_ERROR_INVALID;
2029 id = fb_id(handler->pd.data.fb);
2030 if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
2031 return LB_STATUS_ERROR_INVALID;
2034 packet = packet_create("pd_acquire_pixmap", "ss", handler->pkgname, handler->id);
2036 ErrPrint("Failed to build a param\n");
2037 return LB_STATUS_ERROR_FAULT;
2040 cbinfo = create_cb_info(cb, data);
2042 packet_destroy(packet);
2043 return LB_STATUS_ERROR_FAULT;
2046 ret = master_rpc_async_request(handler, packet, 0, pd_pixmap_acquired_cb, cbinfo);
2048 destroy_cb_info(cbinfo);
2054 EAPI int livebox_pd_pixmap(const struct livebox *handler)
2060 ErrPrint("Handler is NIL\n");
2064 if (handler->state != CREATE || !handler->id) {
2065 ErrPrint("Invalid handler\n");
2069 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
2070 ErrPrint("Invalid handler\n");
2074 id = fb_id(handler->pd.data.fb);
2075 if (id && sscanf(id, SCHEMA_PIXMAP "%d", &pixmap) != 1) {
2076 ErrPrint("PIXMAP Id is not valid\n");
2083 EAPI int livebox_lb_pixmap(const struct livebox *handler)
2089 ErrPrint("Handler is NIL\n");
2093 if (handler->state != CREATE || !handler->id) {
2094 ErrPrint("Invalid handler\n");
2098 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
2099 ErrPrint("Invalid handler\n");
2103 id = fb_id(handler->lb.data.fb);
2104 if (id && sscanf(id, SCHEMA_PIXMAP "%d", &pixmap) != 1) {
2105 ErrPrint("PIXMAP Id is not valid\n");
2112 EAPI int livebox_release_pd_pixmap(struct livebox *handler, int pixmap)
2114 struct packet *packet;
2116 if (!handler || pixmap == 0) {
2117 ErrPrint("Handler is NIL [%d]\n", pixmap);
2118 return LB_STATUS_ERROR_INVALID;
2121 if (handler->state != CREATE || !handler->id) {
2122 ErrPrint("Invalid handle\n");
2123 return LB_STATUS_ERROR_INVALID;
2126 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
2127 ErrPrint("Handler is not valid type\n");
2128 return LB_STATUS_ERROR_INVALID;
2131 packet = packet_create_noack("pd_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap);
2133 ErrPrint("Failed to build a param\n");
2134 return LB_STATUS_ERROR_FAULT;
2137 return master_rpc_request_only(handler, packet);
2140 EAPI void *livebox_acquire_fb(struct livebox *handler)
2143 ErrPrint("Handler is NIL\n");
2147 if (handler->state != CREATE || !handler->id) {
2148 ErrPrint("Invalid handle\n");
2152 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
2153 ErrPrint("Handler is not valid type\n");
2157 return fb_acquire_buffer(handler->lb.data.fb);
2160 EAPI int livebox_release_fb(void *buffer)
2162 return fb_release_buffer(buffer);
2165 EAPI int livebox_fb_refcnt(void *buffer)
2167 return fb_refcnt(buffer);
2170 EAPI void *livebox_acquire_pdfb(struct livebox *handler)
2173 ErrPrint("Handler is NIL\n");
2177 if (handler->state != CREATE || !handler->id) {
2178 ErrPrint("Invalid handler\n");
2182 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
2183 ErrPrint("Handler is not valid type\n");
2187 return fb_acquire_buffer(handler->pd.data.fb);
2190 EAPI int livebox_release_pdfb(void *buffer)
2192 return fb_release_buffer(buffer);
2195 EAPI int livebox_pdfb_refcnt(void *buffer)
2197 return fb_refcnt(buffer);
2200 EAPI int livebox_pdfb_bufsz(struct livebox *handler)
2203 ErrPrint("Handler is NIL\n");
2204 return LB_STATUS_ERROR_INVALID;
2207 if (handler->state != CREATE || !handler->id) {
2208 ErrPrint("Handler is not valid\n");
2209 return LB_STATUS_ERROR_INVALID;
2212 return fb_size(handler->pd.data.fb);
2215 EAPI int livebox_lbfb_bufsz(struct livebox *handler)
2218 ErrPrint("Handler is NIL\n");
2219 return LB_STATUS_ERROR_INVALID;
2222 if (handler->state != CREATE || !handler->id) {
2223 ErrPrint("Handler is not valid\n");
2224 return LB_STATUS_ERROR_INVALID;
2227 return fb_size(handler->lb.data.fb);
2230 EAPI int livebox_is_user(struct livebox *handler)
2233 ErrPrint("Handler is NIL\n");
2234 return LB_STATUS_ERROR_INVALID;
2237 if (handler->state != CREATE) {
2238 ErrPrint("Handler is invalid\n");
2239 return LB_STATUS_ERROR_INVALID;
2242 return handler->is_user;
2245 EAPI int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void *data)
2247 struct packet *packet;
2251 ErrPrint("Handler is NIL\n");
2252 return LB_STATUS_ERROR_INVALID;
2255 if (handler->state != CREATE || !handler->id) {
2256 ErrPrint("Handler is not valid\n");
2257 return LB_STATUS_ERROR_INVALID;
2260 if (handler->pinup_cb) {
2261 ErrPrint("Previous pinup request is not finished\n");
2262 return LB_STATUS_ERROR_BUSY;
2265 if (handler->is_pinned_up == flag) {
2266 DbgPrint("No changes\n");
2267 return LB_STATUS_ERROR_ALREADY;
2270 packet = packet_create("pinup_changed", "ssi", handler->pkgname, handler->id, flag);
2272 ErrPrint("Failed to build a param\n");
2273 return LB_STATUS_ERROR_FAULT;
2277 cb = default_pinup_cb;
2280 ret = master_rpc_async_request(handler, packet, 0, pinup_done_cb, NULL);
2281 if (ret == LB_STATUS_SUCCESS) {
2282 handler->pinup_cb = cb;
2283 handler->pinup_cbdata = data;
2289 EAPI int livebox_is_pinned_up(struct livebox *handler)
2292 ErrPrint("Handler is NIL\n");
2293 return LB_STATUS_ERROR_INVALID;
2296 if (handler->state != CREATE || !handler->id) {
2297 return LB_STATUS_ERROR_INVALID;
2300 return handler->is_pinned_up;
2303 EAPI int livebox_has_pinup(struct livebox *handler)
2306 ErrPrint("Handler is NIL\n");
2307 return LB_STATUS_ERROR_INVALID;
2310 if (handler->state != CREATE || !handler->id) {
2311 return LB_STATUS_ERROR_INVALID;
2314 return handler->lb.pinup_supported;
2317 EAPI int livebox_set_data(struct livebox *handler, void *data)
2320 ErrPrint("Handler is NIL\n");
2321 return LB_STATUS_ERROR_INVALID;
2324 if (handler->state != CREATE) {
2325 return LB_STATUS_ERROR_INVALID;
2328 handler->data = data;
2329 return LB_STATUS_SUCCESS;
2332 EAPI void *livebox_get_data(struct livebox *handler)
2335 ErrPrint("Handler is NIL\n");
2339 if (handler->state != CREATE) {
2343 return handler->data;
2346 EAPI int livebox_is_exists(const char *pkgname)
2350 lb = lb_pkgname(pkgname);
2359 EAPI const char *livebox_content(struct livebox *handler)
2362 ErrPrint("Handler is NIL\n");
2366 if (handler->state != CREATE) {
2370 return handler->content;
2373 EAPI const char *livebox_category_title(struct livebox *handler)
2376 ErrPrint("Handler is NIL\n");
2380 if (handler->state != CREATE) {
2384 return handler->title;
2387 EAPI int livebox_emit_text_signal(struct livebox *handler, const char *emission, const char *source, double sx, double sy, double ex, double ey, ret_cb_t cb, void *data)
2389 struct packet *packet;
2390 struct cb_info *cbinfo;
2394 ErrPrint("Handler is NIL\n");
2395 return LB_STATUS_ERROR_INVALID;
2398 if ((handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || handler->state != CREATE || !handler->id) {
2399 ErrPrint("Handler is not valid\n");
2400 return LB_STATUS_ERROR_INVALID;
2411 packet = packet_create("text_signal", "ssssdddd",
2412 handler->pkgname, handler->id, emission, source, sx, sy, ex, ey);
2414 ErrPrint("Failed to build a param\n");
2415 return LB_STATUS_ERROR_FAULT;
2418 cbinfo = create_cb_info(cb, data);
2420 packet_destroy(packet);
2421 return LB_STATUS_ERROR_FAULT;
2424 ret = master_rpc_async_request(handler, packet, 0, text_signal_cb, cbinfo);
2426 destroy_cb_info(cbinfo);
2432 EAPI int livebox_subscribe_group(const char *cluster, const char *category)
2434 struct packet *packet;
2438 * Validate the group info using DB
2439 * If the group info is not valid, do not send this request
2442 packet = packet_create_noack("subscribe", "ss", cluster ? cluster : "", category ? category : "");
2444 ErrPrint("Failed to create a packet\n");
2445 return LB_STATUS_ERROR_FAULT;
2448 return master_rpc_request_only(NULL, packet);
2451 EAPI int livebox_unsubscribe_group(const char *cluster, const char *category)
2453 struct packet *packet;
2457 * Validate the group info using DB
2458 * If the group info is not valid, do not send this request
2459 * AND Check the subscribed or not too
2462 packet = packet_create_noack("unsubscribe", "ss", cluster ? cluster : "", category ? category : "");
2464 ErrPrint("Failed to create a packet\n");
2465 return LB_STATUS_ERROR_FAULT;
2468 return master_rpc_request_only(NULL, packet);
2471 EAPI int livebox_refresh(struct livebox *handler)
2473 struct packet *packet;
2476 ErrPrint("Hnalder is NIL\n");
2477 return LB_STATUS_ERROR_INVALID;
2480 if (handler->state != CREATE || !handler->id) {
2481 return LB_STATUS_ERROR_INVALID;
2484 packet = packet_create_noack("update", "ss", handler->pkgname, handler->id);
2486 ErrPrint("Failed to create a packet\n");
2487 return LB_STATUS_ERROR_FAULT;
2490 return master_rpc_request_only(handler, packet);
2493 EAPI int livebox_refresh_group(const char *cluster, const char *category)
2495 struct packet *packet;
2497 if (!cluster || !category) {
2498 ErrPrint("Invalid argument\n");
2499 return LB_STATUS_ERROR_INVALID;
2502 packet = packet_create_noack("refresh_group", "ss", cluster, category);
2504 ErrPrint("Failed to create a packet\n");
2505 return LB_STATUS_ERROR_FAULT;
2508 return master_rpc_request_only(NULL, packet);
2511 EAPI int livebox_set_visibility(struct livebox *handler, enum livebox_visible_state state)
2513 struct packet *packet;
2517 ErrPrint("Handler is NIL\n");
2518 return LB_STATUS_ERROR_INVALID;
2521 if (handler->state != CREATE || !handler->id) {
2522 return LB_STATUS_ERROR_INVALID;
2525 if (!handler->is_user) {
2526 /* System cluster livebox cannot be changed its visible states */
2527 if (state == LB_HIDE_WITH_PAUSE) {
2528 ErrPrint("CA Livebox is not able to change the visibility\n");
2529 return LB_STATUS_ERROR_PERMISSION;
2533 if (handler->visible == state) {
2534 return LB_STATUS_ERROR_ALREADY;
2537 packet = packet_create_noack("change,visibility", "ssi", handler->pkgname, handler->id, (int)state);
2539 ErrPrint("Failed to create a packet\n");
2540 return LB_STATUS_ERROR_FAULT;
2543 ret = master_rpc_request_only(handler, packet);
2545 handler->visible = state;
2551 EAPI enum livebox_visible_state livebox_visibility(struct livebox *handler)
2554 ErrPrint("Handler is NIL\n");
2555 return LB_VISIBLE_ERROR;
2558 if (handler->state != CREATE || !handler->id) {
2559 return LB_VISIBLE_ERROR;
2562 return handler->visible;
2565 int lb_set_group(struct livebox *handler, const char *cluster, const char *category)
2571 pc = strdup(cluster);
2573 CRITICAL_LOG("Heap: %s (cluster: %s)\n", strerror(errno), cluster);
2574 return LB_STATUS_ERROR_MEMORY;
2579 ps = strdup(category);
2581 CRITICAL_LOG("Heap: %s (category: %s)\n", strerror(errno), category);
2583 return LB_STATUS_ERROR_MEMORY;
2587 if (handler->cluster) {
2588 free(handler->cluster);
2591 if (handler->category) {
2592 free(handler->category);
2595 handler->cluster = pc;
2596 handler->category = ps;
2598 return LB_STATUS_SUCCESS;
2601 void lb_set_size(struct livebox *handler, int w, int h)
2603 handler->lb.width = w;
2604 handler->lb.height = h;
2607 void lb_set_update_mode(struct livebox *handle, int active_mode)
2609 handle->is_active_update = active_mode;
2612 void lb_set_pdsize(struct livebox *handler, int w, int h)
2614 handler->pd.width = w;
2615 handler->pd.height = h;
2618 void lb_set_default_pdsize(struct livebox *handler, int w, int h)
2620 handler->pd.default_width = w;
2621 handler->pd.default_height = h;
2624 void lb_invoke_fault_handler(enum livebox_fault_type event, const char *pkgname, const char *file, const char *func)
2628 struct fault_info *info;
2630 dlist_foreach_safe(s_info.fault_list, l, n, info) {
2631 if (info->handler(event, pkgname, file, func, info->user_data) == EXIT_FAILURE) {
2632 s_info.fault_list = dlist_remove(s_info.fault_list, l);
2637 void lb_invoke_event_handler(struct livebox *handler, enum livebox_event_type event)
2641 struct event_info *info;
2643 dlist_foreach_safe(s_info.event_list, l, n, info) {
2644 if (info->handler(handler, event, info->user_data) == EXIT_FAILURE) {
2645 s_info.event_list = dlist_remove(s_info.event_list, l);
2650 struct livebox *lb_find_livebox(const char *pkgname, const char *id)
2653 struct livebox *handler;
2655 dlist_foreach(s_info.livebox_list, l, handler) {
2660 if (!strcmp(handler->pkgname, pkgname) && !strcmp(handler->id, id)) {
2668 struct livebox *lb_find_livebox_by_timestamp(double timestamp)
2671 struct livebox *handler;
2673 dlist_foreach(s_info.livebox_list, l, handler) {
2674 if (handler->timestamp == timestamp) {
2682 struct livebox *lb_new_livebox(const char *pkgname, const char *id, double timestamp)
2684 struct livebox *handler;
2686 handler = calloc(1, sizeof(*handler));
2688 ErrPrint("Failed to create a new livebox\n");
2692 handler->pkgname = strdup(pkgname);
2693 if (!handler->pkgname) {
2694 ErrPrint("%s\n", strerror(errno));
2699 handler->id = strdup(id);
2701 ErrPrint("%s\n", strerror(errno));
2702 free(handler->pkgname);
2707 handler->timestamp = timestamp;
2708 handler->lb.type = _LB_TYPE_FILE;
2709 handler->pd.type = _PD_TYPE_SCRIPT;
2710 handler->state = CREATE;
2711 handler->visible = LB_SHOW;
2713 s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
2718 int lb_delete_all(void)
2722 struct livebox *handler;
2724 dlist_foreach_safe(s_info.livebox_list, l, n, handler) {
2725 lb_invoke_event_handler(handler, LB_EVENT_DELETED);
2729 return LB_STATUS_SUCCESS;
2732 int lb_set_content(struct livebox *handler, const char *content)
2734 if (handler->content) {
2735 free(handler->content);
2736 handler->content = NULL;
2740 handler->content = strdup(content);
2741 if (!handler->content) {
2742 CRITICAL_LOG("Heap: %s (content: %s)\n", strerror(errno), content);
2743 return LB_STATUS_ERROR_MEMORY;
2747 return LB_STATUS_SUCCESS;
2750 int lb_set_title(struct livebox *handler, const char *title)
2752 if (handler->title) {
2753 free(handler->title);
2754 handler->title = NULL;
2758 handler->title = strdup(title);
2759 if (!handler->title) {
2760 CRITICAL_LOG("Heap: %s (title: %s)\n", strerror(errno), title);
2761 return LB_STATUS_ERROR_MEMORY;
2765 return LB_STATUS_SUCCESS;
2768 void lb_set_size_list(struct livebox *handler, int size_list)
2770 handler->lb.size_list = size_list;
2773 void lb_set_auto_launch(struct livebox *handler, const char *auto_launch)
2775 if (!strlen(auto_launch)) {
2779 handler->lb.auto_launch = strdup(auto_launch);
2780 if (!handler->lb.auto_launch) {
2781 ErrPrint("Heap: %s\n", strerror(errno));
2785 void lb_set_priority(struct livebox *handler, double priority)
2787 handler->lb.priority = priority;
2790 void lb_set_id(struct livebox *handler, const char *id)
2796 handler->id = strdup(id);
2798 ErrPrint("Error: %s\n", strerror(errno));
2802 void lb_set_filename(struct livebox *handler, const char *filename)
2804 if (handler->filename) {
2805 if (unlink(handler->filename) < 0) {
2806 ErrPrint("unlink: %s\n", strerror(errno));
2809 free(handler->filename);
2812 handler->filename = strdup(filename);
2813 if (!handler->filename) {
2814 ErrPrint("Heap: %s\n", strerror(errno));
2819 int lb_set_lb_fb(struct livebox *handler, const char *filename)
2824 return LB_STATUS_ERROR_INVALID;
2827 fb = handler->lb.data.fb;
2828 if (fb && !strcmp(fb_id(fb), filename)) { /*!< BUFFER is not changed, */
2829 return LB_STATUS_SUCCESS;
2832 handler->lb.data.fb = NULL;
2834 if (!filename || filename[0] == '\0') {
2838 return LB_STATUS_SUCCESS;
2841 handler->lb.data.fb = fb_create(filename, handler->lb.width, handler->lb.height);
2842 if (!handler->lb.data.fb) {
2843 ErrPrint("Faield to create a FB\n");
2847 return LB_STATUS_ERROR_FAULT;
2854 return LB_STATUS_SUCCESS;
2857 int lb_set_pd_fb(struct livebox *handler, const char *filename)
2862 return LB_STATUS_ERROR_INVALID;
2865 fb = handler->pd.data.fb;
2866 if (fb && !strcmp(fb_id(fb), filename)) {
2867 /* BUFFER is not changed, just update the content */
2868 return LB_STATUS_ERROR_EXIST;
2870 handler->pd.data.fb = NULL;
2872 if (!filename || filename[0] == '\0') {
2876 return LB_STATUS_SUCCESS;
2879 handler->pd.data.fb = fb_create(filename, handler->pd.width, handler->pd.height);
2880 if (!handler->pd.data.fb) {
2881 ErrPrint("Failed to create a FB\n");
2885 return LB_STATUS_ERROR_FAULT;
2891 return LB_STATUS_SUCCESS;
2894 struct fb_info *lb_get_lb_fb(struct livebox *handler)
2896 return handler->lb.data.fb;
2899 struct fb_info *lb_get_pd_fb(struct livebox *handler)
2901 return handler->pd.data.fb;
2904 void lb_set_user(struct livebox *handler, int user)
2906 handler->is_user = user;
2909 void lb_set_pinup(struct livebox *handler, int pinup_supported)
2911 handler->lb.pinup_supported = pinup_supported;
2914 void lb_set_text_lb(struct livebox *handler)
2916 handler->lb.type = _LB_TYPE_TEXT;
2919 void lb_set_text_pd(struct livebox *handler)
2921 handler->pd.type = _PD_TYPE_TEXT;
2924 int lb_text_lb(struct livebox *handler)
2926 return handler->lb.type == _LB_TYPE_TEXT;
2929 int lb_text_pd(struct livebox *handler)
2931 return handler->pd.type == _PD_TYPE_TEXT;
2934 void lb_set_period(struct livebox *handler, double period)
2936 handler->lb.period = period;
2939 struct livebox *lb_ref(struct livebox *handler)
2949 struct livebox *lb_unref(struct livebox *handler)
2956 if (handler->refcnt > 0) {
2960 if (handler->created_cb) {
2961 handler->created_cb(handler, LB_STATUS_ERROR_FAULT, handler->created_cbdata);
2962 handler->created_cb = NULL;
2963 handler->created_cbdata = NULL;
2966 if (handler->deleted_cb) {
2967 handler->deleted_cb(handler, LB_STATUS_ERROR_FAULT, handler->deleted_cbdata);
2968 handler->deleted_cb = NULL;
2969 handler->deleted_cbdata = NULL;
2972 if (handler->pinup_cb) {
2973 handler->pinup_cb(handler, LB_STATUS_ERROR_FAULT, handler->pinup_cbdata);
2974 handler->pinup_cb = NULL;
2975 handler->pinup_cbdata = NULL;
2978 if (handler->group_changed_cb) {
2979 handler->group_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->group_cbdata);
2980 handler->group_changed_cb = NULL;
2981 handler->group_cbdata = NULL;
2984 if (handler->period_changed_cb) {
2985 handler->period_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->period_cbdata);
2986 handler->period_changed_cb = NULL;
2987 handler->period_cbdata = NULL;
2990 if (handler->size_changed_cb) {
2991 handler->size_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->size_cbdata);
2992 handler->size_changed_cb = NULL;
2993 handler->size_cbdata = NULL;
2996 if (handler->pd_created_cb) {
2997 handler->pd_created_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_created_cbdata);
2998 handler->pd_created_cb = NULL;
2999 handler->pd_created_cbdata = NULL;
3002 if (handler->pd_destroyed_cb) {
3003 handler->pd_destroyed_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_destroyed_cbdata);
3004 handler->pd_destroyed_cb = NULL;
3005 handler->pd_destroyed_cbdata = NULL;
3008 if (handler->update_mode_cb) {
3009 handler->update_mode_cb(handler, LB_STATUS_ERROR_FAULT, handler->update_mode_cbdata);
3010 handler->update_mode_cb = NULL;
3011 handler->update_mode_cbdata = NULL;
3014 if (handler->access_event_cb) {
3015 handler->access_event_cb(handler, LB_ACCESS_STATUS_ERROR, handler->access_event_cbdata);
3016 handler->access_event_cb = NULL;
3017 handler->access_event_cbdata = NULL;
3020 if (handler->filename) {
3021 (void)util_unlink(handler->filename);
3024 dlist_remove_data(s_info.livebox_list, handler);
3026 handler->state = DESTROYED;
3027 free(handler->cluster);
3028 free(handler->category);
3030 free(handler->pkgname);
3031 free(handler->filename);
3032 free(handler->lb.auto_launch);
3034 if (handler->lb.data.fb) {
3035 fb_destroy(handler->lb.data.fb);
3036 handler->lb.data.fb = NULL;
3039 if (handler->pd.data.fb) {
3040 fb_destroy(handler->pd.data.fb);
3041 handler->pd.data.fb = NULL;
3048 int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data)
3050 struct packet *packet;
3051 struct cb_info *cbinfo;
3054 if (!cb && !!data) {
3055 ErrPrint("Invalid argument\n");
3056 return LB_STATUS_ERROR_INVALID;
3059 if (handler->deleted_cb) {
3060 ErrPrint("Already in-progress\n");
3061 return LB_STATUS_ERROR_BUSY;
3064 packet = packet_create("delete", "ss", handler->pkgname, handler->id);
3066 ErrPrint("Failed to build a param\n");
3068 cb(handler, LB_STATUS_ERROR_FAULT, data);
3071 return LB_STATUS_ERROR_FAULT;
3075 cb = default_delete_cb;
3078 cbinfo = create_cb_info(cb, data);
3080 packet_destroy(packet);
3081 return LB_STATUS_ERROR_FAULT;
3084 ret = master_rpc_async_request(handler, packet, 0, del_ret_cb, cbinfo);
3086 destroy_cb_info(cbinfo);
3092 EAPI int livebox_client_paused(void)
3094 struct packet *packet;
3096 packet = packet_create_noack("client_paused", "d", util_timestamp());
3098 ErrPrint("Failed to create a pause packet\n");
3099 return LB_STATUS_ERROR_FAULT;
3102 return master_rpc_request_only(NULL, packet);
3105 EAPI int livebox_client_resumed(void)
3107 struct packet *packet;
3109 packet = packet_create_noack("client_resumed", "d", util_timestamp());
3111 ErrPrint("Failed to create a resume packet\n");
3112 return LB_STATUS_ERROR_FAULT;
3115 return master_rpc_request_only(NULL, packet);