Update image/desc filename management code.
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 4 Sep 2013 04:41:34 +0000 (13:41 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 4 Sep 2013 04:41:34 +0000 (13:41 +0900)
Change-Id: I1387900fcd2819e86732075966f31895b00fa31c

include/instance.h
include/script_handler.h
include/util.h
packaging/data-provider-master.spec
src/instance.c
src/script_handler.c
src/server.c
src/util.c

index 6bbf554..789960b 100644 (file)
@@ -220,8 +220,7 @@ extern int instance_pd_update_begin(struct inst_info *inst);
 extern int instance_pd_update_end(struct inst_info *inst);
 
 extern void instance_pd_updated(const char *pkgname, const char *id, const char *descfile);
-extern void instance_lb_updated(const char *pkgname, const char *id);
-extern void instance_lb_updated_by_instance(struct inst_info *inst);
+extern void instance_lb_updated_by_instance(struct inst_info *inst, const char *safe_file);
 extern void instance_pd_updated_by_instance(struct inst_info *inst, const char *descfile);
 
 extern int instance_client_pd_destroyed(struct inst_info *inst, int status);
index 1ebad1e..6a2195f 100644 (file)
@@ -21,7 +21,7 @@ extern struct script_info *script_handler_create(struct inst_info *inst, const c
 extern int script_handler_destroy(struct script_info *info);
 extern struct fb_info *script_handler_fb(struct script_info *info);
 extern void *script_handler_evas(struct script_info *info);
-extern int script_handler_parse_desc(const char *pkgname, const char *filename, const char *descfile, int is_pd);
+extern int script_handler_parse_desc(struct inst_info *inst, const char *descfile, int is_pd);
 extern int script_handler_unload(struct script_info *info, int is_pd);
 extern int script_handler_load(struct script_info *info, int is_pd);
 extern int script_handler_is_loaded(struct script_info *info);
index 180fffc..a43a462 100644 (file)
@@ -27,7 +27,6 @@ extern char *util_replace_string(const char *src, const char *pattern, const cha
 extern const char *util_uri_to_path(const char *uri);
 extern void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *data);
 extern void util_timer_interval_set(void *timer, double interval);
-extern char *util_get_file_kept_in_safe(const char *id);
 extern double util_time_delay_for_compensation(double period);
 
 #define SCHEMA_FILE    "file://"
index e363d0b..763504f 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.25.10
+Version: 0.25.11
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 5ae31aa..3bf9e84 100644 (file)
@@ -1733,19 +1733,7 @@ HAPI int instance_pd_update_end(struct inst_info *inst)
        return CLIENT_SEND_EVENT(inst, packet);
 }
 
-HAPI void instance_lb_updated(const char *pkgname, const char *id)
-{
-       struct inst_info *inst;
-
-       inst = package_find_instance_by_id(pkgname, id);
-       if (!inst) {
-               return;
-       }
-
-       instance_lb_updated_by_instance(inst);
-}
-
-HAPI void instance_lb_updated_by_instance(struct inst_info *inst)
+HAPI void instance_lb_updated_by_instance(struct inst_info *inst, const char *safe_file)
 {
        struct packet *packet;
        const char *id;
@@ -1782,9 +1770,9 @@ HAPI void instance_lb_updated_by_instance(struct inst_info *inst)
                title = "";
        }
 
-       packet = packet_create_noack("lb_updated", "sssiidss",
+       packet = packet_create_noack("lb_updated", "sssiidsss",
                        package_name(inst->info), inst->id, id,
-                       inst->lb.width, inst->lb.height, inst->lb.priority, content, title);
+                       inst->lb.width, inst->lb.height, inst->lb.priority, content, title, safe_file);
        if (!packet) {
                ErrPrint("Failed to create param (%s - %s)\n", package_name(inst->info), inst->id);
                return;
index b3fe0a7..0e04bda 100644 (file)
@@ -200,7 +200,7 @@ static void render_post_cb(void *data, Evas *e, void *event_info)
        info = instance_lb_script(inst);
        if (info && script_handler_evas(info) == e) {
                fb_sync(script_handler_fb(info));
-               instance_lb_updated_by_instance(inst);
+               instance_lb_updated_by_instance(inst, NULL);
                return;
        }
 
@@ -839,9 +839,8 @@ free_out:
        delete_block(block);
 }
 
-HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const char *descfile, int is_pd)
+HAPI int script_handler_parse_desc(struct inst_info *inst, const char *descfile, int is_pd)
 {
-       struct inst_info *inst;
        FILE *fp;
        int ch;
        int lineno;
@@ -873,14 +872,7 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
        enum state state;
        register int field_idx;
        register int idx = 0;
-       struct block *block;
-
-       block = NULL;
-       inst = package_find_instance_by_id(pkgname, id);
-       if (!inst) {
-               ErrPrint("Instance is not exists\n");
-               return LB_STATUS_ERROR_NOT_EXIST;
-       }
+       struct block *block = NULL;
 
        fp = fopen(descfile, "rt");
        if (!fp) {
@@ -1223,7 +1215,7 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch
                        break;
                case BLOCK_CLOSE:
                        if (!block->file) {
-                               block->file = strdup(util_uri_to_path(id));
+                               block->file = strdup(util_uri_to_path(instance_id(inst)));
                                if (!block->file) {
                                        ErrPrint("Heap: %s\n", strerror(errno));
                                        goto errout;
index 1d09231..e4e4668 100644 (file)
@@ -5639,6 +5639,7 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
 {
        struct slave_node *slave;
        const char *pkgname;
+       const char *safe_filename;
        const char *id;
        const char *content_info;
        const char *title;
@@ -5654,18 +5655,17 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
                goto out;
        }
 
-       ret = packet_get(packet, "ssiidss", &pkgname, &id,
+       ret = packet_get(packet, "ssiidsss", &pkgname, &id,
                                                &w, &h, &priority,
-                                               &content_info, &title);
-       if (ret != 7) {
+                                               &content_info, &title,
+                                               &safe_filename);
+       if (ret != 8) {
                ErrPrint("Parameter is not matched\n");
                goto out;
        }
 
        ret = validate_request(pkgname, id, &inst, NULL);
        if (ret == LB_STATUS_SUCCESS) {
-               char *filename;
-
                if (instance_state(inst) == INST_DESTROYED) {
                        ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
                        goto out;
@@ -5676,12 +5676,15 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
                switch (package_lb_type(instance_package(inst))) {
                case LB_TYPE_SCRIPT:
                        script_handler_resize(instance_lb_script(inst), w, h);
-                       filename = util_get_file_kept_in_safe(id);
-                       if (filename) {
-                               (void)script_handler_parse_desc(pkgname, id, filename, 0);
-                               DbgFree(filename);
+                       if (safe_filename) {
+                               (void)script_handler_parse_desc(inst, safe_filename, 0);
                        } else {
-                               (void)script_handler_parse_desc(pkgname, id, util_uri_to_path(id), 0);
+                               safe_filename = util_uri_to_path(id);
+                               (void)script_handler_parse_desc(inst, safe_filename, 0);
+                       }
+
+                       if (unlink(safe_filename) < 0) {
+                               ErrPrint("unlink: %s - %s\n", strerror(errno), safe_filename);
                        }
                        break;
                case LB_TYPE_BUFFER:
@@ -5691,7 +5694,7 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
                         * text format (inst)
                         */
                        instance_set_lb_size(inst, w, h);
-                       instance_lb_updated_by_instance(inst);
+                       instance_lb_updated_by_instance(inst, safe_filename);
                        break;
                }
 
@@ -5770,7 +5773,7 @@ static struct packet *slave_desc_updated(pid_t pid, int handle, const struct pac
        switch (package_pd_type(instance_package(inst))) {
        case PD_TYPE_SCRIPT:
                if (script_handler_is_loaded(instance_pd_script(inst))) {
-                       (void)script_handler_parse_desc(pkgname, id, descfile, 1);
+                       (void)script_handler_parse_desc(inst, descfile, 1);
                }
                break;
        case PD_TYPE_TEXT:
index 63b41a8..fb86297 100644 (file)
@@ -409,43 +409,6 @@ HAPI void util_timer_interval_set(void *timer, double interval)
        ecore_timer_delay(timer, delay);
 }
 
-HAPI char *util_get_file_kept_in_safe(const char *id)
-{
-       const char *path;
-       char *new_path;
-       int len;
-       int base_idx;
-
-       path = util_uri_to_path(id);
-       if (!path) {
-               ErrPrint("Invalid URI(%s)\n", id);
-               return NULL;
-       }
-
-       /*!
-        * TODO: Remove me
-        */
-       if (OVERWRITE_CONTENT) {
-               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, "reader/%s", path + base_idx);
-       return new_path;
-}
-
 HAPI int util_unlink_files(const char *folder)
 {
        struct stat info;