Remove unused variable definition
[platform/framework/web/livebox.git] / src / livebox.c
1 /*
2  * Copyright 2013  Samsung Electronics Co., Ltd
3  *
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
7  *
8  * http://floralicense.org/license/
9  *
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.
15  */
16
17 #include <stdio.h>
18 #include <errno.h>
19 #include <stdlib.h> /* malloc */
20 #include <string.h> /* strdup */
21 #include <libgen.h>
22 #include <unistd.h> /* access */
23
24 #include <dlog.h>
25 #include <livebox-service.h>
26 #include <provider.h>
27 #include <provider_buffer.h>
28 #include <livebox-errno.h>
29
30 #include "debug.h"
31 #include "livebox.h"
32 #include "dlist.h"
33 #include "util.h"
34
35 #define PUBLIC __attribute__((visibility("default")))
36
37 #define FILE_SCHEMA     "file://"
38
39 /*!
40  * \brief This function is defined by the data-provider-slave
41  */
42 extern const char *livebox_find_pkgname(const char *filename);
43 extern int livebox_request_update_by_id(const char *uri);
44 extern int livebox_trigger_update_monitor(const char *id, int is_pd);
45
46 struct block {
47         unsigned int idx;
48
49         char *type;
50         char *part;
51         char *data;
52         char *option;
53         char *id;
54         char *file;
55         char *target_id;
56 };
57
58 struct livebox_desc {
59         FILE *fp;
60         int for_pd;
61
62         unsigned int last_idx;
63
64         struct dlist *block_list;
65 };
66
67 struct livebox_buffer_data {
68         int is_pd;
69         int accelerated;
70
71         /* for Buffer event wrapper */
72         int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *);
73         void *cbdata;
74 };
75
76 PUBLIC const int DONE = 0x00;
77 PUBLIC const int OUTPUT_UPDATED = 0x02;
78 PUBLIC const int USE_NET = 0x04;
79
80 PUBLIC const int NEED_TO_SCHEDULE = 0x01;
81 PUBLIC const int NEED_TO_CREATE = 0x01;
82 PUBLIC const int NEED_TO_DESTROY = 0x01;
83 PUBLIC const int NEED_TO_UPDATE = 0x01;
84
85 PUBLIC const int LB_SYS_EVENT_FONT_CHANGED = 0x01;
86 PUBLIC const int LB_SYS_EVENT_LANG_CHANGED = 0x02;
87 PUBLIC const int LB_SYS_EVENT_TIME_CHANGED = 0x04;
88 PUBLIC const int LB_SYS_EVENT_REGION_CHANGED = 0x08;
89 PUBLIC const int LB_SYS_EVENT_PAUSED = 0x0100;
90 PUBLIC const int LB_SYS_EVENT_RESUMED = 0x0200;
91 PUBLIC const int LB_SYS_EVENT_MMC_STATUS_CHANGED = 0x0400;
92
93 PUBLIC struct livebox_desc *livebox_desc_open(const char *filename, int for_pd)
94 {
95         struct livebox_desc *handle;
96         char *new_fname;
97
98         handle = calloc(1, sizeof(*handle));
99         if (!handle) {
100                 ErrPrint("Error: %s\n", strerror(errno));
101                 return NULL;
102         }
103
104         if (for_pd) {
105                 int len;
106                 len = strlen(filename) + strlen(".desc") + 1;
107                 new_fname = malloc(len);
108                 if (!new_fname) {
109                         ErrPrint("Error: %s\n", strerror(errno));
110                         free(handle);
111                         return NULL;
112                 }
113                 snprintf(new_fname, len, "%s.desc", filename);
114         } else {
115                 new_fname = strdup(filename);
116                 if (!new_fname) {
117                         ErrPrint("Error: %s\n", strerror(errno));
118                         free(handle);
119                         return NULL;
120                 }
121         }
122
123         DbgPrint("Open a file %s with merge mode %s\n",
124                                 new_fname,
125                                 access(new_fname, F_OK) == 0 ? "enabled" : "disabled");
126
127         handle->fp = fopen(new_fname, "at");
128         free(new_fname);
129         if (!handle->fp) {
130                 ErrPrint("Failed to open a file: %s\n", strerror(errno));
131                 free(handle);
132                 return NULL;
133         }
134
135         return handle;
136 }
137
138 PUBLIC int livebox_desc_close(struct livebox_desc *handle)
139 {
140         struct dlist *l;
141         struct dlist *n;
142         struct block *block;
143
144         if (!handle) {
145                 return LB_STATUS_ERROR_INVALID;
146         }
147
148         dlist_foreach_safe(handle->block_list, l, n, block) {
149                 handle->block_list = dlist_remove(handle->block_list, l);
150
151                 fprintf(handle->fp, "{\n");
152                 if (block->type) {
153                         fprintf(handle->fp, "type=%s\n", block->type);
154                 }
155
156                 if (block->part) {
157                         fprintf(handle->fp, "part=%s\n", block->part);
158                 }
159
160                 if (block->data) {
161                         fprintf(handle->fp, "data=%s\n", block->data);
162                 }
163
164                 if (block->option) {
165                         fprintf(handle->fp, "option=%s\n", block->option);
166                 }
167
168                 if (block->id) {
169                         fprintf(handle->fp, "id=%s\n", block->id);
170                 }
171
172                 if (block->target_id) {
173                         fprintf(handle->fp, "target=%s\n", block->target_id);
174                 }
175                 fprintf(handle->fp, "}\n");
176
177                 free(block->type);
178                 free(block->part);
179                 free(block->data);
180                 free(block->option);
181                 free(block->id);
182                 free(block->target_id);
183                 free(block);
184         }
185
186         if (fclose(handle->fp) != 0) {
187                 ErrPrint("fclose: %s\n", strerror(errno));
188         }
189         free(handle);
190         return LB_STATUS_SUCCESS;
191 }
192
193 PUBLIC int livebox_desc_set_category(struct livebox_desc *handle, const char *id, const char *category)
194 {
195         struct block *block;
196
197         if (!handle || !category) {
198                 return LB_STATUS_ERROR_INVALID;
199         }
200
201         block = calloc(1, sizeof(*block));
202         if (!block) {
203                 return LB_STATUS_ERROR_MEMORY;
204         }
205
206         block->type = strdup(LB_DESC_TYPE_INFO);
207         if (!block->type) {
208                 free(block);
209                 return LB_STATUS_ERROR_MEMORY;
210         }
211
212         block->part = strdup("category");
213         if (!block->part) {
214                 free(block->type);
215                 free(block);
216                 return LB_STATUS_ERROR_MEMORY;
217         }
218
219         block->data = strdup(category);
220         if (!block->data) {
221                 free(block->type);
222                 free(block->part);
223                 free(block);
224                 return LB_STATUS_ERROR_MEMORY;
225         }
226
227         if (id) {
228                 block->id = strdup(id);
229                 if (!block->id) {
230                         free(block->data);
231                         free(block->type);
232                         free(block->part);
233                         free(block);
234                         return LB_STATUS_ERROR_MEMORY;
235                 }
236         }
237
238         block->idx = handle->last_idx++;
239         handle->block_list = dlist_append(handle->block_list, block);
240         return block->idx;
241 }
242
243 PUBLIC int livebox_desc_set_size(struct livebox_desc *handle, const char *id, int w, int h)
244 {
245         struct block *block;
246         char buffer[BUFSIZ];
247
248         if (!handle) {
249                 return LB_STATUS_ERROR_INVALID;
250         }
251
252         block = calloc(1, sizeof(*block));
253         if (!block) {
254                 return LB_STATUS_ERROR_MEMORY;
255         }
256
257         block->type = strdup(LB_DESC_TYPE_INFO);
258         if (!block->type) {
259                 free(block);
260                 return LB_STATUS_ERROR_MEMORY;
261         }
262
263         block->part = strdup("size");
264         if (!block->part) {
265                 free(block->type);
266                 free(block);
267                 return LB_STATUS_ERROR_MEMORY;
268         }
269
270         if (id) {
271                 block->id = strdup(id);
272                 if (!block->id) {
273                         free(block->part);
274                         free(block->type);
275                         free(block);
276                         return LB_STATUS_ERROR_MEMORY;
277                 }
278         }
279
280         snprintf(buffer, sizeof(buffer), "%dx%d", w, h);
281         block->data = strdup(buffer);
282         if (!block->data) {
283                 free(block->part);
284                 free(block->type);
285                 free(block);
286                 return LB_STATUS_ERROR_MEMORY;
287         }
288
289         block->idx = handle->last_idx++;
290         handle->block_list = dlist_append(handle->block_list, block);
291         return block->idx;
292 }
293
294 PUBLIC char *livebox_util_nl2br(const char *str)
295 {
296         int len;
297         register int i;
298         char *ret;
299         char *ptr;
300
301         if (!str) {
302                 return NULL;
303         }
304
305         len = strlen(str);
306         if (!len) {
307                 return NULL;
308         }
309
310         ret = malloc(len + 1);
311         if (!ret) {
312                 return NULL;
313         }
314
315         ptr = ret;
316         i = 0;
317         while (*str) {
318                 switch (*str) {
319                 case '\n':
320                         if (len - i < 5) {
321                                 char *tmp;
322                                 len += len;
323
324                                 tmp = realloc(ret, len + 1);
325                                 if (!tmp) {
326                                         free(ret);
327                                         return NULL;
328                                 }
329
330                                 ret = tmp;
331                                 ptr = tmp + i;
332                         }
333
334                         strcpy(ptr, "<br>");
335                         ptr += 4;
336                         i += 4;
337                         break;
338                 default:
339                         *ptr++ = *str;
340                         i++;
341                         break;
342                 }
343
344                 str++;
345         }
346         *ptr = '\0';
347
348         return ret;
349 }
350
351 PUBLIC int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char *id)
352 {
353         struct dlist *l;
354         struct block *block;
355
356         dlist_foreach(handle->block_list, l, block) {
357                 if (block->idx == idx) {
358                         if (strcasecmp(block->type, LB_DESC_TYPE_SCRIPT)) {
359                                 ErrPrint("Invalid block is used\n");
360                                 return LB_STATUS_ERROR_INVALID;
361                         }
362
363                         free(block->target_id);
364                         block->target_id = NULL;
365
366                         if (!id || !strlen(id)) {
367                                 return LB_STATUS_SUCCESS;
368                         }
369
370                         block->target_id = strdup(id);
371                         if (!block->target_id) {
372                                 ErrPrint("Heap: %s\n", strerror(errno));
373                                 return LB_STATUS_ERROR_MEMORY;
374                         }
375
376                         return LB_STATUS_SUCCESS;
377                 }
378         }
379
380         return LB_STATUS_ERROR_NOT_EXIST;
381 }
382
383 /*!
384  * \return idx
385  */
386 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)
387 {
388         struct block *block;
389
390         if (!handle || !type) {
391                 return LB_STATUS_ERROR_INVALID;
392         }
393
394         if (!part) {
395                 part = "";
396         }
397
398         if (!data) {
399                 data = "";
400         }
401
402         block = calloc(1, sizeof(*block));
403         if (!block) {
404                 ErrPrint("Heap: %s\n", strerror(errno));
405                 return LB_STATUS_ERROR_MEMORY;
406         }
407
408         block->type = strdup(type);
409         if (!block->type) {
410                 ErrPrint("Heap: %s\n", strerror(errno));
411                 free(block);
412                 return LB_STATUS_ERROR_MEMORY;
413         }
414
415         block->part = strdup(part);
416         if (!block->part) {
417                 ErrPrint("Heap: %s\n", strerror(errno));
418                 free(block->type);
419                 free(block);
420                 return LB_STATUS_ERROR_MEMORY;
421         }
422
423         block->data = strdup(data);
424         if (!block->data) {
425                 ErrPrint("Heap: %s\n", strerror(errno));
426                 free(block->type);
427                 free(block->part);
428                 free(block);
429                 return LB_STATUS_ERROR_MEMORY;
430         }
431
432         if (option) {
433                 block->option = strdup(option);
434                 if (!block->option) {
435                         ErrPrint("Heap: %s\n", strerror(errno));
436                         free(block->data);
437                         free(block->type);
438                         free(block->part);
439                         free(block);
440                         return LB_STATUS_ERROR_MEMORY;
441                 }
442         }
443
444         if (id) {
445                 block->id = strdup(id);
446                 if (!block->id) {
447                         ErrPrint("Heap: %s\n", strerror(errno));
448                         free(block->option);
449                         free(block->data);
450                         free(block->type);
451                         free(block->part);
452                         free(block);
453                         return LB_STATUS_ERROR_MEMORY;
454                 }
455         }
456
457         block->idx = handle->last_idx++;
458         handle->block_list = dlist_append(handle->block_list, block);
459         return block->idx;
460 }
461
462 PUBLIC int livebox_desc_del_block(struct livebox_desc *handle, int idx)
463 {
464         struct dlist *l;
465         struct block *block;
466
467         dlist_foreach(handle->block_list, l, block) {
468                 if (block->idx == idx) {
469                         handle->block_list = dlist_remove(handle->block_list, l);
470                         free(block->type);
471                         free(block->part);
472                         free(block->data);
473                         free(block->option);
474                         free(block->id);
475                         free(block->target_id);
476                         free(block);
477                         return LB_STATUS_SUCCESS;
478                 }
479         }
480
481         return LB_STATUS_ERROR_NOT_EXIST;
482 }
483
484 /*!
485  * \note
486  * The last "data" argument is same with "user_data" which is managed by "provider_set_user_data).
487  */
488 static inline int event_handler_wrapper(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data)
489 {
490         const char *pkgname;
491         const char *id;
492         struct livebox_buffer_data *cbdata = data;
493         int ret;
494
495         pkgname = provider_buffer_pkgname(buffer);
496         if (!pkgname) {
497                 ErrPrint("pkgname is not valid\n");
498                 return LB_STATUS_ERROR_INVALID;
499         }
500
501         id = provider_buffer_id(buffer);
502         if (!id) {
503                 ErrPrint("id is not valid[%s]\n", pkgname);
504                 return LB_STATUS_ERROR_INVALID;
505         }
506
507         ret = cbdata->handler(buffer, event, timestamp, x, y, cbdata->cbdata);
508
509         switch (event) {
510         case BUFFER_EVENT_HIGHLIGHT:
511         case BUFFER_EVENT_HIGHLIGHT_NEXT:
512         case BUFFER_EVENT_HIGHLIGHT_PREV:
513         case BUFFER_EVENT_ACTIVATE:
514         case BUFFER_EVENT_ACTION_UP:
515         case BUFFER_EVENT_ACTION_DOWN:
516         case BUFFER_EVENT_SCROLL_UP:
517         case BUFFER_EVENT_SCROLL_MOVE:
518         case BUFFER_EVENT_SCROLL_DOWN:
519         case BUFFER_EVENT_UNHIGHLIGHT:
520                 DbgPrint("Accessibility event: %d\n", event);
521                 if (ret < 0) {
522                         (void)provider_send_access_status(pkgname, id, LB_ACCESS_STATUS_ERROR);
523                 } else {
524                         (void)provider_send_access_status(pkgname, id, ret);
525                 }
526                 break;
527         default:
528                 break;
529         }
530
531         return ret;
532 }
533
534 static inline int default_event_handler(struct livebox_buffer *buffer, enum buffer_event event, double timestamp, double x, double y, void *data)
535 {
536         /* NOP */
537         return 0;
538 }
539
540 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)
541 {
542         struct livebox_buffer_data *user_data;
543         const char *pkgname;
544         struct livebox_buffer *handle;
545         char *uri;
546         int uri_len;
547
548         if (!filename || !width || !height) {
549                 ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
550                 return NULL;
551         }
552
553         user_data = calloc(1, sizeof(*user_data));
554         if (!user_data) {
555                 ErrPrint("Heap: %s\n", strerror(errno));
556                 return NULL;
557         }
558
559         user_data->is_pd = is_pd;
560         user_data->handler = handler ? handler : default_event_handler;
561         user_data->cbdata = data;
562
563         uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
564         uri = malloc(uri_len);
565         if (!uri) {
566                 ErrPrint("Heap: %s\n", strerror(errno));
567                 free(user_data);
568                 return NULL;
569         }
570
571         snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
572         pkgname = livebox_find_pkgname(uri);
573         if (!pkgname) {
574                 ErrPrint("Invalid Request\n");
575                 free(user_data);
576                 free(uri);
577                 return NULL;
578         }
579
580         handle = provider_buffer_acquire((!!is_pd) ? TYPE_PD : TYPE_LB, pkgname, uri, width, height, sizeof(int), event_handler_wrapper, user_data);
581         DbgPrint("Acquire buffer for PD(%s), %s, %p\n", pkgname, uri, handle);
582         free(uri);
583         if (!handle) {
584                 free(user_data);
585                 return NULL;
586         }
587
588         (void)provider_buffer_set_user_data(handle, user_data);
589         return handle;
590 }
591
592 PUBLIC int livebox_request_update(const char *filename)
593 {
594         int uri_len;
595         char *uri;
596         int ret;
597
598         if (!filename) {
599                 ErrPrint("Invalid argument\n");
600                 return LB_STATUS_ERROR_INVALID;
601         }
602
603         uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
604         uri = malloc(uri_len);
605         if (!uri) {
606                 ErrPrint("Heap: %s\n", strerror(errno));
607                 return LB_STATUS_ERROR_MEMORY;
608         }
609
610         snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
611         ret = livebox_request_update_by_id(uri);
612         free(uri);
613         return ret;
614 }
615
616 PUBLIC unsigned long livebox_pixmap_id(struct livebox_buffer *handle)
617 {
618         return provider_buffer_pixmap_id(handle);
619 }
620
621 PUBLIC int livebox_release_buffer(struct livebox_buffer *handle)
622 {
623         struct livebox_buffer_data *user_data;
624
625         if (!handle) {
626                 return LB_STATUS_ERROR_INVALID;
627         }
628
629         user_data = provider_buffer_user_data(handle);
630         if (user_data) {
631                 free(user_data);
632                 provider_buffer_set_user_data(handle, NULL);
633         }
634
635         DbgPrint("Release buffer\n");
636         return provider_buffer_release(handle);
637 }
638
639 PUBLIC void *livebox_ref_buffer(struct livebox_buffer *handle)
640 {
641         struct livebox_buffer_data *user_data;
642         void *data;
643         int w, h, size;
644         int ret;
645
646         if (!handle) {
647                 return NULL;
648         }
649
650         user_data = provider_buffer_user_data(handle);
651         if (!user_data) {
652                 return NULL;
653         }
654
655         if (user_data->accelerated) {
656                 DbgPrint("H/W accelerated buffer is allocated\n");
657                 return NULL;
658         }
659
660         ret = provider_buffer_get_size(handle, &w, &h, &size);
661
662         data = provider_buffer_ref(handle);
663         if (data && !ret && w > 0 && h > 0 && size > 0) {
664                 memset(data, 0, w * h * size);
665                 provider_buffer_sync(handle);
666         }
667
668         DbgPrint("Ref buffer %ds%d(%d)\n", w, h, size);
669         return data;
670 }
671
672 PUBLIC int livebox_unref_buffer(void *buffer)
673 {
674         if (!buffer) {
675                 return LB_STATUS_ERROR_INVALID;
676         }
677
678         DbgPrint("Unref buffer\n");
679         return provider_buffer_unref(buffer);
680 }
681
682 PUBLIC int livebox_sync_buffer(struct livebox_buffer *handle)
683 {
684         struct livebox_buffer_data *user_data;
685         const char *pkgname;
686         const char *id;
687
688         if (!handle) {
689                 return LB_STATUS_ERROR_INVALID;
690         }
691
692         user_data = provider_buffer_user_data(handle);
693         if (!user_data) {
694                 ErrPrint("Invalid buffer\n");
695                 return LB_STATUS_ERROR_INVALID;
696         }
697
698         if (user_data->accelerated) {
699                 DbgPrint("H/W Buffer allocated. skip the sync buffer\n");
700                 return LB_STATUS_SUCCESS;
701         }
702
703         pkgname = provider_buffer_pkgname(handle);
704         if (!pkgname) {
705                 ErrPrint("Invalid buffer handler\n");
706                 return LB_STATUS_ERROR_INVALID;
707         }
708
709         id = provider_buffer_id(handle);
710         if (!id) {
711                 ErrPrint("Invalid buffer handler\n");
712                 return LB_STATUS_ERROR_INVALID;
713         }
714
715         provider_buffer_sync(handle);
716
717         if (user_data->is_pd) {
718                 if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
719                         ErrPrint("Failed to send PD updated (%s)\n", id);
720                 }
721         } else {
722                 int w;
723                 int h;
724                 int pixel_size;
725
726                 if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) {
727                         ErrPrint("Failed to get size (%s)\n", id);
728                 }
729
730                 if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
731                         ErrPrint("Failed to send updated (%s)\n", id);
732                 }
733         }
734
735         return LB_STATUS_SUCCESS;
736 }
737
738 PUBLIC int livebox_support_hw_buffer(struct livebox_buffer *handle)
739 {
740         if (!handle) {
741                 return LB_STATUS_ERROR_INVALID;
742         }
743
744         return provider_buffer_pixmap_is_support_hw(handle);
745 }
746
747 PUBLIC int livebox_create_hw_buffer(struct livebox_buffer *handle)
748 {
749         struct livebox_buffer_data *user_data;
750         int ret;
751
752         if (!handle) {
753                 return LB_STATUS_ERROR_INVALID;
754         }
755
756         user_data = provider_buffer_user_data(handle);
757         if (!user_data) {
758                 return LB_STATUS_ERROR_INVALID;
759         }
760
761         if (user_data->accelerated) {
762                 return LB_STATUS_ERROR_ALREADY;
763         }
764
765         ret = provider_buffer_pixmap_create_hw(handle);
766         user_data->accelerated = (ret == 0);
767         return ret;
768 }
769
770 PUBLIC int livebox_destroy_hw_buffer(struct livebox_buffer *handle)
771 {
772         struct livebox_buffer_data *user_data;
773         if (!handle) {
774                 return LB_STATUS_ERROR_INVALID;
775         }
776
777         user_data = provider_buffer_user_data(handle);
778         if (!user_data || !user_data->accelerated) {
779                 return LB_STATUS_ERROR_INVALID;
780         }
781
782         user_data->accelerated = 0;
783
784         return provider_buffer_pixmap_destroy_hw(handle);
785 }
786
787 PUBLIC void *livebox_buffer_hw_buffer(struct livebox_buffer *handle)
788 {
789         struct livebox_buffer_data *user_data;
790
791         if (!handle) {
792                 return NULL;
793         }
794
795         user_data = provider_buffer_user_data(handle);
796         if (!user_data || !user_data->accelerated) {
797                 return NULL;
798         }
799
800         return provider_buffer_pixmap_hw_addr(handle);
801 }
802
803 PUBLIC int livebox_buffer_pre_render(struct livebox_buffer *handle)
804 {
805         struct livebox_buffer_data *user_data;
806
807         if (!handle) {
808                 return LB_STATUS_ERROR_INVALID;
809         }
810
811         user_data = provider_buffer_user_data(handle);
812         if (!user_data) {
813                 return LB_STATUS_ERROR_INVALID;
814         }
815
816         if (!user_data->accelerated) {
817                 return LB_STATUS_SUCCESS;
818         }
819
820         /*!
821          * \note
822          * Do preprocessing for accessing the H/W render buffer
823          */
824         return provider_buffer_pre_render(handle);
825 }
826
827 PUBLIC int livebox_buffer_post_render(struct livebox_buffer *handle)
828 {
829         int ret;
830         const char *pkgname;
831         const char *id;
832         struct livebox_buffer_data *user_data;
833
834         if (!handle) {
835                 return LB_STATUS_ERROR_INVALID;
836         }
837
838         user_data = provider_buffer_user_data(handle);
839         if (!user_data) {
840                 return LB_STATUS_ERROR_INVALID;
841         }
842
843         if (!user_data->accelerated) {
844                 return LB_STATUS_SUCCESS;
845         }
846
847         pkgname = provider_buffer_pkgname(handle);
848         if (!pkgname) {
849                 ErrPrint("Invalid buffer handle\n");
850                 return LB_STATUS_ERROR_INVALID;
851         }
852
853         id = provider_buffer_id(handle);
854         if (!id) {
855                 ErrPrint("Invalid buffer handler\n");
856                 return LB_STATUS_ERROR_INVALID;
857         }
858
859         ret = provider_buffer_post_render(handle);
860         if (ret < 0) {
861                 ErrPrint("Failed to post render processing\n");
862                 return ret;
863         }
864
865         if (user_data->is_pd == 1) {
866                 if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
867                         ErrPrint("Failed to send PD updated (%s)\n", id);
868                 }
869         } else {
870                 int w;
871                 int h;
872                 int pixel_size;
873
874                 if (provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) {
875                         ErrPrint("Failed to get size (%s)\n", id);
876                 }
877
878                 if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
879                         ErrPrint("Failed to send updated (%s)\n", id);
880                 }
881         }
882
883         return LB_STATUS_SUCCESS;
884 }
885
886 PUBLIC int livebox_content_is_updated(const char *filename, int is_pd)
887 {
888         return livebox_trigger_update_monitor(filename, is_pd);
889 }
890
891 /* End of a file */