From 651ddd6ecc6f9cfe4ad285f3835bddbcd8841379 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Tue, 13 Jan 2015 00:05:14 +0900 Subject: [PATCH] Unlink image/text data file after invoke the event callback To be able to access it from viewer application from its updated callback. [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: Ifddc45f0eeed97b1e5f3c2a5635f9954d090eaf6 --- dynamicbox_viewer/include/dynamicbox_internal.h | 1 + dynamicbox_viewer/src/client.c | 3 ++- dynamicbox_viewer/src/desc_parser.c | 2 +- dynamicbox_viewer/src/dynamicbox_internal.c | 15 +++++++++------ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dynamicbox_viewer/include/dynamicbox_internal.h b/dynamicbox_viewer/include/dynamicbox_internal.h index f4a6b7e..ad3f7d7 100644 --- a/dynamicbox_viewer/include/dynamicbox_internal.h +++ b/dynamicbox_viewer/include/dynamicbox_internal.h @@ -49,6 +49,7 @@ extern int dbox_text_gbar(struct dynamicbox_common *handler); extern void dbox_set_period(struct dynamicbox_common *handler, double period); extern void dbox_set_update_mode(struct dynamicbox_common *handler, int active_mode); extern void dbox_set_filename(struct dynamicbox_common *handler, const char *filename); +extern void dbox_unlink_filename(struct dynamicbox_common *common); extern void dbox_set_alt_icon(struct dynamicbox_common *handler, const char *icon); extern void dbox_set_alt_name(struct dynamicbox_common *handle, const char *name); extern int dbox_destroy_common_handle(struct dynamicbox_common *common); diff --git a/dynamicbox_viewer/src/client.c b/dynamicbox_viewer/src/client.c index 087d320..61ae62d 100644 --- a/dynamicbox_viewer/src/client.c +++ b/dynamicbox_viewer/src/client.c @@ -788,7 +788,6 @@ static struct packet *master_dbox_updated(pid_t pid, int handle, const struct pa common->dbox.last_damage.w = w; common->dbox.last_damage.h = h; common->dbox.last_extra_buffer_idx = DBOX_PRIMARY_BUFFER; - dbox_set_filename(common, safe_file); if (dbox_text_dbox(common)) { @@ -802,6 +801,7 @@ static struct packet *master_dbox_updated(pid_t pid, int handle, const struct pa * DESC parser will call the "text event callback". * Don't need to call global event callback in this case. */ + dbox_unlink_filename(common); goto out; } else if (dbox_get_dbox_fb(common)) { /*! @@ -836,6 +836,7 @@ static struct packet *master_dbox_updated(pid_t pid, int handle, const struct pa dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_UPDATED); } } + dbox_unlink_filename(common); out: return NULL; diff --git a/dynamicbox_viewer/src/desc_parser.c b/dynamicbox_viewer/src/desc_parser.c index daf82c6..4103b90 100644 --- a/dynamicbox_viewer/src/desc_parser.c +++ b/dynamicbox_viewer/src/desc_parser.c @@ -336,7 +336,7 @@ static inline char *load_file(const char *filename) fd = open(filename, O_RDONLY); if (fd < 0) { - ErrPrint("open: %s\n", strerror(errno)); + ErrPrint("open: %s (%s)\n", strerror(errno), filename); return NULL; } diff --git a/dynamicbox_viewer/src/dynamicbox_internal.c b/dynamicbox_viewer/src/dynamicbox_internal.c index 27dada9..4b3e034 100644 --- a/dynamicbox_viewer/src/dynamicbox_internal.c +++ b/dynamicbox_viewer/src/dynamicbox_internal.c @@ -484,15 +484,18 @@ void dbox_set_id(struct dynamicbox_common *common, const char *id) common->id = pi; } -void dbox_set_filename(struct dynamicbox_common *common, const char *filename) +void dbox_unlink_filename(struct dynamicbox_common *common) { - if (common->filename) { - if (common->dbox.type == DBOX_TYPE_FILE || common->dbox.type == DBOX_TYPE_TEXT) { - if (common->filename[0] && unlink(common->filename) < 0) { - ErrPrint("unlink: %s (%s)\n", strerror(errno), common->filename); - } + if (common->dbox.type == DBOX_TYPE_FILE || common->dbox.type == DBOX_TYPE_TEXT) { + if (common->filename && common->filename[0] && unlink(common->filename) < 0) { + ErrPrint("unlink: %s (%s)\n", strerror(errno), common->filename); } + } +} +void dbox_set_filename(struct dynamicbox_common *common, const char *filename) +{ + if (common->filename) { free(common->filename); } -- 2.7.4