Merge with old git repository
authorSung-jae Park <nicesj.park@samsung.com>
Sat, 11 Aug 2012 05:33:40 +0000 (14:33 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Sat, 11 Aug 2012 05:33:40 +0000 (14:33 +0900)
Change-Id: I602b20bee18dae794b1ac4eb36b5cb548a30e753

include/livebox.h
include/livebox_internal.h
src/fb.c
src/livebox.c

index 9ce2d5b..1a2c8fb 100644 (file)
@@ -14,18 +14,19 @@ struct livebox;
  * 348x348
  * 700x348
  */
-#define NR_OF_SIZE_LIST 5
+#define NR_OF_SIZE_LIST 6
 #define DEFAULT_PERIOD -1.0f
 
 static const struct supported_size_list {
        int w;
        int h;
 } SIZE_LIST[NR_OF_SIZE_LIST] = {
-       { 172, 172 },
-       { 348, 172 },
-       { 348, 348 },
-       { 700, 348 },
-       { 700, 172 },
+       { 172, 172 }, /*!< 1x1 */
+       { 348, 172 }, /*!< 2x1 */
+       { 348, 348 }, /*!< 2x2 */
+       { 700, 348 }, /*!< 4x2 */
+       { 700, 172 }, /*!< 4x1 */
+       { 700, 700 }, /*!< 4x4 */
 };
 
 enum content_event_type {
index 27bb8e3..08b2df6 100644 (file)
@@ -56,6 +56,7 @@ struct livebox {
        char *pkgname;
        char *id;
        char *content;
+       char *filename;
 
        double timestamp;
        double event_timestamp;
index 32a5123..7075be2 100644 (file)
--- a/src/fb.c
+++ b/src/fb.c
@@ -74,11 +74,16 @@ int fb_sync(struct fb_info *info)
        int fd;
        struct buffer *buffer;
 
-       if (!info || !info->buffer) {
+       if (!info) {
                ErrPrint("FB Handle is not valid\n");
                return -EINVAL;
        }
 
+       if (!info->buffer) {
+               DbgPrint("Buffer is not prepared\n");
+               return 0;
+       }
+
        buffer = info->buffer;
 
        if (buffer->state != CREATED) {
index 93ac3f3..a9f2611 100644 (file)
@@ -1110,6 +1110,10 @@ EAPI const char *livebox_filename(struct livebox *handler)
                return NULL;
        }
 
+       if (handler->filename)
+               return handler->filename;
+
+       /* Oooops */
        return URI_TO_PATH(handler->id);
 }
 
@@ -1747,6 +1751,43 @@ struct livebox *lb_find_livebox_by_timestamp(double timestamp)
        return NULL;
 }
 
+static inline char *get_file_kept_in_safe(const char *id)
+{
+       const char *path;
+       char *new_path;
+       int len;
+       int base_idx;
+
+       path = URI_TO_PATH(id);
+       if (!path) {
+               ErrPrint("Invalid URI(%s)\n", id);
+               return NULL;
+       }
+
+       /*!
+        * \TODO: REMOVE ME
+        */
+       if (getenv("DISABLE_PREVENT_OVERWRITE")) {
+               return strdup(path);
+       }
+
+       len = strlen(path);
+       base_idx = len - 1;
+
+       while (base_idx > 0 && path[base_idx] != '/') base_idx--;
+       base_idx += (path[base_idx] == '/');
+
+       new_path = malloc(len + 10);
+       if (!new_path) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return NULL;
+       }
+
+       strncpy(new_path, path, base_idx);
+       snprintf(new_path + base_idx, len + 10 - base_idx, "_%s", path + base_idx);
+       return new_path;
+}
+
 struct livebox *lb_new_livebox(const char *pkgname, const char *id, double timestamp)
 {
        struct livebox *handler;
@@ -1772,6 +1813,13 @@ struct livebox *lb_new_livebox(const char *pkgname, const char *id, double times
                return NULL;
        }
 
+       handler->filename = get_file_kept_in_safe(id);
+       if (!handler->filename) {
+               handler->filename = strdup(URI_TO_PATH(id));
+               if (!handler->filename)
+                       ErrPrint("Error: %s\n", strerror(errno));
+       }
+
        handler->timestamp = timestamp;
        handler->lb.type = _LB_TYPE_FILE;
        handler->pd.type = _PD_TYPE_SCRIPT;
@@ -1837,6 +1885,16 @@ void lb_set_id(struct livebox *handler, const char *id)
        handler->id = strdup(id);
        if (!handler->id)
                ErrPrint("Error: %s\n", strerror(errno));
+
+       if (handler->filename)
+               free(handler->filename);
+
+       handler->filename = get_file_kept_in_safe(id);
+       if (!handler->filename) {
+               handler->filename = strdup(URI_TO_PATH(id));
+               if (!handler->filename)
+                       ErrPrint("Error: %s\n", strerror(errno));
+       }
 }
 
 int lb_set_lb_fb(struct livebox *handler, const char *filename)
@@ -1994,6 +2052,7 @@ struct livebox *lb_unref(struct livebox *handler)
        free(handler->category);
        free(handler->id);
        free(handler->pkgname);
+       free(handler->filename);
 
        if (handler->lb.data.fb) {
                fb_destroy(handler->lb.data.fb);