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 */
22 #include <unistd.h> /* access */
27 #include <livebox-service.h>
29 #include <provider_buffer.h>
30 #include <livebox-errno.h>
37 #define PUBLIC __attribute__((visibility("default")))
39 #define FILE_SCHEMA "file://"
41 /* Must has to sync'd with data-provider-slave */
48 double minimum_period;
63 double default_packet_time;
68 char *default_content;
71 unsigned long minimum_space;
76 double slave_activate_time;
77 double slave_relaunch_time;
78 int slave_relaunch_count;
83 unsigned long sqlite_flush_max;
106 char *provider_method;
108 int overwrite_content;
115 * \brief This function is defined by the data-provider-slave
118 const char *(*find_pkgname)(const char *filename);
119 int (*request_update_by_id)(const char *uri);
120 int (*trigger_update_monitor)(const char *id, int is_pd);
121 int (*update_extra_info)(const char *id, const char *content, const char *title, const char *icon, const char *name);
124 .find_pkgname = NULL,
125 .request_update_by_id = NULL,
126 .trigger_update_monitor = NULL,
127 .update_extra_info = NULL,
143 struct livebox_desc {
147 unsigned int last_idx;
149 struct dlist *block_list;
152 struct livebox_buffer_data {
156 /* for Buffer event wrapper */
157 int (*handler_NEW)(struct livebox_buffer *, struct buffer_event_data *, void *);
158 int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *);
167 PUBLIC const int DONE = 0x00;
168 PUBLIC const int OUTPUT_UPDATED = 0x02;
169 PUBLIC const int USE_NET = 0x04;
171 PUBLIC const int NEED_TO_SCHEDULE = 0x01;
172 PUBLIC const int NEED_TO_CREATE = 0x01;
173 PUBLIC const int NEED_TO_DESTROY = 0x01;
174 PUBLIC const int NEED_TO_UPDATE = 0x01;
175 PUBLIC const int FORCE_TO_SCHEDULE = 0x08;
177 PUBLIC const int LB_SYS_EVENT_FONT_CHANGED = 0x01;
178 PUBLIC const int LB_SYS_EVENT_LANG_CHANGED = 0x02;
179 PUBLIC const int LB_SYS_EVENT_TIME_CHANGED = 0x04;
180 PUBLIC const int LB_SYS_EVENT_REGION_CHANGED = 0x08;
181 PUBLIC const int LB_SYS_EVENT_PAUSED = 0x0100;
182 PUBLIC const int LB_SYS_EVENT_RESUMED = 0x0200;
183 PUBLIC const int LB_SYS_EVENT_MMC_STATUS_CHANGED = 0x0400;
185 static char *id_to_uri(const char *id)
190 uri_len = strlen(id) + strlen(FILE_SCHEMA) + 1;
192 uri = malloc(uri_len);
197 snprintf(uri, uri_len, FILE_SCHEMA "%s", id);
201 PUBLIC struct livebox_desc *livebox_desc_open(const char *filename, int for_pd)
203 struct livebox_desc *handle;
206 handle = calloc(1, sizeof(*handle));
208 ErrPrint("Error: %s\n", strerror(errno));
214 len = strlen(filename) + strlen(".desc") + 1;
215 new_fname = malloc(len);
217 ErrPrint("Error: %s\n", strerror(errno));
221 snprintf(new_fname, len, "%s.desc", filename);
223 new_fname = strdup(filename);
225 ErrPrint("Error: %s\n", strerror(errno));
231 DbgPrint("Open a file %s with merge mode %s\n",
233 access(new_fname, F_OK) == 0 ? "enabled" : "disabled");
235 handle->fp = fopen(new_fname, "at");
238 ErrPrint("Failed to open a file: %s\n", strerror(errno));
246 PUBLIC int livebox_desc_close(struct livebox_desc *handle)
253 return LB_STATUS_ERROR_INVALID;
256 dlist_foreach_safe(handle->block_list, l, n, block) {
257 handle->block_list = dlist_remove(handle->block_list, l);
259 fprintf(handle->fp, "{\n");
261 fprintf(handle->fp, "type=%s\n", block->type);
265 fprintf(handle->fp, "part=%s\n", block->part);
269 fprintf(handle->fp, "data=%s\n", block->data);
273 fprintf(handle->fp, "option=%s\n", block->option);
277 fprintf(handle->fp, "id=%s\n", block->id);
280 if (block->target_id) {
281 fprintf(handle->fp, "target=%s\n", block->target_id);
283 fprintf(handle->fp, "}\n");
290 free(block->target_id);
294 if (fclose(handle->fp) != 0) {
295 ErrPrint("fclose: %s\n", strerror(errno));
298 return LB_STATUS_SUCCESS;
301 PUBLIC int livebox_desc_set_category(struct livebox_desc *handle, const char *id, const char *category)
305 if (!handle || !category) {
306 return LB_STATUS_ERROR_INVALID;
309 block = calloc(1, sizeof(*block));
311 return LB_STATUS_ERROR_MEMORY;
314 block->type = strdup(LB_DESC_TYPE_INFO);
317 return LB_STATUS_ERROR_MEMORY;
320 block->part = strdup("category");
324 return LB_STATUS_ERROR_MEMORY;
327 block->data = strdup(category);
332 return LB_STATUS_ERROR_MEMORY;
336 block->id = strdup(id);
342 return LB_STATUS_ERROR_MEMORY;
346 block->idx = handle->last_idx++;
347 handle->block_list = dlist_append(handle->block_list, block);
351 PUBLIC int livebox_desc_set_size(struct livebox_desc *handle, const char *id, int w, int h)
357 return LB_STATUS_ERROR_INVALID;
360 block = calloc(1, sizeof(*block));
362 return LB_STATUS_ERROR_MEMORY;
365 block->type = strdup(LB_DESC_TYPE_INFO);
368 return LB_STATUS_ERROR_MEMORY;
371 block->part = strdup("size");
375 return LB_STATUS_ERROR_MEMORY;
379 block->id = strdup(id);
384 return LB_STATUS_ERROR_MEMORY;
388 snprintf(buffer, sizeof(buffer), "%dx%d", w, h);
389 block->data = strdup(buffer);
394 return LB_STATUS_ERROR_MEMORY;
397 block->idx = handle->last_idx++;
398 handle->block_list = dlist_append(handle->block_list, block);
402 PUBLIC char *livebox_util_nl2br(const char *str)
418 ret = malloc(len + 1);
432 tmp = realloc(ret, len + 1);
459 PUBLIC int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char *id)
464 dlist_foreach(handle->block_list, l, block) {
465 if (block->idx == idx) {
466 if (strcasecmp(block->type, LB_DESC_TYPE_SCRIPT)) {
467 ErrPrint("Invalid block is used\n");
468 return LB_STATUS_ERROR_INVALID;
471 free(block->target_id);
472 block->target_id = NULL;
474 if (!id || !strlen(id)) {
475 return LB_STATUS_SUCCESS;
478 block->target_id = strdup(id);
479 if (!block->target_id) {
480 ErrPrint("Heap: %s\n", strerror(errno));
481 return LB_STATUS_ERROR_MEMORY;
484 return LB_STATUS_SUCCESS;
488 return LB_STATUS_ERROR_NOT_EXIST;
494 PUBLIC int livebox_desc_add_block(struct livebox_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *option)
498 if (!handle || !type) {
499 return LB_STATUS_ERROR_INVALID;
510 block = calloc(1, sizeof(*block));
512 ErrPrint("Heap: %s\n", strerror(errno));
513 return LB_STATUS_ERROR_MEMORY;
516 block->type = strdup(type);
518 ErrPrint("Heap: %s\n", strerror(errno));
520 return LB_STATUS_ERROR_MEMORY;
523 block->part = strdup(part);
525 ErrPrint("Heap: %s\n", strerror(errno));
528 return LB_STATUS_ERROR_MEMORY;
531 block->data = strdup(data);
533 ErrPrint("Heap: %s\n", strerror(errno));
537 return LB_STATUS_ERROR_MEMORY;
541 block->option = strdup(option);
542 if (!block->option) {
543 ErrPrint("Heap: %s\n", strerror(errno));
548 return LB_STATUS_ERROR_MEMORY;
553 block->id = strdup(id);
555 ErrPrint("Heap: %s\n", strerror(errno));
561 return LB_STATUS_ERROR_MEMORY;
565 block->idx = handle->last_idx++;
566 handle->block_list = dlist_append(handle->block_list, block);
570 PUBLIC int livebox_desc_del_block(struct livebox_desc *handle, int idx)
575 if (!handle || idx < 0) {
576 return LB_STATUS_ERROR_INVALID;
579 dlist_foreach(handle->block_list, l, block) {
580 if (block->idx == idx) {
581 handle->block_list = dlist_remove(handle->block_list, l);
587 free(block->target_id);
589 return LB_STATUS_SUCCESS;
593 return LB_STATUS_ERROR_NOT_EXIST;
596 static inline int event_handler_wrapper_NEW(struct livebox_buffer *buffer, struct buffer_event_data *event_info, void *data)
600 struct livebox_buffer_data *cbdata = data;
603 pkgname = provider_buffer_pkgname(buffer);
605 ErrPrint("pkgname is not valid\n");
606 return LB_STATUS_ERROR_INVALID;
609 id = provider_buffer_id(buffer);
611 ErrPrint("id is not valid[%s]\n", pkgname);
612 return LB_STATUS_ERROR_INVALID;
615 if (cbdata->handler_NEW) {
616 ret = cbdata->handler_NEW(buffer, event_info, cbdata->cbdata);
618 ret = LB_STATUS_ERROR_FAULT;
621 switch (event_info->type) {
622 case BUFFER_EVENT_HIGHLIGHT:
623 case BUFFER_EVENT_HIGHLIGHT_NEXT:
624 case BUFFER_EVENT_HIGHLIGHT_PREV:
625 case BUFFER_EVENT_ACTIVATE:
626 case BUFFER_EVENT_ACTION_UP:
627 case BUFFER_EVENT_ACTION_DOWN:
628 case BUFFER_EVENT_SCROLL_UP:
629 case BUFFER_EVENT_SCROLL_MOVE:
630 case BUFFER_EVENT_SCROLL_DOWN:
631 case BUFFER_EVENT_UNHIGHLIGHT:
632 DbgPrint("Accessibility event: %d\n", event_info->type);
634 (void)provider_send_access_status(pkgname, id, LB_ACCESS_STATUS_ERROR);
636 (void)provider_send_access_status(pkgname, id, ret);
639 case BUFFER_EVENT_KEY_UP:
640 case BUFFER_EVENT_KEY_DOWN:
641 case BUFFER_EVENT_KEY_FOCUS_IN:
642 case BUFFER_EVENT_KEY_FOCUS_OUT:
643 DbgPrint("Key event: %d\n", event_info->type);
645 (void)provider_send_key_status(pkgname, id, LB_KEY_STATUS_ERROR);
647 (void)provider_send_key_status(pkgname, id, ret);
659 * The last "data" argument is same with "user_data" which is managed by "provider_set_user_data).
661 static inline int event_handler_wrapper(struct livebox_buffer *buffer, enum buffer_event type, double timestamp, double x, double y, void *data)
665 struct livebox_buffer_data *cbdata = data;
668 pkgname = provider_buffer_pkgname(buffer);
670 ErrPrint("pkgname is not valid\n");
671 return LB_STATUS_ERROR_INVALID;
674 id = provider_buffer_id(buffer);
676 ErrPrint("id is not valid[%s]\n", pkgname);
677 return LB_STATUS_ERROR_INVALID;
680 if (cbdata->handler) {
681 ret = cbdata->handler(buffer, type, timestamp, x, y, cbdata->cbdata);
683 ret = LB_STATUS_ERROR_FAULT;
687 case BUFFER_EVENT_HIGHLIGHT:
688 case BUFFER_EVENT_HIGHLIGHT_NEXT:
689 case BUFFER_EVENT_HIGHLIGHT_PREV:
690 case BUFFER_EVENT_ACTIVATE:
691 case BUFFER_EVENT_ACTION_UP:
692 case BUFFER_EVENT_ACTION_DOWN:
693 case BUFFER_EVENT_SCROLL_UP:
694 case BUFFER_EVENT_SCROLL_MOVE:
695 case BUFFER_EVENT_SCROLL_DOWN:
696 case BUFFER_EVENT_UNHIGHLIGHT:
697 DbgPrint("Accessibility event: %d\n", type);
699 (void)provider_send_access_status(pkgname, id, LB_ACCESS_STATUS_ERROR);
701 (void)provider_send_access_status(pkgname, id, ret);
704 case BUFFER_EVENT_KEY_UP:
705 case BUFFER_EVENT_KEY_DOWN:
706 case BUFFER_EVENT_KEY_FOCUS_IN:
707 case BUFFER_EVENT_KEY_FOCUS_OUT:
708 DbgPrint("Key event: %d\n", type);
710 (void)provider_send_key_status(pkgname, id, LB_KEY_STATUS_ERROR);
712 (void)provider_send_key_status(pkgname, id, ret);
722 static inline int default_event_handler_NEW(struct livebox_buffer *buffer, struct buffer_event_data *event_info, void *data)
728 static inline int default_event_handler(struct livebox_buffer *buffer, enum buffer_event type, double timestamp, double x, double y, void *data)
734 PUBLIC struct livebox_buffer *livebox_acquire_buffer_NEW(const char *filename, int is_pd, int width, int height, int pixels, int (*handler)(struct livebox_buffer *, struct buffer_event_data *, void *), void *data)
736 struct livebox_buffer_data *user_data;
738 struct livebox_buffer *handle;
741 if (!filename || !width || !height) {
742 ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
746 user_data = calloc(1, sizeof(*user_data));
748 ErrPrint("Heap: %s\n", strerror(errno));
752 user_data->is_pd = is_pd;
753 user_data->handler_NEW = handler ? handler : default_event_handler_NEW;
754 user_data->handler = NULL;
755 user_data->cbdata = data;
757 uri = id_to_uri(filename);
759 ErrPrint("Heap: %s\n", strerror(errno));
764 if (!s_info.find_pkgname) {
765 s_info.find_pkgname = dlsym(RTLD_DEFAULT, "livebox_find_pkgname");
766 if (!s_info.find_pkgname) {
767 ErrPrint("Failed to find a \"livebox_find_pkgname\"\n");
774 pkgname = s_info.find_pkgname(uri);
776 ErrPrint("Invalid Request\n");
782 handle = provider_buffer_create((!!is_pd) ? TYPE_PD : TYPE_LB, pkgname, uri, event_handler_wrapper_NEW, user_data);
789 if (provider_buffer_acquire_NEW(handle, width, height, pixels) < 0) {
790 provider_buffer_destroy(handle);
795 (void)provider_buffer_set_user_data(handle, user_data);
799 PUBLIC struct livebox_buffer *livebox_acquire_buffer(const char *filename, int is_pd, int width, int height, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data)
801 struct livebox_buffer_data *user_data;
803 struct livebox_buffer *handle;
806 if (!filename || !width || !height) {
807 ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
811 user_data = calloc(1, sizeof(*user_data));
813 ErrPrint("Heap: %s\n", strerror(errno));
817 user_data->is_pd = is_pd;
818 user_data->handler = handler ? handler : default_event_handler;
819 user_data->handler_NEW = NULL;
820 user_data->cbdata = data;
822 uri = id_to_uri(filename);
824 ErrPrint("Heap: %s\n", strerror(errno));
829 if (!s_info.find_pkgname) {
830 s_info.find_pkgname = dlsym(RTLD_DEFAULT, "livebox_find_pkgname");
831 if (!s_info.find_pkgname) {
832 ErrPrint("Failed to find a \"livebox_find_pkgname\"\n");
839 pkgname = s_info.find_pkgname(uri);
841 ErrPrint("Invalid Request\n");
847 handle = provider_buffer_acquire((!!is_pd) ? TYPE_PD : TYPE_LB, pkgname, uri, width, height, sizeof(int), event_handler_wrapper, user_data);
848 DbgPrint("Acquire buffer for PD(%s), %s, %p\n", pkgname, uri, handle);
855 (void)provider_buffer_set_user_data(handle, user_data);
859 PUBLIC int livebox_request_update(const char *filename)
865 ErrPrint("Invalid argument\n");
866 return LB_STATUS_ERROR_INVALID;
869 uri = id_to_uri(filename);
871 ErrPrint("Heap: %s\n", strerror(errno));
872 return LB_STATUS_ERROR_MEMORY;
875 if (!s_info.request_update_by_id) {
876 s_info.request_update_by_id = dlsym(RTLD_DEFAULT, "livebox_request_update_by_id");
877 if (!s_info.request_update_by_id) {
878 ErrPrint("\"livebox_request_update_by_id\" is not exists\n");
880 return LB_STATUS_ERROR_FAULT;
883 ret = s_info.request_update_by_id(uri);
888 PUBLIC int livebox_conf_premultiplied_alpha(void)
891 s_info.conf = dlsym(RTLD_DEFAULT, "g_conf");
893 ErrPrint("g_conf is not found\n");
897 DbgPrint("Premultiplied alpha: %d\n", s_info.conf->premultiplied);
900 return s_info.conf->premultiplied;
903 PUBLIC unsigned long livebox_pixmap_id(struct livebox_buffer *handle)
905 return provider_buffer_pixmap_id(handle);
908 PUBLIC int livebox_release_buffer(struct livebox_buffer *handle)
910 struct livebox_buffer_data *user_data;
913 return LB_STATUS_ERROR_INVALID;
916 user_data = provider_buffer_user_data(handle);
918 free(user_data->content);
919 free(user_data->title);
920 free(user_data->icon);
921 free(user_data->name);
923 provider_buffer_set_user_data(handle, NULL);
926 DbgPrint("Release buffer\n");
927 return provider_buffer_release(handle);
930 PUBLIC int livebox_release_buffer_NEW(struct livebox_buffer *handle)
932 struct livebox_buffer_data *user_data;
935 return LB_STATUS_ERROR_INVALID;
938 user_data = provider_buffer_user_data(handle);
940 free(user_data->content);
941 free(user_data->title);
942 free(user_data->icon);
943 free(user_data->name);
945 provider_buffer_set_user_data(handle, NULL);
948 (void)provider_buffer_release_NEW(handle);
949 (void)provider_buffer_destroy(handle);
951 DbgPrint("Release buffer\n");
955 PUBLIC void *livebox_ref_buffer(struct livebox_buffer *handle)
957 struct livebox_buffer_data *user_data;
966 user_data = provider_buffer_user_data(handle);
971 if (user_data->accelerated) {
972 DbgPrint("H/W accelerated buffer is allocated\n");
976 ret = provider_buffer_get_size(handle, &w, &h, &size);
978 data = provider_buffer_ref(handle);
979 if (data && !ret && w > 0 && h > 0 && size > 0) {
980 memset(data, 0, w * h * size);
981 (void)provider_buffer_sync(handle);
984 DbgPrint("Ref buffer %ds%d(%d)\n", w, h, size);
988 PUBLIC int livebox_unref_buffer(void *buffer)
991 return LB_STATUS_ERROR_INVALID;
994 DbgPrint("Unref buffer\n");
995 return provider_buffer_unref(buffer);
998 PUBLIC int livebox_sync_buffer(struct livebox_buffer *handle)
1000 struct livebox_buffer_data *user_data;
1001 const char *pkgname;
1005 return LB_STATUS_ERROR_INVALID;
1008 user_data = provider_buffer_user_data(handle);
1010 ErrPrint("Invalid buffer\n");
1011 return LB_STATUS_ERROR_INVALID;
1014 if (user_data->accelerated) {
1015 DbgPrint("H/W Buffer allocated. skip the sync buffer\n");
1016 return LB_STATUS_SUCCESS;
1019 pkgname = provider_buffer_pkgname(handle);
1021 ErrPrint("Invalid buffer handler\n");
1022 return LB_STATUS_ERROR_INVALID;
1025 id = provider_buffer_id(handle);
1027 ErrPrint("Invalid buffer handler\n");
1028 return LB_STATUS_ERROR_INVALID;
1031 (void)provider_buffer_sync(handle);
1033 if (user_data->is_pd == 1) {
1034 if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
1035 ErrPrint("Failed to send PD updated (%s)\n", id);
1042 if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) {
1043 ErrPrint("Failed to get size (%s)\n", id);
1046 if (provider_send_updated_NEW(pkgname, id, w, h, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) {
1047 ErrPrint("Failed to send updated (%s)\n", id);
1051 return LB_STATUS_SUCCESS;
1054 PUBLIC int livebox_support_hw_buffer(struct livebox_buffer *handle)
1057 return LB_STATUS_ERROR_INVALID;
1060 return provider_buffer_pixmap_is_support_hw(handle);
1063 PUBLIC int livebox_create_hw_buffer(struct livebox_buffer *handle)
1065 struct livebox_buffer_data *user_data;
1069 return LB_STATUS_ERROR_INVALID;
1072 user_data = provider_buffer_user_data(handle);
1074 return LB_STATUS_ERROR_INVALID;
1077 if (user_data->accelerated) {
1078 return LB_STATUS_ERROR_ALREADY;
1081 ret = provider_buffer_pixmap_create_hw(handle);
1082 user_data->accelerated = (ret == 0);
1086 PUBLIC int livebox_destroy_hw_buffer(struct livebox_buffer *handle)
1088 struct livebox_buffer_data *user_data;
1091 LOGD("handle is NULL\n");
1092 return LB_STATUS_ERROR_INVALID;
1095 user_data = provider_buffer_user_data(handle);
1096 if (!user_data || !user_data->accelerated) {
1097 LOGD("user_data is NULL\n");
1098 return LB_STATUS_ERROR_INVALID;
1101 user_data->accelerated = 0;
1103 return provider_buffer_pixmap_destroy_hw(handle);
1106 PUBLIC void *livebox_buffer_hw_buffer(struct livebox_buffer *handle)
1108 struct livebox_buffer_data *user_data;
1114 user_data = provider_buffer_user_data(handle);
1115 if (!user_data || !user_data->accelerated) {
1119 return provider_buffer_pixmap_hw_addr(handle);
1122 PUBLIC int livebox_buffer_pre_render(struct livebox_buffer *handle)
1124 struct livebox_buffer_data *user_data;
1127 return LB_STATUS_ERROR_INVALID;
1130 user_data = provider_buffer_user_data(handle);
1132 return LB_STATUS_ERROR_INVALID;
1135 if (!user_data->accelerated) {
1136 return LB_STATUS_SUCCESS;
1141 * Do preprocessing for accessing the H/W render buffer
1143 return provider_buffer_pre_render(handle);
1146 PUBLIC int livebox_buffer_post_render(struct livebox_buffer *handle)
1149 const char *pkgname;
1151 struct livebox_buffer_data *user_data;
1154 return LB_STATUS_ERROR_INVALID;
1157 user_data = provider_buffer_user_data(handle);
1159 return LB_STATUS_ERROR_INVALID;
1162 if (!user_data->accelerated) {
1163 return LB_STATUS_SUCCESS;
1166 pkgname = provider_buffer_pkgname(handle);
1168 ErrPrint("Invalid buffer handle\n");
1169 return LB_STATUS_ERROR_INVALID;
1172 id = provider_buffer_id(handle);
1174 ErrPrint("Invalid buffer handler\n");
1175 return LB_STATUS_ERROR_INVALID;
1178 ret = provider_buffer_post_render(handle);
1180 ErrPrint("Failed to post render processing\n");
1184 if (user_data->is_pd == 1) {
1185 if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
1186 ErrPrint("Failed to send PD updated (%s)\n", id);
1193 if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) {
1194 ErrPrint("Failed to get size (%s)\n", id);
1197 if (provider_send_updated_NEW(pkgname, id, w, h, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) {
1198 ErrPrint("Failed to send updated (%s)\n", id);
1202 return LB_STATUS_SUCCESS;
1205 PUBLIC int livebox_content_is_updated(const char *filename, int is_pd)
1207 if (!s_info.trigger_update_monitor) {
1208 s_info.trigger_update_monitor = dlsym(RTLD_DEFAULT, "livebox_trigger_update_monitor");
1209 if (!s_info.trigger_update_monitor) {
1210 ErrPrint("Trigger update monitor function is not exists\n");
1211 return LB_STATUS_ERROR_FAULT;
1215 return s_info.trigger_update_monitor(filename, is_pd);
1218 PUBLIC int livebox_request_close_pd(const char *pkgname, const char *id, int reason)
1221 int schema_len = strlen(FILE_SCHEMA);
1224 if (!pkgname || !id) {
1225 ErrPrint("Invalid parameters (%s) (%s)\n", pkgname, id);
1226 return LB_STATUS_ERROR_INVALID;
1229 if (strncmp(id, FILE_SCHEMA, schema_len)) {
1230 uri = id_to_uri(id);
1232 ErrPrint("Heap: %s\n", strerror(errno));
1233 return LB_STATUS_ERROR_MEMORY;
1238 ErrPrint("Heap: %s\n", strerror(errno));
1239 return LB_STATUS_ERROR_MEMORY;
1243 ret = provider_send_request_close_pd(pkgname, uri, reason);
1248 PUBLIC int livebox_freeze_scroller(const char *pkgname, const char *id)
1253 uri = id_to_uri(id);
1255 ErrPrint("Heap: %s\n", strerror(errno));
1256 return LB_STATUS_ERROR_MEMORY;
1259 ret = provider_send_hold_scroll(pkgname, uri, 1);
1264 PUBLIC int livebox_release_scroller(const char *pkgname, const char *id)
1269 uri = id_to_uri(id);
1271 ErrPrint("Heap: %s\n", strerror(errno));
1272 return LB_STATUS_ERROR_MEMORY;
1275 ret = provider_send_hold_scroll(pkgname, uri, 0);
1280 PUBLIC int livebox_set_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name)
1282 struct livebox_buffer *handle;
1283 const char *pkgname;
1286 uri = id_to_uri(id);
1288 ErrPrint("Heap: %s\n", strerror(errno));
1289 return LB_STATUS_ERROR_MEMORY;
1292 pkgname = s_info.find_pkgname(uri);
1294 ErrPrint("Failed to find a package (%s)\n", uri);
1296 return LB_STATUS_ERROR_INVALID;
1299 handle = provider_buffer_find_buffer(TYPE_LB, pkgname, uri);
1302 struct livebox_buffer_data *user_data;
1304 user_data = provider_buffer_user_data(handle);
1306 ErrPrint("User data is not available\n");
1307 return LB_STATUS_ERROR_FAULT;
1310 if (content && strlen(content)) {
1313 _content = strdup(content);
1315 if (user_data->content) {
1316 free(user_data->content);
1317 user_data->content = NULL;
1320 user_data->content = _content;
1322 ErrPrint("Heap: %s\n", strerror(errno));
1326 if (title && strlen(title)) {
1329 _title = strdup(title);
1331 if (user_data->title) {
1332 free(user_data->title);
1333 user_data->title = NULL;
1336 user_data->title = _title;
1338 ErrPrint("Heap: %s\n", strerror(errno));
1342 if (icon && strlen(icon)) {
1345 _icon = strdup(icon);
1347 if (user_data->icon) {
1348 free(user_data->icon);
1349 user_data->icon = NULL;
1352 user_data->icon = _icon;
1354 ErrPrint("Heap: %s\n", strerror(errno));
1358 if (name && strlen(name)) {
1361 _name = strdup(name);
1363 if (user_data->name) {
1364 free(user_data->name);
1365 user_data->name = NULL;
1368 user_data->name = _name;
1370 ErrPrint("Heap: %s\n", strerror(errno));
1374 return LB_STATUS_SUCCESS;
1377 if (!s_info.update_extra_info) {
1378 s_info.update_extra_info = dlsym(RTLD_DEFAULT, "livebox_update_extra_info");
1379 if (!s_info.update_extra_info) {
1380 ErrPrint("Failed to find a \"livebox_update_extra_info\"\n");
1381 return LB_STATUS_ERROR_INVALID;
1385 return s_info.update_extra_info(id, content, title, icon, name);