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 */
26 #include <com-core_packet.h>
28 #include <livebox-service.h>
29 #include <livebox-errno.h>
34 #include "livebox_internal.h"
37 #include "master_rpc.h"
39 #include "critical_log.h"
41 #define EAPI __attribute__((visibility("default")))
42 #define MINIMUM_EVENT s_info.event_filter
49 struct dlist *livebox_list;
50 struct dlist *event_list;
51 struct dlist *fault_list;
53 int prevent_overwrite;
60 .prevent_overwrite = 0,
61 .event_filter = 0.01f,
70 int (*handler)(struct livebox *handler, enum livebox_event_type event, void *data);
75 int (*handler)(enum livebox_fault_type event, const char *pkgname, const char *filename, const char *func, void *data);
79 static inline void default_create_cb(struct livebox *handler, int ret, void *data)
81 DbgPrint("Default created event handler: %d\n", ret);
84 static inline void default_delete_cb(struct livebox *handler, int ret, void *data)
86 DbgPrint("Default deleted event handler: %d\n", ret);
89 static inline void default_pinup_cb(struct livebox *handler, int ret, void *data)
91 DbgPrint("Default pinup event handler: %d\n", ret);
94 static inline void default_group_changed_cb(struct livebox *handler, int ret, void *data)
96 DbgPrint("Default group changed event handler: %d\n", ret);
99 static inline void default_period_changed_cb(struct livebox *handler, int ret, void *data)
101 DbgPrint("Default period changed event handler: %d\n", ret);
104 static inline void default_pd_created_cb(struct livebox *handler, int ret, void *data)
106 DbgPrint("Default PD created event handler: %d\n", ret);
109 static inline void default_pd_destroyed_cb(struct livebox *handler, int ret, void *data)
111 DbgPrint("Default PD destroyed event handler: %d\n", ret);
114 static inline void default_lb_size_changed_cb(struct livebox *handler, int ret, void *data)
116 DbgPrint("Default LB size changed event handler: %d\n", ret);
119 static inline void default_update_mode_cb(struct livebox *handler, int ret, void *data)
121 DbgPrint("Default update mode set event handler: %d\n", ret);
124 static inline void default_access_event_cb(struct livebox *handler, int ret, void *data)
126 DbgPrint("Default access event handler: %d\n", ret);
129 static inline __attribute__((always_inline)) struct cb_info *create_cb_info(ret_cb_t cb, void *data)
131 struct cb_info *info;
133 info = malloc(sizeof(*info));
135 CRITICAL_LOG("Heap: %s\n", strerror(errno));
144 static inline void destroy_cb_info(struct cb_info *info)
149 static void update_mode_cb(struct livebox *handler, const struct packet *result, void *data)
154 ret = LB_STATUS_ERROR_FAULT;
156 } else if (packet_get(result, "i", &ret) != 1) {
157 ErrPrint("Invalid argument\n");
158 ret = LB_STATUS_ERROR_INVALID;
163 ErrPrint("Resize request is failed: %d\n", ret);
170 handler->update_mode_cb(handler, ret, handler->update_mode_cbdata);
171 handler->update_mode_cb = NULL;
172 handler->update_mode_cbdata = NULL;
176 static void resize_cb(struct livebox *handler, const struct packet *result, void *data)
181 ret = LB_STATUS_ERROR_FAULT;
183 } else if (packet_get(result, "i", &ret) != 1) {
184 ErrPrint("Invalid argument\n");
185 ret = LB_STATUS_ERROR_INVALID;
191 * In case of resize request,
192 * The livebox handler will not have resized value right after this callback,
193 * It can only get the new size when it makes updates.
195 * So the user can only get the resized value(result) from the first update event
196 * after this request.
199 ErrPrint("Resize request is failed: %d\n", ret);
206 handler->size_changed_cb(handler, ret, handler->size_cbdata);
207 handler->size_changed_cb = NULL;
208 handler->size_cbdata = NULL;
211 static void text_signal_cb(struct livebox *handler, const struct packet *result, void *data)
215 struct cb_info *info = data;
220 destroy_cb_info(info);
223 ret = LB_STATUS_ERROR_FAULT;
224 } else if (packet_get(result, "i", &ret) != 1) {
225 ErrPrint("Invalid argument\n");
226 ret = LB_STATUS_ERROR_INVALID;
230 cb(handler, ret, cbdata);
234 static void set_group_ret_cb(struct livebox *handler, const struct packet *result, void *data)
239 ret = LB_STATUS_ERROR_FAULT;
241 } else if (packet_get(result, "i", &ret) != 1) {
242 ErrPrint("Invalid argument\n");
243 ret = LB_STATUS_ERROR_INVALID;
253 handler->group_changed_cb(handler, ret, handler->group_cbdata);
254 handler->group_changed_cb = NULL;
255 handler->group_cbdata = NULL;
258 static void period_ret_cb(struct livebox *handler, const struct packet *result, void *data)
263 ret = LB_STATUS_ERROR_FAULT;
265 } else if (packet_get(result, "i", &ret) != 1) {
266 ErrPrint("Invalid argument\n");
267 ret = LB_STATUS_ERROR_INVALID;
277 handler->period_changed_cb(handler, ret, handler->period_cbdata);
278 handler->period_changed_cb = NULL;
279 handler->period_cbdata = NULL;
282 static void del_ret_cb(struct livebox *handler, const struct packet *result, void *data)
284 struct cb_info *info = data;
291 destroy_cb_info(info);
294 ErrPrint("Connection lost?\n");
295 ret = LB_STATUS_ERROR_FAULT;
296 } else if (packet_get(result, "i", &ret) != 1) {
297 ErrPrint("Invalid argument\n");
298 ret = LB_STATUS_ERROR_INVALID;
302 handler->deleted_cb = cb;
303 handler->deleted_cbdata = cbdata;
305 cb(handler, ret, cbdata);
310 * Do not call the deleted callback from here.
311 * master will send the "deleted" event.
312 * Then invoke this callback.
314 * if (handler->deleted_cb)
315 * handler->deleted_cb(handler, ret, handler->deleted_cbdata);
319 static void new_ret_cb(struct livebox *handler, const struct packet *result, void *data)
322 struct cb_info *info = data;
328 destroy_cb_info(info);
331 ret = LB_STATUS_ERROR_FAULT;
332 } else if (packet_get(result, "i", &ret) != 1) {
333 ret = LB_STATUS_ERROR_INVALID;
337 handler->created_cb = cb;
338 handler->created_cbdata = cbdata;
342 * Don't go anymore ;)
348 * It means the current instance is not created,
349 * so user has to know about this.
350 * notice it to user using "deleted" event.
352 cb(handler, ret, cbdata);
358 static void pd_create_cb(struct livebox *handler, const struct packet *result, void *data)
363 ret = LB_STATUS_ERROR_FAULT;
365 } else if (packet_get(result, "i", &ret) != 1) {
366 ret = LB_STATUS_ERROR_INVALID;
371 ErrPrint("Failed to create a PD[%d]\n", ret);
378 handler->pd_created_cb(handler, ret, handler->pd_created_cbdata);
379 handler->pd_created_cb = NULL;
380 handler->pd_created_cbdata = NULL;
383 static void activated_cb(struct livebox *handler, const struct packet *result, void *data)
386 struct cb_info *info = data;
389 const char *pkgname = "";
393 destroy_cb_info(info);
396 ret = LB_STATUS_ERROR_FAULT;
397 } else if (packet_get(result, "is", &ret, &pkgname) != 2) {
398 ret = LB_STATUS_ERROR_INVALID;
402 cb(handler, ret, cbdata);
405 static void pd_destroy_cb(struct livebox *handler, const struct packet *result, void *data)
410 struct cb_info *info = data;
414 destroy_cb_info(info);
417 ErrPrint("Result is NIL (may connection lost)\n");
418 ret = LB_STATUS_ERROR_FAULT;
419 } else if (packet_get(result, "i", &ret) != 1) {
420 ErrPrint("Invalid parameter\n");
421 ret = LB_STATUS_ERROR_INVALID;
425 handler->pd_destroyed_cb = cb;
426 handler->pd_destroyed_cbdata = cbdata;
428 handler->is_pd_created = 0;
429 cb(handler, ret, cbdata);
433 static void delete_cluster_cb(struct livebox *handler, const struct packet *result, void *data)
435 struct cb_info *info = data;
442 destroy_cb_info(info);
445 ret = LB_STATUS_ERROR_FAULT;
446 } else if (packet_get(result, "i", &ret) != 1) {
447 ret = LB_STATUS_ERROR_INVALID;
451 cb(handler, ret, cbdata);
454 static void delete_category_cb(struct livebox *handler, const struct packet *result, void *data)
456 struct cb_info *info = data;
463 destroy_cb_info(info);
466 ret = LB_STATUS_ERROR_FAULT;
467 else if (packet_get(result, "i", &ret) != 1)
468 ret = LB_STATUS_ERROR_INVALID;
471 cb(handler, ret, cbdata);
474 static void pixmap_acquired_cb(struct livebox *handler, const struct packet *result, void *data)
479 struct cb_info *info = data;
483 destroy_cb_info(info);
486 ret = 0; /* PIXMAP 0 means error */
487 else if (packet_get(result, "i", &ret) != 1)
491 cb(handler, ret, cbdata);
494 static void pinup_done_cb(struct livebox *handler, const struct packet *result, void *data)
499 ret = LB_STATUS_ERROR_FAULT;
501 } else if (packet_get(result, "i", &ret) != 1) {
511 handler->pinup_cb(handler, ret, handler->pinup_cbdata);
512 handler->pinup_cb = NULL;
513 handler->pinup_cbdata = NULL;
516 static void access_ret_cb(struct livebox *handler, const struct packet *result, void *data)
521 ret = LB_STATUS_ERROR_FAULT;
525 if (packet_get(result, "i", &ret) != 1) {
526 ret = LB_STATUS_ERROR_INVALID;
530 if (ret != LB_STATUS_SUCCESS) {
537 handler->access_event_cb(handler, ret, handler->access_event_cbdata);
538 handler->access_event_cb = NULL;
539 handler->access_event_cbdata = NULL;
543 static int send_access_event(struct livebox *handler, const char *event, int x, int y)
545 struct packet *packet;
548 timestamp = util_timestamp();
550 packet = packet_create(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y);
552 ErrPrint("Failed to build packet\n");
553 return LB_STATUS_ERROR_FAULT;
556 return master_rpc_async_request(handler, packet, 0, access_ret_cb, NULL);
559 static int send_mouse_event(struct livebox *handler, const char *event, int x, int y)
561 struct packet *packet;
564 timestamp = util_timestamp();
565 packet = packet_create_noack(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y);
567 ErrPrint("Failed to build param\n");
568 return LB_STATUS_ERROR_FAULT;
571 return master_rpc_request_only(handler, packet);
574 EAPI int livebox_init(void *disp)
578 if (s_info.init_count > 0) {
580 return LB_STATUS_SUCCESS;
582 env = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
583 if (env && !strcasecmp(env, "true"))
584 s_info.prevent_overwrite = 1;
586 env = getenv("PROVIDER_EVENT_FILTER");
588 sscanf(env, "%lf", &MINIMUM_EVENT);
591 char filename[BUFSIZ];
592 snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
593 __file_log_fp = fopen(filename, "w+t");
595 __file_log_fp = fdopen(1, "w+t");
597 critical_log_init("viewer");
598 livebox_service_init();
604 return LB_STATUS_SUCCESS;
607 EAPI int livebox_fini(void)
609 if (s_info.init_count <= 0) {
610 ErrPrint("Doesn't initialized\n");
611 return LB_STATUS_ERROR_INVALID;
615 if (s_info.init_count > 0) {
616 ErrPrint("init count : %d\n", s_info.init_count);
617 return LB_STATUS_SUCCESS;
622 livebox_service_fini();
624 return LB_STATUS_SUCCESS;
627 static inline char *lb_pkgname(const char *pkgname)
631 lb = livebox_service_pkgname(pkgname);
633 if (util_validate_livebox_package(pkgname) == 0)
634 return strdup(pkgname);
641 * Just wrapping the livebox_add_with_size function.
643 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)
645 return livebox_add_with_size(pkgname, content, cluster, category, period, LB_SIZE_TYPE_UNKNOWN, cb, data);
648 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)
650 struct livebox *handler;
651 struct packet *packet;
655 struct cb_info *cbinfo;
657 if (!pkgname || !cluster || !category) {
658 ErrPrint("Invalid arguments: pkgname[%p], cluster[%p], category[%p]\n",
659 pkgname, cluster, category);
663 if (type != LB_SIZE_TYPE_UNKNOWN)
664 livebox_service_get_size(type, &width, &height);
666 handler = calloc(1, sizeof(*handler));
668 ErrPrint("Error: %s\n", strerror(errno));
672 handler->pkgname = lb_pkgname(pkgname);
673 if (!handler->pkgname) {
678 if (livebox_service_is_enabled(handler->pkgname) == 0) {
679 DbgPrint("Livebox [%s](%s) is disabled package\n", handler->pkgname, pkgname);
680 free(handler->pkgname);
686 handler->content = strdup(content);
687 if (!handler->content) {
688 ErrPrint("Error: %s\n", strerror(errno));
689 free(handler->pkgname);
694 handler->content = livebox_service_content(handler->pkgname);
697 handler->cluster = strdup(cluster);
698 if (!handler->cluster) {
699 ErrPrint("Error: %s\n", strerror(errno));
700 free(handler->content);
701 free(handler->pkgname);
706 handler->category = strdup(category);
707 if (!handler->category) {
708 ErrPrint("Error: %s\n", strerror(errno));
709 free(handler->cluster);
710 free(handler->content);
711 free(handler->pkgname);
717 cb = default_create_cb;
719 /* Data provider will set this */
720 handler->lb.type = _LB_TYPE_FILE;
721 handler->pd.type = _PD_TYPE_SCRIPT;
722 handler->lb.period = period;
724 /* Used for handling the mouse event on a box */
725 handler->lb.mouse_event = livebox_service_mouse_event(handler->pkgname);
727 /* Cluster infomration is not determined yet */
728 handler->nr_of_sizes = 0x01;
730 handler->timestamp = util_timestamp();
731 handler->is_user = 1;
732 handler->visible = LB_SHOW;
734 s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
736 packet = packet_create("new", "dssssdii", handler->timestamp, handler->pkgname, handler->content, cluster, category, period, width, height);
738 ErrPrint("Failed to create a new packet\n");
739 free(handler->category);
740 free(handler->cluster);
741 free(handler->content);
742 free(handler->pkgname);
747 cbinfo = create_cb_info(cb, data);
749 ErrPrint("Failed to create a cbinfo\n");
750 packet_destroy(packet);
751 free(handler->category);
752 free(handler->cluster);
753 free(handler->content);
754 free(handler->pkgname);
759 ret = master_rpc_async_request(handler, packet, 0, new_ret_cb, cbinfo);
761 ErrPrint("Failed to send a new packet\n");
762 destroy_cb_info(cbinfo);
763 free(handler->category);
764 free(handler->cluster);
765 free(handler->content);
766 free(handler->pkgname);
771 handler->state = CREATE;
772 return lb_ref(handler);
775 EAPI double livebox_period(struct livebox *handler)
777 if (!handler || handler->state != CREATE || !handler->id) {
778 ErrPrint("Handler is not valid\n");
782 return handler->lb.period;
785 EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, void *data)
787 struct packet *packet;
790 if (!handler || handler->state != CREATE || !handler->id) {
791 ErrPrint("Handler is not valid\n");
792 return LB_STATUS_ERROR_INVALID;
795 if (handler->period_changed_cb) {
796 ErrPrint("Previous request for changing period is not finished\n");
797 return LB_STATUS_ERROR_BUSY;
800 if (!handler->is_user) {
801 ErrPrint("CA Livebox is not able to change the period\n");
802 return LB_STATUS_ERROR_PERMISSION;
805 if (handler->lb.period == period) {
806 DbgPrint("No changes\n");
807 return LB_STATUS_ERROR_ALREADY;
810 packet = packet_create("set_period", "ssd", handler->pkgname, handler->id, period);
812 ErrPrint("Failed to build a packet %s\n", handler->pkgname);
813 return LB_STATUS_ERROR_FAULT;
817 cb = default_period_changed_cb;
819 ret = master_rpc_async_request(handler, packet, 0, period_ret_cb, NULL);
820 if (ret == LB_STATUS_SUCCESS) {
821 handler->period_changed_cb = cb;
822 handler->period_cbdata = data;
828 EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data)
831 ErrPrint("Handler is NIL\n");
832 return LB_STATUS_ERROR_INVALID;
835 if (handler->state != CREATE) {
836 ErrPrint("Handler is already deleted\n");
837 return LB_STATUS_ERROR_INVALID;
840 handler->state = DELETE;
845 * The id is not determined yet.
846 * It means a user didn't receive created event yet.
847 * Then just stop to delete procedure from here.
848 * Because the "created" event handler will release this.
849 * By the way, if the user adds any callback for getting return status of this,
853 cb(handler, 0, data);
854 return LB_STATUS_SUCCESS;
858 cb = default_delete_cb;
860 return lb_send_delete(handler, cb, data);
863 EAPI int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *), void *data)
865 struct fault_info *info;
868 return LB_STATUS_ERROR_INVALID;
870 info = malloc(sizeof(*info));
872 CRITICAL_LOG("Heap: %s\n", strerror(errno));
873 return LB_STATUS_ERROR_MEMORY;
877 info->user_data = data;
879 s_info.fault_list = dlist_append(s_info.fault_list, info);
880 return LB_STATUS_SUCCESS;
883 EAPI void *livebox_unset_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *))
885 struct fault_info *info;
888 dlist_foreach(s_info.fault_list, l, info) {
889 if (info->handler == cb) {
892 s_info.fault_list = dlist_remove(s_info.fault_list, l);
893 data = info->user_data;
903 EAPI int livebox_set_event_handler(int (*cb)(struct livebox *, enum livebox_event_type, void *), void *data)
905 struct event_info *info;
908 ErrPrint("Invalid argument cb is nil\n");
909 return LB_STATUS_ERROR_INVALID;
912 info = malloc(sizeof(*info));
914 CRITICAL_LOG("Heap: %s\n", strerror(errno));
915 return LB_STATUS_ERROR_MEMORY;
919 info->user_data = data;
921 s_info.event_list = dlist_append(s_info.event_list, info);
922 return LB_STATUS_SUCCESS;
925 EAPI void *livebox_unset_event_handler(int (*cb)(struct livebox *, enum livebox_event_type, void *))
927 struct event_info *info;
930 dlist_foreach(s_info.event_list, l, info) {
931 if (info->handler == cb) {
934 s_info.event_list = dlist_remove(s_info.event_list, l);
935 data = info->user_data;
945 EAPI int livebox_set_update_mode(struct livebox *handler, int active_update, ret_cb_t cb, void *data)
947 struct packet *packet;
951 ErrPrint("Handler is NIL\n");
952 return LB_STATUS_ERROR_INVALID;
955 if (handler->state != CREATE || !handler->id)
956 return LB_STATUS_ERROR_INVALID;
958 if (handler->update_mode_cb) {
959 ErrPrint("Previous update_mode cb is not finished yet\n");
960 return LB_STATUS_ERROR_BUSY;
963 if (handler->is_active_update == active_update)
964 return LB_STATUS_ERROR_ALREADY;
966 if (!handler->is_user)
967 return LB_STATUS_ERROR_PERMISSION;
969 packet = packet_create("update_mode", "ssi", handler->pkgname, handler->id, active_update);
971 return LB_STATUS_ERROR_FAULT;
974 cb = default_update_mode_cb;
976 ret = master_rpc_async_request(handler, packet, 0, update_mode_cb, NULL);
977 if (ret == LB_STATUS_SUCCESS) {
978 handler->update_mode_cb = cb;
979 handler->update_mode_cbdata = data;
985 EAPI int livebox_is_active_update(struct livebox *handler)
988 ErrPrint("Handler is NIL\n");
989 return LB_STATUS_ERROR_INVALID;
992 if (handler->state != CREATE || !handler->id)
993 return LB_STATUS_ERROR_INVALID;
995 return handler->is_active_update;
998 EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data)
1000 struct packet *packet;
1006 ErrPrint("Handler is NIL\n");
1007 return LB_STATUS_ERROR_INVALID;
1010 if (handler->state != CREATE || !handler->id) {
1011 ErrPrint("Handler is not valid\n");
1012 return LB_STATUS_ERROR_INVALID;
1015 if (handler->size_changed_cb) {
1016 ErrPrint("Previous resize request is not finished yet\n");
1017 return LB_STATUS_ERROR_BUSY;
1020 if (!handler->is_user) {
1021 ErrPrint("CA Livebox is not able to be resized\n");
1022 return LB_STATUS_ERROR_PERMISSION;
1025 if (livebox_service_get_size(type, &w, &h) != 0) {
1026 ErrPrint("Invalid size type\n");
1027 return LB_STATUS_ERROR_INVALID;
1030 if (handler->lb.width == w && handler->lb.height == h) {
1031 DbgPrint("No changes\n");
1032 return LB_STATUS_ERROR_ALREADY;;
1035 packet = packet_create("resize", "ssii", handler->pkgname, handler->id, w, h);
1037 ErrPrint("Failed to build param\n");
1038 return LB_STATUS_ERROR_FAULT;
1042 cb = default_lb_size_changed_cb;
1044 ret = master_rpc_async_request(handler, packet, 0, resize_cb, NULL);
1045 if (ret == LB_STATUS_SUCCESS) {
1046 handler->size_changed_cb = cb;
1047 handler->size_cbdata = data;
1053 EAPI int livebox_click(struct livebox *handler, double x, double y)
1055 struct packet *packet;
1059 timestamp = util_timestamp();
1062 ErrPrint("Handler is NIL\n");
1063 return LB_STATUS_ERROR_INVALID;
1066 if (handler->state != CREATE || !handler->id) {
1067 ErrPrint("Handler is not valid\n");
1068 return LB_STATUS_ERROR_INVALID;
1071 if (handler->lb.auto_launch) {
1072 DbgPrint("AUTO_LAUNCH [%s]\n", handler->lb.auto_launch);
1073 if (aul_launch_app(handler->lb.auto_launch, NULL) < 0)
1074 ErrPrint("Failed to launch app %s\n", handler->lb.auto_launch);
1077 packet = packet_create_noack("clicked", "sssddd", handler->pkgname, handler->id, "clicked", timestamp, x, y);
1079 ErrPrint("Failed to build param\n");
1080 return LB_STATUS_ERROR_FAULT;
1083 DbgPrint("CLICKED: %lf\n", timestamp);
1084 ret = master_rpc_request_only(handler, packet);
1086 if (!handler->lb.mouse_event && (handler->lb.type == _LB_TYPE_BUFFER || handler->lb.type == _LB_TYPE_SCRIPT)) {
1087 int ret; /* Shadow variable */
1088 ret = send_mouse_event(handler, "lb_mouse_down", x * handler->lb.width, y * handler->lb.height);
1090 ErrPrint("Failed to send Down: %d\n", ret);
1092 ret = send_mouse_event(handler, "lb_mouse_move", x * handler->lb.width, y * handler->lb.height);
1094 ErrPrint("Failed to send Move: %d\n", ret);
1096 ret = send_mouse_event(handler, "lb_mouse_up", x * handler->lb.width, y * handler->lb.height);
1098 ErrPrint("Failed to send Up: %d\n", ret);
1104 EAPI int livebox_has_pd(struct livebox *handler)
1107 ErrPrint("Handler is NIL\n");
1108 return LB_STATUS_ERROR_INVALID;
1111 if (handler->state != CREATE || !handler->id) {
1112 ErrPrint("Handler is not valid\n");
1113 return LB_STATUS_ERROR_INVALID;
1116 return !!handler->pd.data.fb;
1119 EAPI int livebox_pd_is_created(struct livebox *handler)
1122 ErrPrint("Handler is NIL\n");
1123 return LB_STATUS_ERROR_INVALID;
1126 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1127 ErrPrint("Handler is not valid\n");
1128 return LB_STATUS_ERROR_INVALID;
1131 return handler->is_pd_created;
1134 EAPI int livebox_create_pd(struct livebox *handler, ret_cb_t cb, void *data)
1136 return livebox_create_pd_with_position(handler, -1.0, -1.0, cb, data);
1139 EAPI int livebox_create_pd_with_position(struct livebox *handler, double x, double y, ret_cb_t cb, void *data)
1141 struct packet *packet;
1145 ErrPrint("Handler is NIL\n");
1146 return LB_STATUS_ERROR_INVALID;
1149 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1150 ErrPrint("Handler is not valid\n");
1151 return LB_STATUS_ERROR_INVALID;
1154 if (handler->is_pd_created == 1) {
1155 DbgPrint("PD already created\n");
1156 return LB_STATUS_SUCCESS;
1159 if (handler->pd_created_cb) {
1160 ErrPrint("Previous request is not completed yet\n");
1161 return LB_STATUS_ERROR_BUSY;
1164 packet = packet_create("create_pd", "ssdd", handler->pkgname, handler->id, x, y);
1166 ErrPrint("Failed to build param\n");
1167 return LB_STATUS_ERROR_FAULT;
1171 cb = default_pd_created_cb;
1173 DbgPrint("PERF_DBOX\n");
1174 ret = master_rpc_async_request(handler, packet, 0, pd_create_cb, NULL);
1175 if (ret == LB_STATUS_SUCCESS) {
1176 handler->pd_created_cb = cb;
1177 handler->pd_created_cbdata = data;
1183 EAPI int livebox_move_pd(struct livebox *handler, double x, double y)
1185 struct packet *packet;
1188 ErrPrint("Handler is NIL\n");
1189 return LB_STATUS_ERROR_INVALID;
1192 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1193 ErrPrint("Handler is not valid\n");
1194 return LB_STATUS_ERROR_INVALID;
1197 if (!handler->is_pd_created) {
1198 ErrPrint("PD is not created\n");
1199 return LB_STATUS_ERROR_INVALID;
1202 packet = packet_create_noack("pd_move", "ssdd", handler->pkgname, handler->id, x, y);
1204 ErrPrint("Failed to build param\n");
1205 return LB_STATUS_ERROR_FAULT;
1208 return master_rpc_request_only(handler, packet);
1211 EAPI int livebox_activate(const char *pkgname, ret_cb_t cb, void *data)
1213 struct packet *packet;
1214 struct cb_info *cbinfo;
1218 return LB_STATUS_ERROR_INVALID;
1220 packet = packet_create("activate_package", "s", pkgname);
1222 ErrPrint("Failed to build a param\n");
1223 return LB_STATUS_ERROR_FAULT;
1226 cbinfo = create_cb_info(cb, data);
1228 ErrPrint("Unable to create cbinfo\n");
1229 packet_destroy(packet);
1230 return LB_STATUS_ERROR_FAULT;
1233 ret = master_rpc_async_request(NULL, packet, 0, activated_cb, cbinfo);
1235 destroy_cb_info(cbinfo);
1240 EAPI int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data)
1242 struct packet *packet;
1243 struct cb_info *cbinfo;
1247 ErrPrint("Handler is NIL\n");
1248 return LB_STATUS_ERROR_INVALID;
1251 if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
1252 ErrPrint("Handler is not valid\n");
1253 return LB_STATUS_ERROR_INVALID;
1256 if (!handler->is_pd_created && !handler->pd_created_cb) {
1257 ErrPrint("PD is not created\n");
1258 return LB_STATUS_ERROR_INVALID;
1261 packet = packet_create("destroy_pd", "ss", handler->pkgname, handler->id);
1263 ErrPrint("Failed to build a param\n");
1264 return LB_STATUS_ERROR_FAULT;
1268 cb = default_pd_destroyed_cb;
1270 cbinfo = create_cb_info(cb, data);
1272 packet_destroy(packet);
1273 return LB_STATUS_ERROR_FAULT;
1276 ret = master_rpc_async_request(handler, packet, 0, pd_destroy_cb, cbinfo);
1278 destroy_cb_info(cbinfo);
1283 EAPI int livebox_access_event(struct livebox *handler, enum access_event_type type, double x, double y, ret_cb_t cb, void *data)
1287 char cmd[32] = { '\0', };
1292 ErrPrint("Handler is NIL\n");
1293 return LB_STATUS_ERROR_INVALID;
1296 if (handler->state != CREATE || !handler->id) {
1297 ErrPrint("Handler is not valid\n");
1298 return LB_STATUS_ERROR_INVALID;
1301 if (handler->access_event_cb) {
1302 ErrPrint("Previous access event is not yet done\n");
1303 return LB_STATUS_ERROR_BUSY;
1306 if (type & ACCESS_EVENT_PD_MASK) {
1307 if (!handler->is_pd_created) {
1308 ErrPrint("PD is not created\n");
1309 return LB_STATUS_ERROR_INVALID;
1313 w = handler->pd.width;
1314 h = handler->pd.height;
1315 } else if (type & ACCESS_EVENT_LB_MASK) {
1318 w = handler->lb.width;
1319 h = handler->lb.height;
1321 ErrPrint("Invalid event type\n");
1322 return LB_STATUS_ERROR_INVALID;
1325 switch (type & ~ACCESS_EVENT_PD_MASK) {
1326 case ACCESS_EVENT_HIGHLIGHT:
1327 strcpy(ptr, "_access_hl");
1329 case ACCESS_EVENT_HIGHLIGHT_NEXT:
1330 strcpy(ptr, "_access_hl_next");
1332 case ACCESS_EVENT_HIGHLIGHT_PREV:
1333 strcpy(ptr, "_access_hl_prev");
1335 case ACCESS_EVENT_ACTIVATE:
1336 strcpy(ptr, "_access_activate");
1338 case ACCESS_EVENT_ACTION_DOWN:
1339 strcpy(ptr, "_access_action_down");
1341 case ACCESS_EVENT_ACTION_UP:
1342 strcpy(ptr, "_access_action_up");
1344 case ACCESS_EVENT_UNHIGHLIGHT:
1345 strcpy(ptr, "_access_unhighlight");
1347 case ACCESS_EVENT_SCROLL_DOWN:
1348 strcpy(ptr, "_access_scroll_down");
1350 case ACCESS_EVENT_SCROLL_MOVE:
1351 strcpy(ptr, "_access_scroll_move");
1353 case ACCESS_EVENT_SCROLL_UP:
1354 strcpy(ptr, "_access_scroll_up");
1357 return LB_STATUS_ERROR_INVALID;
1361 cb = default_access_event_cb;
1363 ret = send_access_event(handler, cmd, x * w, y * h);
1364 if (ret == LB_STATUS_SUCCESS) {
1365 handler->access_event_cb = cb;
1366 handler->access_event_cbdata = data;
1372 EAPI int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y)
1376 char cmd[32] = { '\0', };
1380 ErrPrint("Handler is NIL\n");
1381 return LB_STATUS_ERROR_INVALID;
1384 if (handler->state != CREATE || !handler->id) {
1385 ErrPrint("Handler is not valid\n");
1386 return LB_STATUS_ERROR_INVALID;
1389 if (type & CONTENT_EVENT_PD_MASK) {
1392 if (!handler->is_pd_created) {
1393 ErrPrint("PD is not created\n");
1394 return LB_STATUS_ERROR_INVALID;
1397 if (type & CONTENT_EVENT_MOUSE_MASK) {
1398 if (!handler->pd.data.fb) {
1399 ErrPrint("Handler is not valid\n");
1400 return LB_STATUS_ERROR_INVALID;
1403 if (type & CONTENT_EVENT_MOUSE_MOVE) {
1404 if (fabs(x - handler->pd.x) < MINIMUM_EVENT && fabs(y - handler->pd.y) < MINIMUM_EVENT)
1405 return LB_STATUS_ERROR_BUSY;
1406 } else if (type & CONTENT_EVENT_MOUSE_SET) {
1412 w = handler->pd.width;
1413 h = handler->pd.height;
1419 } else if (type & CONTENT_EVENT_LB_MASK) {
1422 if (type & CONTENT_EVENT_MOUSE_MASK) {
1423 if (!handler->lb.mouse_event)
1424 return LB_STATUS_ERROR_INVALID;
1426 if (!handler->lb.data.fb) {
1427 ErrPrint("Handler is not valid\n");
1428 return LB_STATUS_ERROR_INVALID;
1431 if (type & CONTENT_EVENT_MOUSE_MOVE) {
1432 if (fabs(x - handler->lb.x) < MINIMUM_EVENT && fabs(y - handler->lb.y) < MINIMUM_EVENT)
1433 return LB_STATUS_ERROR_BUSY;
1434 } else if (type & CONTENT_EVENT_MOUSE_SET) {
1440 w = handler->lb.width;
1441 h = handler->lb.height;
1448 ErrPrint("Invalid event type\n");
1449 return LB_STATUS_ERROR_INVALID;
1453 * Must be short than 29 bytes.
1455 switch ((type & ~(CONTENT_EVENT_PD_MASK | CONTENT_EVENT_LB_MASK))) {
1456 case CONTENT_EVENT_MOUSE_ENTER | CONTENT_EVENT_MOUSE_MASK:
1457 strcpy(ptr, "_mouse_enter");
1459 case CONTENT_EVENT_MOUSE_LEAVE | CONTENT_EVENT_MOUSE_MASK:
1460 strcpy(ptr, "_mouse_leave");
1462 case CONTENT_EVENT_MOUSE_UP | CONTENT_EVENT_MOUSE_MASK:
1463 strcpy(ptr, "_mouse_up");
1465 case CONTENT_EVENT_MOUSE_DOWN | CONTENT_EVENT_MOUSE_MASK:
1466 strcpy(ptr, "_mouse_down");
1468 case CONTENT_EVENT_MOUSE_MOVE | CONTENT_EVENT_MOUSE_MASK:
1469 strcpy(ptr, "_mouse_move");
1471 case CONTENT_EVENT_MOUSE_SET | CONTENT_EVENT_MOUSE_MASK:
1472 strcpy(ptr, "_mouse_set");
1474 case CONTENT_EVENT_MOUSE_UNSET | CONTENT_EVENT_MOUSE_MASK:
1475 strcpy(ptr, "_mouse_unset");
1477 case CONTENT_EVENT_KEY_DOWN | CONTENT_EVENT_KEY_MASK:
1478 strcpy(ptr, "_key_down");
1480 case CONTENT_EVENT_KEY_UP | CONTENT_EVENT_KEY_MASK:
1481 strcpy(ptr, "_key_up");
1484 ErrPrint("Invalid event type\n");
1485 return LB_STATUS_ERROR_INVALID;
1488 return send_mouse_event(handler, cmd, x * w, y * h);
1491 EAPI const char *livebox_filename(struct livebox *handler)
1494 ErrPrint("Handler is NIL\n");
1498 if (handler->state != CREATE || !handler->id) {
1499 ErrPrint("Handler is not valid\n");
1503 if (handler->filename)
1504 return handler->filename;
1507 return util_uri_to_path(handler->id);
1510 EAPI int livebox_get_pdsize(struct livebox *handler, int *w, int *h)
1516 ErrPrint("Handler is NIL\n");
1517 return LB_STATUS_ERROR_INVALID;
1520 if (handler->state != CREATE || !handler->id) {
1521 ErrPrint("Handler is not valid\n");
1522 return LB_STATUS_ERROR_INVALID;
1530 if (!handler->is_pd_created) {
1531 *w = handler->pd.default_width;
1532 *h = handler->pd.default_height;
1534 *w = handler->pd.width;
1535 *h = handler->pd.height;
1538 return LB_STATUS_SUCCESS;
1541 EAPI int livebox_size(struct livebox *handler)
1547 ErrPrint("Handler is NIL\n");
1548 return LB_STATUS_ERROR_INVALID;
1551 if (handler->state != CREATE || !handler->id) {
1552 ErrPrint("Handler is not valid\n");
1553 return LB_STATUS_ERROR_INVALID;
1556 w = handler->lb.width;
1557 h = handler->lb.height;
1559 switch (handler->lb.type) {
1560 case _LB_TYPE_BUFFER:
1561 case _LB_TYPE_SCRIPT:
1562 if (!fb_is_created(handler->lb.data.fb)) {
1571 return livebox_service_size_type(w, h);
1574 EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const char *category, ret_cb_t cb, void *data)
1576 struct packet *packet;
1580 ErrPrint("Handler is NIL\n");
1581 return LB_STATUS_ERROR_INVALID;
1584 if (!cluster || !category || handler->state != CREATE || !handler->id) {
1585 ErrPrint("Invalid argument\n");
1586 return LB_STATUS_ERROR_INVALID;
1589 if (handler->group_changed_cb) {
1590 ErrPrint("Previous group changing request is not finished yet\n");
1591 return LB_STATUS_ERROR_BUSY;
1594 if (!handler->is_user) {
1595 ErrPrint("CA Livebox is not able to change the group\n");
1596 return LB_STATUS_ERROR_PERMISSION;
1599 if (!strcmp(handler->cluster, cluster) && !strcmp(handler->category, category)) {
1600 DbgPrint("No changes\n");
1601 return LB_STATUS_ERROR_ALREADY;
1604 packet = packet_create("change_group", "ssss", handler->pkgname, handler->id, cluster, category);
1606 ErrPrint("Failed to build a param\n");
1607 return LB_STATUS_ERROR_FAULT;
1611 cb = default_group_changed_cb;
1613 ret = master_rpc_async_request(handler, packet, 0, set_group_ret_cb, NULL);
1614 if (ret == LB_STATUS_SUCCESS) {
1615 handler->group_changed_cb = cb;
1616 handler->group_cbdata = data;
1622 EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category)
1625 ErrPrint("Handler is NIL\n");
1626 return LB_STATUS_ERROR_INVALID;
1629 if (!cluster || !category || handler->state != CREATE || !handler->id) {
1630 ErrPrint("Invalid argument\n");
1631 return LB_STATUS_ERROR_INVALID;
1634 *cluster = handler->cluster;
1635 *category = handler->category;
1636 return LB_STATUS_SUCCESS;
1639 EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list)
1644 if (!handler || !size_list) {
1645 ErrPrint("Invalid argument, handler(%p), size_list(%p)\n", handler, size_list);
1646 return LB_STATUS_ERROR_INVALID;
1649 if (!cnt || handler->state != CREATE || !handler->id) {
1650 ErrPrint("Handler is not valid\n");
1651 return LB_STATUS_ERROR_INVALID;
1654 for (j = i = 0; i < NR_OF_SIZE_LIST; i++) {
1655 if (handler->lb.size_list & (0x01 << i)) {
1659 size_list[j++] = (0x01 << i);
1664 return LB_STATUS_SUCCESS;
1667 EAPI const char *livebox_pkgname(struct livebox *handler)
1670 ErrPrint("Handler is NIL\n");
1674 if (handler->state != CREATE) {
1675 ErrPrint("Handler is not valid\n");
1679 return handler->pkgname;
1682 EAPI double livebox_priority(struct livebox *handler)
1685 ErrPrint("Handler is NIL\n");
1689 if (handler->state != CREATE || !handler->id) {
1690 ErrPrint("Handler is not valid (%p)\n", handler);
1694 return handler->lb.priority;
1697 EAPI int livebox_delete_cluster(const char *cluster, ret_cb_t cb, void *data)
1699 struct packet *packet;
1700 struct cb_info *cbinfo;
1703 packet = packet_create("delete_cluster", "s", cluster);
1705 ErrPrint("Failed to build a param\n");
1706 return LB_STATUS_ERROR_FAULT;
1709 cbinfo = create_cb_info(cb, data);
1711 packet_destroy(packet);
1712 return LB_STATUS_ERROR_FAULT;
1715 ret = master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, cbinfo);
1717 destroy_cb_info(cbinfo);
1722 EAPI int livebox_delete_category(const char *cluster, const char *category, ret_cb_t cb, void *data)
1724 struct packet *packet;
1725 struct cb_info *cbinfo;
1728 packet = packet_create("delete_category", "ss", cluster, category);
1730 ErrPrint("Failed to build a param\n");
1731 return LB_STATUS_ERROR_FAULT;
1734 cbinfo = create_cb_info(cb, data);
1736 packet_destroy(packet);
1737 return LB_STATUS_ERROR_FAULT;
1740 ret = master_rpc_async_request(NULL, packet, 0, delete_category_cb, cbinfo);
1742 destroy_cb_info(cbinfo);
1747 EAPI enum livebox_lb_type livebox_lb_type(struct livebox *handler)
1750 ErrPrint("Handler is NIL\n");
1751 return LB_TYPE_INVALID;
1754 if (handler->state != CREATE || !handler->id) {
1755 ErrPrint("Handler is not valid\n");
1756 return LB_TYPE_INVALID;
1759 switch (handler->lb.type) {
1761 return LB_TYPE_IMAGE;
1762 case _LB_TYPE_BUFFER:
1763 case _LB_TYPE_SCRIPT:
1766 id = fb_id(handler->lb.data.fb);
1767 if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
1768 return LB_TYPE_PIXMAP;
1770 return LB_TYPE_BUFFER;
1772 return LB_TYPE_TEXT;
1777 return LB_TYPE_INVALID;
1780 EAPI enum livebox_pd_type livebox_pd_type(struct livebox *handler)
1783 ErrPrint("Handler is NIL\n");
1784 return PD_TYPE_INVALID;
1787 if (handler->state != CREATE || !handler->id) {
1788 ErrPrint("Handler is not valid\n");
1789 return PD_TYPE_INVALID;
1792 switch (handler->pd.type) {
1794 return PD_TYPE_TEXT;
1795 case _PD_TYPE_BUFFER:
1796 case _PD_TYPE_SCRIPT:
1799 id = fb_id(handler->pd.data.fb);
1800 if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
1801 return PD_TYPE_PIXMAP;
1803 return PD_TYPE_BUFFER;
1808 return PD_TYPE_INVALID;
1811 EAPI int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_script_operators *ops)
1814 ErrPrint("Handler is NIL\n");
1815 return LB_STATUS_ERROR_INVALID;
1818 if (handler->state != CREATE) {
1819 ErrPrint("Handler is not valid\n");
1820 return LB_STATUS_ERROR_INVALID;
1823 memcpy(&handler->pd.data.ops, ops, sizeof(*ops));
1824 return LB_STATUS_SUCCESS;
1827 EAPI int livebox_set_text_handler(struct livebox *handler, struct livebox_script_operators *ops)
1830 ErrPrint("Handler is NIL\n");
1831 return LB_STATUS_ERROR_INVALID;
1834 if (handler->state != CREATE) {
1835 ErrPrint("Handler is not valid\n");
1836 return LB_STATUS_ERROR_INVALID;
1839 memcpy(&handler->lb.data.ops, ops, sizeof(*ops));
1840 return LB_STATUS_SUCCESS;
1843 EAPI int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
1845 struct packet *packet;
1846 struct cb_info *cbinfo;
1851 ErrPrint("Handler is NIL\n");
1852 return LB_STATUS_ERROR_INVALID;
1855 if (handler->state != CREATE || !handler->id) {
1856 ErrPrint("Invalid handle\n");
1857 return LB_STATUS_ERROR_INVALID;
1860 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
1861 ErrPrint("Handler is not valid type\n");
1862 return LB_STATUS_ERROR_INVALID;
1865 id = fb_id(handler->lb.data.fb);
1866 if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
1867 return LB_STATUS_ERROR_INVALID;
1869 packet = packet_create("lb_acquire_pixmap", "ss", handler->pkgname, handler->id);
1871 ErrPrint("Failed to build a param\n");
1872 return LB_STATUS_ERROR_FAULT;
1875 cbinfo = create_cb_info(cb, data);
1877 packet_destroy(packet);
1878 return LB_STATUS_ERROR_FAULT;
1881 ret = master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, cbinfo);
1883 destroy_cb_info(cbinfo);
1888 EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
1890 struct packet *packet;
1893 ErrPrint("Handler is NIL\n");
1894 return LB_STATUS_ERROR_INVALID;
1897 if (handler->state != CREATE || !handler->id) {
1898 ErrPrint("Invalid handle\n");
1899 return LB_STATUS_ERROR_INVALID;
1902 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
1903 ErrPrint("Handler is not valid type\n");
1904 return LB_STATUS_ERROR_INVALID;
1907 packet = packet_create_noack("lb_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap);
1909 ErrPrint("Failed to build a param\n");
1910 return LB_STATUS_ERROR_INVALID;
1913 return master_rpc_request_only(handler, packet);
1916 EAPI int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
1918 struct packet *packet;
1919 struct cb_info *cbinfo;
1924 ErrPrint("Handler is NIL\n");
1925 return LB_STATUS_ERROR_INVALID;
1928 if (handler->state != CREATE || !handler->id) {
1929 ErrPrint("Invalid handle\n");
1930 return LB_STATUS_ERROR_INVALID;
1933 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
1934 ErrPrint("Handler is not valid type\n");
1935 return LB_STATUS_ERROR_INVALID;
1938 id = fb_id(handler->pd.data.fb);
1939 if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
1940 return LB_STATUS_ERROR_INVALID;
1942 packet = packet_create("pd_acquire_pixmap", "ss", handler->pkgname, handler->id);
1944 ErrPrint("Failed to build a param\n");
1945 return LB_STATUS_ERROR_FAULT;
1948 cbinfo = create_cb_info(cb, data);
1950 packet_destroy(packet);
1951 return LB_STATUS_ERROR_FAULT;
1954 ret = master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, cbinfo);
1956 destroy_cb_info(cbinfo);
1961 EAPI int livebox_pd_pixmap(const struct livebox *handler)
1967 ErrPrint("Handler is NIL\n");
1971 if (handler->state != CREATE || !handler->id) {
1972 ErrPrint("Invalid handler\n");
1976 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
1977 ErrPrint("Invalid handler\n");
1981 id = fb_id(handler->pd.data.fb);
1982 if (id && sscanf(id, SCHEMA_PIXMAP "%d", &pixmap) != 1) {
1983 ErrPrint("PIXMAP Id is not valid\n");
1990 EAPI int livebox_lb_pixmap(const struct livebox *handler)
1996 ErrPrint("Handler is NIL\n");
2000 if (handler->state != CREATE || !handler->id) {
2001 ErrPrint("Invalid handler\n");
2005 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
2006 ErrPrint("Invalid handler\n");
2010 id = fb_id(handler->lb.data.fb);
2011 if (id && sscanf(id, SCHEMA_PIXMAP "%d", &pixmap) != 1) {
2012 ErrPrint("PIXMAP Id is not valid\n");
2019 EAPI int livebox_release_pd_pixmap(struct livebox *handler, int pixmap)
2021 struct packet *packet;
2024 ErrPrint("Handler is NIL\n");
2025 return LB_STATUS_ERROR_INVALID;
2028 if (handler->state != CREATE || !handler->id) {
2029 ErrPrint("Invalid handle\n");
2030 return LB_STATUS_ERROR_INVALID;
2033 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
2034 ErrPrint("Handler is not valid type\n");
2035 return LB_STATUS_ERROR_INVALID;
2038 packet = packet_create_noack("pd_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap);
2040 ErrPrint("Failed to build a param\n");
2041 return LB_STATUS_ERROR_FAULT;
2044 return master_rpc_request_only(handler, packet);
2047 EAPI void *livebox_acquire_fb(struct livebox *handler)
2050 ErrPrint("Handler is NIL\n");
2054 if (handler->state != CREATE || !handler->id) {
2055 ErrPrint("Invalid handle\n");
2059 if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
2060 ErrPrint("Handler is not valid type\n");
2064 return fb_acquire_buffer(handler->lb.data.fb);
2067 EAPI int livebox_release_fb(void *buffer)
2069 return fb_release_buffer(buffer);
2072 EAPI int livebox_fb_refcnt(void *buffer)
2074 return fb_refcnt(buffer);
2077 EAPI void *livebox_acquire_pdfb(struct livebox *handler)
2080 ErrPrint("Handler is NIL\n");
2084 if (handler->state != CREATE || !handler->id) {
2085 ErrPrint("Invalid handler\n");
2089 if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
2090 ErrPrint("Handler is not valid type\n");
2094 return fb_acquire_buffer(handler->pd.data.fb);
2097 EAPI int livebox_release_pdfb(void *buffer)
2099 return fb_release_buffer(buffer);
2102 EAPI int livebox_pdfb_refcnt(void *buffer)
2104 return fb_refcnt(buffer);
2107 EAPI int livebox_pdfb_bufsz(struct livebox *handler)
2110 ErrPrint("Handler is NIL\n");
2111 return LB_STATUS_ERROR_INVALID;
2114 if (handler->state != CREATE || !handler->id) {
2115 ErrPrint("Handler is not valid\n");
2116 return LB_STATUS_ERROR_INVALID;
2119 return fb_size(handler->pd.data.fb);
2122 EAPI int livebox_lbfb_bufsz(struct livebox *handler)
2125 ErrPrint("Handler is NIL\n");
2126 return LB_STATUS_ERROR_INVALID;
2129 if (handler->state != CREATE || !handler->id) {
2130 ErrPrint("Handler is not valid\n");
2131 return LB_STATUS_ERROR_INVALID;
2134 return fb_size(handler->lb.data.fb);
2137 EAPI int livebox_is_user(struct livebox *handler)
2140 ErrPrint("Handler is NIL\n");
2141 return LB_STATUS_ERROR_INVALID;
2144 if (handler->state != CREATE) {
2145 ErrPrint("Handler is invalid\n");
2146 return LB_STATUS_ERROR_INVALID;
2149 return handler->is_user;
2152 EAPI int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void *data)
2154 struct packet *packet;
2158 ErrPrint("Handler is NIL\n");
2159 return LB_STATUS_ERROR_INVALID;
2162 if (handler->state != CREATE || !handler->id) {
2163 ErrPrint("Handler is not valid\n");
2164 return LB_STATUS_ERROR_INVALID;
2167 if (handler->pinup_cb) {
2168 ErrPrint("Previous pinup request is not finished\n");
2169 return LB_STATUS_ERROR_BUSY;
2172 if (handler->is_pinned_up == flag) {
2173 DbgPrint("No changes\n");
2174 return LB_STATUS_ERROR_ALREADY;
2177 packet = packet_create("pinup_changed", "ssi", handler->pkgname, handler->id, flag);
2179 ErrPrint("Failed to build a param\n");
2180 return LB_STATUS_ERROR_FAULT;
2184 cb = default_pinup_cb;
2186 ret = master_rpc_async_request(handler, packet, 0, pinup_done_cb, NULL);
2187 if (ret == LB_STATUS_SUCCESS) {
2188 handler->pinup_cb = cb;
2189 handler->pinup_cbdata = data;
2195 EAPI int livebox_is_pinned_up(struct livebox *handler)
2198 ErrPrint("Handler is NIL\n");
2199 return LB_STATUS_ERROR_INVALID;
2202 if (handler->state != CREATE || !handler->id)
2203 return LB_STATUS_ERROR_INVALID;
2205 return handler->is_pinned_up;
2208 EAPI int livebox_has_pinup(struct livebox *handler)
2211 ErrPrint("Handler is NIL\n");
2212 return LB_STATUS_ERROR_INVALID;
2215 if (handler->state != CREATE || !handler->id)
2216 return LB_STATUS_ERROR_INVALID;
2218 return handler->lb.pinup_supported;
2221 EAPI int livebox_set_data(struct livebox *handler, void *data)
2224 ErrPrint("Handler is NIL\n");
2225 return LB_STATUS_ERROR_INVALID;
2228 if (handler->state != CREATE)
2229 return LB_STATUS_ERROR_INVALID;
2231 handler->data = data;
2232 return LB_STATUS_SUCCESS;
2235 EAPI void *livebox_get_data(struct livebox *handler)
2238 ErrPrint("Handler is NIL\n");
2242 if (handler->state != CREATE)
2245 return handler->data;
2248 EAPI int livebox_is_exists(const char *pkgname)
2252 lb = lb_pkgname(pkgname);
2261 EAPI const char *livebox_content(struct livebox *handler)
2264 ErrPrint("Handler is NIL\n");
2268 if (handler->state != CREATE)
2271 return handler->content;
2274 EAPI const char *livebox_category_title(struct livebox *handler)
2277 ErrPrint("Handler is NIL\n");
2281 if (handler->state != CREATE)
2284 return handler->title;
2287 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)
2289 struct packet *packet;
2290 struct cb_info *cbinfo;
2294 ErrPrint("Handler is NIL\n");
2295 return LB_STATUS_ERROR_INVALID;
2298 if ((handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || handler->state != CREATE || !handler->id) {
2299 ErrPrint("Handler is not valid\n");
2300 return LB_STATUS_ERROR_INVALID;
2309 packet = packet_create("text_signal", "ssssdddd",
2310 handler->pkgname, handler->id, emission, source, sx, sy, ex, ey);
2312 ErrPrint("Failed to build a param\n");
2313 return LB_STATUS_ERROR_FAULT;
2316 cbinfo = create_cb_info(cb, data);
2318 packet_destroy(packet);
2319 return LB_STATUS_ERROR_FAULT;
2322 ret = master_rpc_async_request(handler, packet, 0, text_signal_cb, cbinfo);
2324 destroy_cb_info(cbinfo);
2326 return LB_STATUS_ERROR_FAULT;
2329 EAPI int livebox_subscribe_group(const char *cluster, const char *category)
2331 struct packet *packet;
2335 * Validate the group info using DB
2336 * If the group info is not valid, do not send this request
2339 packet = packet_create_noack("subscribe", "ss", cluster ? cluster : "", category ? category : "");
2341 ErrPrint("Failed to create a packet\n");
2342 return LB_STATUS_ERROR_FAULT;
2345 return master_rpc_request_only(NULL, packet);
2348 EAPI int livebox_unsubscribe_group(const char *cluster, const char *category)
2350 struct packet *packet;
2354 * Validate the group info using DB
2355 * If the group info is not valid, do not send this request
2356 * AND Check the subscribed or not too
2359 packet = packet_create_noack("unsubscribe", "ss", cluster ? cluster : "", category ? category : "");
2361 ErrPrint("Failed to create a packet\n");
2362 return LB_STATUS_ERROR_FAULT;
2365 return master_rpc_request_only(NULL, packet);
2368 EAPI int livebox_refresh(struct livebox *handler)
2370 struct packet *packet;
2373 ErrPrint("Hnalder is NIL\n");
2374 return LB_STATUS_ERROR_INVALID;
2377 if (handler->state != CREATE || !handler->id)
2378 return LB_STATUS_ERROR_INVALID;
2380 packet = packet_create_noack("update", "ss", handler->pkgname, handler->id);
2382 ErrPrint("Failed to create a packet\n");
2383 return LB_STATUS_ERROR_FAULT;
2386 return master_rpc_request_only(handler, packet);
2389 EAPI int livebox_refresh_group(const char *cluster, const char *category)
2391 struct packet *packet;
2393 if (!cluster || !category) {
2394 ErrPrint("Invalid argument\n");
2395 return LB_STATUS_ERROR_INVALID;
2398 packet = packet_create_noack("refresh_group", "ss", cluster, category);
2400 ErrPrint("Failed to create a packet\n");
2401 return LB_STATUS_ERROR_FAULT;
2404 return master_rpc_request_only(NULL, packet);
2407 EAPI int livebox_set_visibility(struct livebox *handler, enum livebox_visible_state state)
2409 struct packet *packet;
2413 ErrPrint("Handler is NIL\n");
2414 return LB_STATUS_ERROR_INVALID;
2417 if (handler->state != CREATE || !handler->id)
2418 return LB_STATUS_ERROR_INVALID;
2420 if (!handler->is_user) {
2421 /* System cluster livebox cannot be changed its visible states */
2422 if (state == LB_HIDE_WITH_PAUSE) {
2423 ErrPrint("CA Livebox is not able to change the visibility\n");
2424 return LB_STATUS_ERROR_PERMISSION;
2428 if (handler->visible == state)
2429 return LB_STATUS_ERROR_ALREADY;
2431 packet = packet_create_noack("change,visibility", "ssi", handler->pkgname, handler->id, (int)state);
2433 ErrPrint("Failed to create a packet\n");
2434 return LB_STATUS_ERROR_FAULT;
2437 ret = master_rpc_request_only(handler, packet);
2439 handler->visible = state;
2444 EAPI enum livebox_visible_state livebox_visibility(struct livebox *handler)
2447 ErrPrint("Handler is NIL\n");
2448 return LB_VISIBLE_ERROR;
2451 if (handler->state != CREATE || !handler->id)
2452 return LB_VISIBLE_ERROR;
2454 return handler->visible;
2457 int lb_set_group(struct livebox *handler, const char *cluster, const char *category)
2463 pc = strdup(cluster);
2465 CRITICAL_LOG("Heap: %s (cluster: %s)\n", strerror(errno), cluster);
2466 return LB_STATUS_ERROR_MEMORY;
2471 ps = strdup(category);
2473 CRITICAL_LOG("Heap: %s (category: %s)\n", strerror(errno), category);
2475 return LB_STATUS_ERROR_MEMORY;
2479 if (handler->cluster)
2480 free(handler->cluster);
2482 if (handler->category)
2483 free(handler->category);
2485 handler->cluster = pc;
2486 handler->category = ps;
2488 return LB_STATUS_SUCCESS;
2491 void lb_set_size(struct livebox *handler, int w, int h)
2493 handler->lb.width = w;
2494 handler->lb.height = h;
2497 void lb_set_update_mode(struct livebox *handle, int active_mode)
2499 handle->is_active_update = active_mode;
2502 void lb_set_pdsize(struct livebox *handler, int w, int h)
2504 handler->pd.width = w;
2505 handler->pd.height = h;
2508 void lb_set_default_pdsize(struct livebox *handler, int w, int h)
2510 handler->pd.default_width = w;
2511 handler->pd.default_height = h;
2514 void lb_invoke_fault_handler(enum livebox_fault_type event, const char *pkgname, const char *file, const char *func)
2518 struct fault_info *info;
2520 dlist_foreach_safe(s_info.fault_list, l, n, info) {
2521 if (info->handler(event, pkgname, file, func, info->user_data) == EXIT_FAILURE)
2522 s_info.fault_list = dlist_remove(s_info.fault_list, l);
2526 void lb_invoke_event_handler(struct livebox *handler, enum livebox_event_type event)
2530 struct event_info *info;
2532 dlist_foreach_safe(s_info.event_list, l, n, info) {
2533 if (info->handler(handler, event, info->user_data) == EXIT_FAILURE)
2534 s_info.event_list = dlist_remove(s_info.event_list, l);
2538 struct livebox *lb_find_livebox(const char *pkgname, const char *id)
2541 struct livebox *handler;
2543 dlist_foreach(s_info.livebox_list, l, handler) {
2547 if (!strcmp(handler->pkgname, pkgname) && !strcmp(handler->id, id))
2554 struct livebox *lb_find_livebox_by_timestamp(double timestamp)
2557 struct livebox *handler;
2559 dlist_foreach(s_info.livebox_list, l, handler) {
2560 if (handler->timestamp == timestamp)
2567 static inline char *get_file_kept_in_safe(const char *id)
2574 path = util_uri_to_path(id);
2576 ErrPrint("Invalid URI(%s)\n", id);
2583 if (s_info.prevent_overwrite) {
2584 new_path = strdup(path);
2586 ErrPrint("Heap: %s\n", strerror(errno));
2595 while (base_idx > 0 && path[base_idx] != '/') base_idx--;
2596 base_idx += (path[base_idx] == '/');
2598 new_path = malloc(len + 10);
2600 ErrPrint("Heap: %s\n", strerror(errno));
2604 strncpy(new_path, path, base_idx);
2605 snprintf(new_path + base_idx, len + 10 - base_idx, "reader/%s", path + base_idx);
2609 struct livebox *lb_new_livebox(const char *pkgname, const char *id, double timestamp)
2611 struct livebox *handler;
2613 handler = calloc(1, sizeof(*handler));
2615 ErrPrint("Failed to create a new livebox\n");
2619 handler->pkgname = strdup(pkgname);
2620 if (!handler->pkgname) {
2621 ErrPrint("%s\n", strerror(errno));
2626 handler->id = strdup(id);
2628 ErrPrint("%s\n", strerror(errno));
2629 free(handler->pkgname);
2634 handler->filename = get_file_kept_in_safe(id);
2635 if (!handler->filename) {
2636 handler->filename = strdup(util_uri_to_path(id));
2637 if (!handler->filename)
2638 ErrPrint("Error: %s\n", strerror(errno));
2641 handler->timestamp = timestamp;
2642 handler->lb.type = _LB_TYPE_FILE;
2643 handler->pd.type = _PD_TYPE_SCRIPT;
2644 handler->state = CREATE;
2645 handler->visible = LB_SHOW;
2647 s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
2652 int lb_delete_all(void)
2656 struct livebox *handler;
2658 dlist_foreach_safe(s_info.livebox_list, l, n, handler) {
2659 lb_invoke_event_handler(handler, LB_EVENT_DELETED);
2663 return LB_STATUS_SUCCESS;
2666 int lb_set_content(struct livebox *handler, const char *content)
2668 if (handler->content) {
2669 free(handler->content);
2670 handler->content = NULL;
2674 handler->content = strdup(content);
2675 if (!handler->content) {
2676 CRITICAL_LOG("Heap: %s (content: %s)\n", strerror(errno), content);
2677 return LB_STATUS_ERROR_MEMORY;
2681 return LB_STATUS_SUCCESS;
2684 int lb_set_title(struct livebox *handler, const char *title)
2686 if (handler->title) {
2687 free(handler->title);
2688 handler->title = NULL;
2692 handler->title = strdup(title);
2693 if (!handler->title) {
2694 CRITICAL_LOG("Heap: %s (title: %s)\n", strerror(errno), title);
2695 return LB_STATUS_ERROR_MEMORY;
2699 return LB_STATUS_SUCCESS;
2702 void lb_set_size_list(struct livebox *handler, int size_list)
2704 handler->lb.size_list = size_list;
2707 void lb_set_auto_launch(struct livebox *handler, const char *auto_launch)
2709 if (!strlen(auto_launch))
2712 handler->lb.auto_launch = strdup(auto_launch);
2713 if (!handler->lb.auto_launch)
2714 ErrPrint("Heap: %s\n", strerror(errno));
2717 void lb_set_priority(struct livebox *handler, double priority)
2719 handler->lb.priority = priority;
2722 void lb_set_id(struct livebox *handler, const char *id)
2727 handler->id = strdup(id);
2729 ErrPrint("Error: %s\n", strerror(errno));
2731 if (handler->filename)
2732 free(handler->filename);
2734 handler->filename = get_file_kept_in_safe(id);
2735 if (!handler->filename) {
2736 handler->filename = strdup(util_uri_to_path(id));
2737 if (!handler->filename)
2738 ErrPrint("Error: %s\n", strerror(errno));
2742 int lb_set_lb_fb(struct livebox *handler, const char *filename)
2747 return LB_STATUS_ERROR_INVALID;
2749 fb = handler->lb.data.fb;
2750 if (fb && !strcmp(fb_id(fb), filename)) /*!< BUFFER is not changed, */
2751 return LB_STATUS_SUCCESS;
2753 handler->lb.data.fb = NULL;
2755 if (!filename || filename[0] == '\0') {
2758 return LB_STATUS_SUCCESS;
2761 handler->lb.data.fb = fb_create(filename, handler->lb.width, handler->lb.height);
2762 if (!handler->lb.data.fb) {
2763 ErrPrint("Faield to create a FB\n");
2766 return LB_STATUS_ERROR_FAULT;
2772 return LB_STATUS_SUCCESS;
2775 int lb_set_pd_fb(struct livebox *handler, const char *filename)
2780 return LB_STATUS_ERROR_INVALID;
2782 fb = handler->pd.data.fb;
2783 if (fb && !strcmp(fb_id(fb), filename)) {
2784 /* BUFFER is not changed, just update the content */
2785 return LB_STATUS_ERROR_EXIST;
2787 handler->pd.data.fb = NULL;
2789 if (!filename || filename[0] == '\0') {
2792 return LB_STATUS_SUCCESS;
2795 handler->pd.data.fb = fb_create(filename, handler->pd.width, handler->pd.height);
2796 if (!handler->pd.data.fb) {
2797 ErrPrint("Failed to create a FB\n");
2800 return LB_STATUS_ERROR_FAULT;
2805 return LB_STATUS_SUCCESS;
2808 struct fb_info *lb_get_lb_fb(struct livebox *handler)
2810 return handler->lb.data.fb;
2813 struct fb_info *lb_get_pd_fb(struct livebox *handler)
2815 return handler->pd.data.fb;
2818 void lb_set_user(struct livebox *handler, int user)
2820 handler->is_user = user;
2823 void lb_set_pinup(struct livebox *handler, int pinup_supported)
2825 handler->lb.pinup_supported = pinup_supported;
2828 void lb_set_text_lb(struct livebox *handler)
2830 handler->lb.type = _LB_TYPE_TEXT;
2833 void lb_set_text_pd(struct livebox *handler)
2835 handler->pd.type = _PD_TYPE_TEXT;
2838 int lb_text_lb(struct livebox *handler)
2840 return handler->lb.type == _LB_TYPE_TEXT;
2843 int lb_text_pd(struct livebox *handler)
2845 return handler->pd.type == _PD_TYPE_TEXT;
2848 void lb_set_period(struct livebox *handler, double period)
2850 handler->lb.period = period;
2853 struct livebox *lb_ref(struct livebox *handler)
2862 struct livebox *lb_unref(struct livebox *handler)
2868 if (handler->refcnt > 0)
2871 if (handler->created_cb) {
2872 handler->created_cb(handler, LB_STATUS_ERROR_FAULT, handler->created_cbdata);
2873 handler->created_cb = NULL;
2874 handler->created_cbdata = NULL;
2877 if (handler->deleted_cb) {
2878 handler->deleted_cb(handler, LB_STATUS_ERROR_FAULT, handler->deleted_cbdata);
2879 handler->deleted_cb = NULL;
2880 handler->deleted_cbdata = NULL;
2883 if (handler->pinup_cb) {
2884 handler->pinup_cb(handler, LB_STATUS_ERROR_FAULT, handler->pinup_cbdata);
2885 handler->pinup_cb = NULL;
2886 handler->pinup_cbdata = NULL;
2889 if (handler->group_changed_cb) {
2890 handler->group_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->group_cbdata);
2891 handler->group_changed_cb = NULL;
2892 handler->group_cbdata = NULL;
2895 if (handler->period_changed_cb) {
2896 handler->period_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->period_cbdata);
2897 handler->period_changed_cb = NULL;
2898 handler->period_cbdata = NULL;
2901 if (handler->size_changed_cb) {
2902 handler->size_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->size_cbdata);
2903 handler->size_changed_cb = NULL;
2904 handler->size_cbdata = NULL;
2907 if (handler->pd_created_cb) {
2908 handler->pd_created_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_created_cbdata);
2909 handler->pd_created_cb = NULL;
2910 handler->pd_created_cbdata = NULL;
2913 if (handler->pd_destroyed_cb) {
2914 handler->pd_destroyed_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_destroyed_cbdata);
2915 handler->pd_destroyed_cb = NULL;
2916 handler->pd_destroyed_cbdata = NULL;
2919 if (handler->update_mode_cb) {
2920 handler->update_mode_cb(handler, LB_STATUS_ERROR_FAULT, handler->update_mode_cbdata);
2921 handler->update_mode_cb = NULL;
2922 handler->update_mode_cbdata = NULL;
2925 if (handler->access_event_cb) {
2926 handler->access_event_cb(handler, LB_STATUS_ERROR_FAULT, handler->access_event_cbdata);
2927 handler->access_event_cb = NULL;
2928 handler->access_event_cbdata = NULL;
2931 if (handler->filename)
2932 util_unlink(handler->filename);
2934 dlist_remove_data(s_info.livebox_list, handler);
2936 handler->state = DESTROYED;
2937 free(handler->cluster);
2938 free(handler->category);
2940 free(handler->pkgname);
2941 free(handler->filename);
2942 free(handler->lb.auto_launch);
2944 if (handler->lb.data.fb) {
2945 fb_destroy(handler->lb.data.fb);
2946 handler->lb.data.fb = NULL;
2949 if (handler->pd.data.fb) {
2950 fb_destroy(handler->pd.data.fb);
2951 handler->pd.data.fb = NULL;
2958 int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data)
2960 struct packet *packet;
2961 struct cb_info *cbinfo;
2964 if (!cb && !!data) {
2965 ErrPrint("Invalid argument\n");
2966 return LB_STATUS_ERROR_INVALID;
2969 if (handler->deleted_cb) {
2970 ErrPrint("Already in-progress\n");
2971 return LB_STATUS_ERROR_BUSY;
2974 packet = packet_create("delete", "ss", handler->pkgname, handler->id);
2976 ErrPrint("Failed to build a param\n");
2978 cb(handler, LB_STATUS_ERROR_FAULT, data);
2980 return LB_STATUS_ERROR_FAULT;
2984 cb = default_delete_cb;
2986 cbinfo = create_cb_info(cb, data);
2988 packet_destroy(packet);
2989 return LB_STATUS_ERROR_FAULT;
2992 ret = master_rpc_async_request(handler, packet, 0, del_ret_cb, cbinfo);
2994 destroy_cb_info(cbinfo);
2999 EAPI int livebox_client_paused(void)
3001 struct packet *packet;
3003 packet = packet_create_noack("client_paused", "d", util_timestamp());
3005 ErrPrint("Failed to create a pause packet\n");
3006 return LB_STATUS_ERROR_FAULT;
3009 return master_rpc_request_only(NULL, packet);
3012 EAPI int livebox_client_resumed(void)
3014 struct packet *packet;
3016 packet = packet_create_noack("client_resumed", "d", util_timestamp());
3018 ErrPrint("Failed to create a resume packet\n");
3019 return LB_STATUS_ERROR_FAULT;
3022 return master_rpc_request_only(NULL, packet);