From ce815000f24f08ae8c4b2e9e67b4fdd27b2439c9 Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Thu, 13 Oct 2016 18:47:28 +0530 Subject: [PATCH] [TSAM-8604][TSAM-8350]popup on compression/decompression Change-Id: Iaaa81898d94c673e4f473e66e17e9d275f28d002 Signed-off-by: shubham kumar --- inc/mf-callback.h | 2 + inc/mf-miniunzip.h | 2 +- inc/mf-minizip.h | 12 +- inc/mf-popup.h | 1 + inc/mf-search.h | 4 + res/edje/myfile.edc | 486 ++++++++++++++++++++++++++++++- src/common/file-operation/mf-miniunzip.c | 23 +- src/common/file-operation/mf-minizip.c | 32 +- src/common/mf-callback.c | 106 +++++-- src/common/mf-util.c | 53 ++-- src/widget/mf-popup.c | 90 +++++- 11 files changed, 730 insertions(+), 81 deletions(-) diff --git a/inc/mf-callback.h b/inc/mf-callback.h index a123f6a..de8c5d1 100755 --- a/inc/mf-callback.h +++ b/inc/mf-callback.h @@ -45,6 +45,8 @@ void mf_callback_cancel_cb(void *data, Evas_Object *obj, void *event_info); void mf_callback_move_here_cb(void *data, Evas_Object *obj, void *event_info); void mf_callback_paste_here_cb(void *data, Evas_Object *obj, void *event_info); void mfCopyCB(void *data, Evas_Object *obj, void *event_info); +void __mf_compress_pipe_cb(void *data, void *buffer, unsigned int nbyte); +void __mf_decompress_pipe_cb(void *data, void *buffer, unsigned int nbyte); Eina_Bool mf_callback_thumb_timer_cb(void *data); /*Callbacks defined for external usage*/ diff --git a/inc/mf-miniunzip.h b/inc/mf-miniunzip.h index 0c874a4..2e7c860 100644 --- a/inc/mf-miniunzip.h +++ b/inc/mf-miniunzip.h @@ -39,7 +39,7 @@ int mf_create_new_dir(const char* dirname); int mf_do_list(unzFile uf); -int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password,void *data); +int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password,void *data, int count); int mf_do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password, void *data); diff --git a/inc/mf-minizip.h b/inc/mf-minizip.h index 123e7a3..77242be 100644 --- a/inc/mf-minizip.h +++ b/inc/mf-minizip.h @@ -28,15 +28,25 @@ #include +#include "mf-search.h" + #define WRITEBUFFERSIZE (16384) #define MAXFILENAME (256) +typedef struct _mf_compress_pipe_msg mf_compress_pipe_msg; +struct _mf_compress_pipe_msg { + mf_search_pipe_msg_type mf_sp_msg_type; + char *filename; + int finished_count; + int total_count; +}; + int mf_check_exist_file(const char* filename); /* calculate the CRC32 of a file, because to encrypt a file, we need known the CRC32 of the file before */ int mf_get_file_crc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc); -int mf_file_do_zip(int argc, char **argv, char *cwd); +int mf_file_do_zip(void *data, int argc, char **argv, char *cwd); #endif /* MF_MINIZIP_H_ */ diff --git a/inc/mf-popup.h b/inc/mf-popup.h index 2da4951..5563870 100755 --- a/inc/mf-popup.h +++ b/inc/mf-popup.h @@ -48,6 +48,7 @@ enum __message_type_e { Evas_Object *mf_popup_create_popup(void *data, ePopMode popupMode, char *title, const char *context, const char *first_btn_text, const char *second_btn_text, const char *third_btn_text, Evas_Smart_Cb func, void *param); Evas_Object *mf_popup_create_pb_popup(void *data, char *title, char *context, int file_count, void *func, void *param); +Evas_Object *mf_popup_create_progress_pb_popup(void *data, char *title, char *context, int file_count, void *func, void *param); void mf_popup_indicator_popup(void *data, const char *text); Evas_Object *mf_popup_center_processing(void *data, const char *context, diff --git a/inc/mf-search.h b/inc/mf-search.h index d6b2041..2b7193e 100755 --- a/inc/mf-search.h +++ b/inc/mf-search.h @@ -15,6 +15,9 @@ * */ + +#include + #ifndef _MF_SEARCH_H_ #define _MF_SEARCH_H_ @@ -105,6 +108,7 @@ struct _mf_search_pipe_msg { gchar *current_path; }; + /** * mf_Search_Cb: * @result: the handle of result, use util APIs to get detail result with this handle. diff --git a/res/edje/myfile.edc b/res/edje/myfile.edc index 739769c..b000b86 100644 --- a/res/edje/myfile.edc +++ b/res/edje/myfile.edc @@ -50,6 +50,461 @@ collections { #include "myfile-expand-title.edc" #include "myfile-toolbar.edc" /* for genlist multi_item style*/ + + + #define PROGRESSBAR_DEFAULT_HEIGHT_INC 4 +#define PROGRESSBAR_DEFAULT_TEXT_HEIGHT_INC 21 +#define PROGRESSBAR_PADDING_HEIGHT_INC 4 + +group { name: "elm/progressbar/horizontal/myfile/default"; + data.item: "vector_ux" "default"; + parts { + part { name: "access"; + type: RECT; + description { state: "default" 0.0; + fixed: 1 1; + color: 0 0 0 0; + } + } + part { name: "elm.swallow.bar"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 0; + } + } + part { name: "base"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + min: 0 PROGRESSBAR_DEFAULT_HEIGHT_INC; + } + } + part { name: "elm.text.top.right"; + type: TEXT; + scale: 1; + description { state: "default" 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + rel1.to: "base"; + rel2.to: "top_padding"; + text { + min: 0 0; + align: 0.0 1.0; + font: "Tizen:style=Regular"; size: "12"; + text_class: "tizen"; + } + align: 0.0 1.0; + color: 102 102 102 255; + visible: 0; + } + description { state: "show" 0.0; + inherit: "default" 0.0; + min: 0 PROGRESSBAR_DEFAULT_TEXT_HEIGHT_INC; + text.min: 1 1; + visible: 1; + } + } + part { name: "top_padding"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + min: 0 PROGRESSBAR_PADDING_HEIGHT_INC; + max: -1 PROGRESSBAR_PADDING_HEIGHT_INC; + fixed: 0 1; + rel1.to: "background"; + rel2.to: "background"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + align: 0.5 1.0; + } + } + part { name: "background"; + type: RECT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 PROGRESSBAR_DEFAULT_HEIGHT_INC; + max: -1 PROGRESSBAR_DEFAULT_HEIGHT_INC; + fixed: 0 1; + color: 145 145 145 179; + } + } + part { name: "tizen_vg_shape1"; + type: SWALLOW; + mouse_events: 0; + scale: 1; + clip_to: "background"; + description { state: "default" 0.0; + rel1.to: "background"; + rel2.to: "background"; + } + } + part { name: "drag.background"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + rel1 { + to_x: "background"; + to_y: "background"; + relative: 0.0 0.0; + } + rel2 { + to_x: "background"; + to_y: "background"; + relative: 1.0 1.0; + } + } + } + part { name: "tizen_vg_shape2"; + type: SWALLOW; + scale: 1; + clip_to: "tizen_vg_shape2_clipper"; + description { state: "default" 0.0; + rel1.to: "elm.progress.progressbar"; + rel2.to: "elm.progress.progressbar"; + } + } + part { name: "tizen_vg_shape2_clipper"; + type: RECT; + description { state: "default" 0.0; + color:61 184 204 77; + } + } + part { name: "tizen_vg_shape3"; + type: SWALLOW; + scale: 1; + clip_to: "elm.progress.progressbar"; + description { state: "default" 0.0; + rel1.to: "elm.progress.progressbar"; + rel2.to: "elm.progress.progressbar"; + } + } + part { name: "elm.progress.progressbar"; + type: RECT; + description { state: "default" 0.0; + min: 0 0; + fixed: 1 1; + rel1 { + to: "background"; + relative: 0.0 0.0; + } + rel2 { + to_y: "background"; + to_x: "elm.cur.progressbar"; + offset: -1 -1; + } + color:61 184 204 255; + } + description { state: "invert" 0.0; + inherit: "default" 0.0; + rel1 { + to_y: "background"; + to_x: "elm.cur.progressbar"; + } + rel2 { + to: "background"; + relative: 1.0 1.0; + } + } + description { state: "state_begin" 0.0; + inherit: "default" 0.0; + rel1 { + to: "background"; + relative: 0.0 0.0; + } + rel2 { + to: "background"; + relative: 0.1 1.0; + } + } + description { state: "state_end" 0.0; + inherit: "default" 0.0; + rel1 { + to: "background"; + relative: 0.9 0.0; + } + rel2 { + to: "background"; + relative: 1.0 1.0; + } + } + } + part { name: "elm.cur.progressbar"; + mouse_events: 0; + scale: 1; + dragable { + confine: "drag.background"; + x: 1 1 1; + y: 0 0 0; + } + description { state: "default" 0.0; + min: 0 28; + fixed: 1 1; + visible: 0; + rel1.to: "drag.background"; + rel2.to: "drag.background"; + } + } + part { name: "bottom_padding"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + min: 0 PROGRESSBAR_PADDING_HEIGHT_INC; + max: -1 PROGRESSBAR_PADDING_HEIGHT_INC; + fixed: 0 1; + rel1.to: "background"; + rel2.to: "background"; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + align: 0.5 0.0; + } + } + part { name: "elm.text.bottom.left"; + type: TEXT; + scale: 1; + description { state: "default" 0.0; + rel1.to: "bottom_padding"; + rel2.to: "base"; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + text { + min: 0 0; + align: 0.0 0.0; + font: "Tizen:style=Regular"; size: "12"; + text_class: "tizen"; + } + align: 0.0 0.0; + color: 102 102 102 255; + visible: 0; + } + description { state: "show" 0.0; + inherit: "default" 0.0; + text.min: 1 1; + visible: 1; + min: 0 PROGRESSBAR_DEFAULT_TEXT_HEIGHT_INC; + } + } + part { name: "elm.text.status"; + type: TEXT; + scale: 1; + description { state: "default" 0.0; + rel1.to: "bottom_padding"; + rel2.to: "base"; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + text { + min: 0 0; + align: 1.0 0.0; + font: "Tizen:style=Regular"; size: "12"; + text_class: "tizen"; + } + align: 1.0 0.0; + color: 102 102 102 255; + visible: 0; + } + description { state: "show" 0.0; + inherit: "default" 0.0; + text.min: 1 1; + min: 0 PROGRESSBAR_DEFAULT_TEXT_HEIGHT_INC; + visible: 1; + } + } + part { name: "elm.text.bottom.right"; + type: TEXT; + scale: 1; + description { state: "default" 0.0; + rel1.to: "bottom_padding"; + rel2.to: "base"; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + text { + min: 0 0; + align: 1.0 0.0; + font: "Tizen:style=Regular"; size: "12"; + text_class: "tizen"; + } + align: 1.0 0.0; + color: 102 102 102 255; + visible: 0; + } + description { state: "show" 0.0; + inherit: "default" 0.0; + text.min: 1 1; + visible: 1; + min: 0 PROGRESSBAR_DEFAULT_TEXT_HEIGHT_INC; + } + } + } + programs { + program { name: "text_top_right_show"; + signal: "elm,state,top.right,visible"; + source: "elm"; + action: STATE_SET "show" 0.0; + target: "elm.text.top.right"; + } + program { name: "text_top_right_text_hide"; + signal: "elm,state,top.right,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text.top.right"; + } + program { name: "text_bottom_left_show"; + signal: "elm,state,bottom.left,visible"; + source: "elm"; + action: STATE_SET "show" 0.0; + target: "elm.text.bottom.left"; + } + program { name: "text_bottom_left_text_hide"; + signal: "elm,state,bottom.left,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text.bottom.left"; + } + program { name: "text_bottom_right_show"; + signal: "elm,state,bottom.right,visible"; + source: "elm"; + script { + set_state(PART:"elm.text.status", "default", 0.0); + set_state(PART:"elm.text.bottom.right", "show", 0.0); + } + } + program { name: "text_status_show"; + signal: "elm,state,units,visible"; + source: "elm"; + script { + set_state(PART:"elm.text.bottom.right", "default", 0.0); + set_state(PART:"elm.text.status", "show", 0.0); + } + } + program { name: "text_status_text_hide"; + signal: "elm,state,units,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text.status"; + } + program { name: "slide_to_end"; + action: STATE_SET "state_end" 0.0; + transition: LINEAR 0.5; + target: "elm.progress.progressbar"; + after: "slide_to_begin"; + } + program { name: "slide_to_begin"; + signal: "elm,state,slide,begin"; + action: STATE_SET "state_begin" 0.0; + target: "elm.progress.progressbar"; + transition: LINEAR 0.5; + after: "slide_to_end"; + } + program { name: "start_pulse"; + signal: "elm,state,pulse,start"; + source: "elm"; + } + program { name: "stop_pulse"; + signal: "elm,state,pulse,stop"; + source: "elm"; + action: ACTION_STOP; + target: "slide_to_begin"; + target: "slide_to_end"; + target: "start_pulse"; + } + program { name: "state_pulse"; + signal: "elm,state,pulse"; + source: "elm"; + action: STATE_SET "state_begin" 0.0; + target: "elm.progress.progressbar"; + action: STATE_SET "default" 0.0; + target: "elm.text.status"; + } + program { name: "state_fraction"; + signal: "elm,state,fraction"; + source: "elm"; + action: ACTION_STOP; + target: "slide_to_begin"; + target: "slide_to_end"; + target: "start_pulse"; + action: STATE_SET "default" 0.0; + target: "elm.progress.progressbar"; + target: "elm.text.status"; + } + program { name: "set_invert_on"; + signal: "elm,state,inverted,on"; + source: "elm"; + action: STATE_SET "invert" 0.0; + target: "elm.progress.progressbar"; + } + program { name: "set_invert_off"; + signal: "elm,state,inverted,off"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.progress.progressbar"; + } + program { name: "finished_animation"; + signal: "elm,action,animation,finished"; + source: "elm"; + action: SIGNAL_EMIT "animation,finished" ""; + } + } + } + + group { name: "popup_copy_move"; + parts { + part { + name : "bg"; + type : RECT; + description { + min : 200 0; + max : -1 200; + rel1 { + relative : 1.0 0.0; + to : "pad_l"; + } + rel2 { + relative : 0.0 1.0; + to : "pad_r"; + } + color : 0 0 0 0; + } + } + part { + name : "swallow"; + type : SWALLOW; + description { + min : 0 0; + max : -1 -1; + rel1 { + relative : 1.0 0.0; + to : "pad_l"; + } + rel2 { + relative : 0.0 1.0; + to : "pad_r"; + } + } + } + part { + name : "pad_l"; + type : SPACER; + description { + min : 50 50; + max : 50 50; + rel1.relative : 0.0 0.0; + rel2.relative : 0.0 0.0; + align : 0.0 0.0; + } + } + part { + name : "pad_r"; + type : SPACER; + description { + min : 50 50; + max : 50 50; + rel1.relative : 1.0 1.0; + rel2.relative : 1.0 1.0; + align : 1 1; + } + } + } +} group @@ -331,8 +786,8 @@ collections { /************** progressbar popup****************/ group { name: "popup_center_progressview"; -#define DEMO_POPUP_PROGRESSVIEW_CONTENT_MIN 200 5 -#define DEMO_POPUP_PROGRESSVIEW_PROGRESSBAR_MIN 200 6 +#define DEMO_POPUP_PROGRESSVIEW_CONTENT_MIN 200 40 +#define DEMO_POPUP_PROGRESSVIEW_PROGRESSBAR_MIN 200 10 #define DEMO_POPUP_PROGRESSVIEW_TITLE_MIN 200 28 #define DEMO_POPUP_PROGRESSVIEW_TEXT_LEFT_RIGHT_MAX 142 28 parts { @@ -341,7 +796,7 @@ collections { scale: 1; description { state: "default" 0.0; align: 0.5 0.0; - min: 0 40; + min: 0 20; fixed: 0 1; rel1 { relative: 1.0 0.0;to_x: "pad_l"; @@ -355,8 +810,8 @@ collections { type: SPACER; scale: 1; description { state: "default" 0.0; - min: 29 0; - max: 29 0; + min: 20 0; + max: 20 0; fixed: 1 0; rel1 { relative: 0.0 0.0; @@ -371,8 +826,8 @@ collections { type: SPACER; scale: 1; description { state: "default" 0.0; - min: 29 0; - max: 29 0; + min: 20 0; + max: 20 0; fixed: 1 0; rel1 { relative: 1.0 0.0; @@ -410,16 +865,16 @@ collections { min: 0 0; align: 0.0 0.0; text_class: "T058"; - size : 15; + size : 12; } color: 0 0 0 255; align: 0.5 0.0; rel1 { - relative: 0.5 0.4; + relative: 0.0 0.1; to: "pad_t"; } rel2 { - relative: 1.0 0.6; + relative: 1.0 1.0; to: "pad_t"; } } @@ -454,16 +909,15 @@ collections { type: SWALLOW; scale: 1; description { state: "default" 0.0; - max: DEMO_POPUP_PROGRESSVIEW_PROGRESSBAR_MIN; + min: DEMO_POPUP_PROGRESSVIEW_PROGRESSBAR_MIN; align: 0.0 0.5; rel1 { - relative: 0.0 0.4; - to_x: "pad_l"; - to_y: "pad_t"; + relative: 0.0 0.0; + to: "elm.swallow.content"; } rel2 { - relative: 0.1 0.8; - to: "pad_t"; + relative: 1.0 1.0; + to: "elm.swallow.content"; } } } diff --git a/src/common/file-operation/mf-miniunzip.c b/src/common/file-operation/mf-miniunzip.c index 35e39ec..29d5562 100644 --- a/src/common/file-operation/mf-miniunzip.c +++ b/src/common/file-operation/mf-miniunzip.c @@ -13,6 +13,7 @@ */ #include"mf-miniunzip.h" +#include "mf-minizip.h" #include"mf-dlog.h" #include "mf-main.h" #include @@ -122,7 +123,7 @@ int mf_do_list(unzFile uf) } -int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password,void *data) +int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password,void *data, int count) { char filename_inzip[256]; char* filename_withoutpath; @@ -151,6 +152,13 @@ int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, if (file_found == 1) { mf_debug("shubham file found"); + mf_compress_pipe_msg msg1; + memset(&msg1, 0, sizeof(mf_compress_pipe_msg)); + msg1.finished_count = count; + msg1.filename = strdup(filename_inzip); + msg1.mf_sp_msg_type = MF_SEARCH_PIPE_MSG_DOING; + msg1.total_count = eina_list_count(ap->edit_file_list); + ecore_pipe_write(ap->mf_FileOperation.sync_pipe, &msg1, sizeof(msg1)); if (err!=UNZ_OK) { mf_debug("error %d with zipfile in unzGetCurrentFileInfo\n",err); return err; @@ -266,6 +274,15 @@ int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, } } + mf_compress_pipe_msg msg; + memset(&msg, 0, sizeof(mf_compress_pipe_msg)); + msg.finished_count = count; + msg.filename = strdup(filename_inzip); + msg.mf_sp_msg_type = MF_SEARCH_PIPE_MSG_RESULT_REPORT; + msg.total_count = eina_list_count(ap->edit_file_list); + ecore_pipe_write(ap->mf_FileOperation.sync_pipe, &msg, sizeof(msg)); + sleep(1); + if (err==UNZ_OK) { err = unzCloseCurrentFile (uf); if (err!=UNZ_OK) { @@ -304,7 +321,7 @@ int mf_do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, c { int ret = mf_do_extract_currentfile(uf,&opt_extract_without_path, - &opt_overwrite, password,ap); + &opt_overwrite, password,ap,i+1); if (ret != 10 && ret != UNZ_OK) { break; } @@ -332,7 +349,7 @@ int mf_do_extract_onefile(unzFile uf, const char* filename, int opt_extract_with if (mf_do_extract_currentfile(uf,&opt_extract_without_path, &opt_overwrite, - password,ap) == UNZ_OK) { + password,ap,1) == UNZ_OK) { return 0; } else { diff --git a/src/common/file-operation/mf-minizip.c b/src/common/file-operation/mf-minizip.c index c41e3eb..25b4ada 100644 --- a/src/common/file-operation/mf-minizip.c +++ b/src/common/file-operation/mf-minizip.c @@ -13,7 +13,11 @@ */ #include "mf-minizip.h" +#include "mf-search.h" #include "mf-dlog.h" +#include "mf-main.h" + +#include uLong mf_get_filetime(char *f, tm_zip *tmzip, uLong *dt) { @@ -108,11 +112,12 @@ int mf_get_file_crc(const char* filenameinzip,void*buf,unsigned long size_buf,un return err; } -int mf_file_do_zip(int argc, char **argv, char *cwd) +int mf_file_do_zip(void *data, int argc, char **argv, char *cwd) { chdir(cwd); getcwd(cwd, sizeof(cwd)); mf_debug("Current Directory : %s", cwd); + struct appdata *ap = (struct appdata *)data; int i; int opt_overwrite=0; int opt_compress_level=Z_DEFAULT_COMPRESSION; @@ -211,6 +216,15 @@ int mf_file_do_zip(int argc, char **argv, char *cwd) mf_debug("creating %s",filename_try); } + mf_compress_pipe_msg msg2; + memset(&msg2, 0, sizeof(mf_compress_pipe_msg)); + msg2.finished_count = 0; + msg2.filename = strdup(""); + msg2.mf_sp_msg_type = MF_SEARCH_PIPE_MSG_RESULT_REPORT; + msg2.total_count = argc - 2; + ecore_pipe_write(ap->mf_FileOperation.sync_pipe, &msg2, sizeof(msg2)); + + for (i=zipfilenamearg+1;(imf_FileOperation.sync_pipe, &msg, sizeof(msg)); + zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; zi.dosDate = 0; @@ -277,6 +299,14 @@ int mf_file_do_zip(int argc, char **argv, char *cwd) } while ((err == ZIP_OK) && (size_read>0)); } + mf_compress_pipe_msg msg1; + memset(&msg1, 0, sizeof(mf_compress_pipe_msg)); + msg1.finished_count = i; + msg1.filename = strdup(filenameinzip); + msg1.mf_sp_msg_type = MF_SEARCH_PIPE_MSG_RESULT_REPORT; + msg1.total_count = argc - 2; + ecore_pipe_write(ap->mf_FileOperation.sync_pipe, &msg1, sizeof(msg1)); + if (fin) { fclose(fin); } diff --git a/src/common/mf-callback.c b/src/common/mf-callback.c index a403759..63f24f4 100755 --- a/src/common/mf-callback.c +++ b/src/common/mf-callback.c @@ -127,6 +127,81 @@ void mf_callback_storage_remove_flag_set(Eina_Bool flag, int more) mf_storage_remove_flag = flag; } +void __mf_compress_pipe_cb(void *data, void *buffer, unsigned int nbyte) +{ + struct appdata *ap = (struct appdata *)data; + char count[1024]; + char per[1024]; + + mf_compress_pipe_msg *pSearchMsg = (mf_compress_pipe_msg *) buffer; + if (pSearchMsg == NULL) { + mf_debug("received message is NULL"); + return; + } + + if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_DOING) { + if (pSearchMsg->filename) { + mf_debug("file name exits"); + mf_object_text_set(ap->mf_MainWindow.pProgressLayout, pSearchMsg->filename, "elm.title.filename"); + free(pSearchMsg->filename); + } + } + + else if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_RESULT_REPORT) { + int percentage = (((pSearchMsg->finished_count-1) * 100 )/pSearchMsg->total_count); + snprintf(count, sizeof(count), "%d/%d", pSearchMsg->finished_count-1, pSearchMsg->total_count); + snprintf(per, sizeof(per), "%d %%", percentage); + elm_progressbar_value_set(ap->mf_FileOperation.progress_bar, (double)((double)percentage/100)); + elm_object_part_text_set(ap->mf_MainWindow.pProgressLayout, "elm.text.left", per); + elm_object_part_text_set(ap->mf_MainWindow.pProgressLayout, "elm.text.right", count); + + } else { + SAFE_FREE_OBJ(ap->mf_MainWindow.pProgressPopup); + mf_callback_cancel_cb(ap,NULL,NULL); + ecore_pipe_del(ap->mf_FileOperation.sync_pipe); + } + + +} + +void __mf_decompress_pipe_cb(void *data, void *buffer, unsigned int nbyte) +{ + struct appdata *ap = (struct appdata *)data; + char count[1024]; + char per[1024]; + + mf_compress_pipe_msg *pSearchMsg = (mf_compress_pipe_msg *) buffer; + if (pSearchMsg == NULL) { + mf_debug("received message is NULL"); + return; + } + + if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_DOING) { + if (pSearchMsg->filename) { + mf_object_text_set(ap->mf_MainWindow.pProgressLayout, pSearchMsg->filename, "elm.title.filename"); + free(pSearchMsg->filename); + } + } else if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_RESULT_REPORT) { + int percentage = (((pSearchMsg->finished_count) * 100 )/pSearchMsg->total_count); + snprintf(count, sizeof(count), "%d/%d", pSearchMsg->finished_count, pSearchMsg->total_count); + snprintf(per, sizeof(per), "%d %%", percentage); + + double v = elm_progressbar_value_get(ap->mf_FileOperation.progress_bar); + + elm_progressbar_value_set(ap->mf_FileOperation.progress_bar, (double)((double)percentage/100)); + + double v1 = elm_progressbar_value_get(ap->mf_FileOperation.progress_bar); + + elm_object_part_text_set(ap->mf_MainWindow.pProgressLayout, "elm.text.left", per); + elm_object_part_text_set(ap->mf_MainWindow.pProgressLayout, "elm.text.right", count); + } else { + mf_debug("popup deleted"); + SAFE_FREE_OBJ(ap->mf_MainWindow.pProgressPopup); + mf_callback_cancel_cb(ap,NULL,NULL); + ecore_pipe_del(ap->mf_FileOperation.sync_pipe); + } +} + Eina_Bool mf_callback_monitor_internal_update_flag_get() { return monitor_internal_update_flag; @@ -2478,13 +2553,18 @@ void * mf_callback_compress_cb(void *data) i++; } - mf_file_do_zip(argc, argv, ap->mf_FileOperation.source->str); + mf_file_do_zip(ap, argc, argv, ap->mf_FileOperation.source->str); ap->mf_Status.view_type = mf_view_normal; mf_debug("thread function done"); // ap->new_file = NULL; MF_TRACE_END; + mf_compress_pipe_msg msg; + memset(&msg, 0, sizeof(mf_compress_pipe_msg)); + msg.mf_sp_msg_type = MF_SEARCH_PIPE_MSG_FINISHED; + ecore_pipe_write(ap->mf_FileOperation.sync_pipe, &msg, sizeof(msg)); pthread_exit(0); + return NULL; } @@ -2631,21 +2711,13 @@ void mf_callback_decompress_cb(void *data) mf_error("\nMORE : %d. EXTRA : %d", ap->mf_Status.more, ap->mf_Status.extra); - if (ap->mf_Status.extra == MORE_SEARCH) { - ap->mf_Status.more = MORE_SEARCH; - mf_search_view_create(ap); - } else { - ap->mf_Status.more = MORE_DEFAULT; - SAFE_FREE_CHAR(ap->mf_Status.entry_path); - ap->mf_Status.entry_more = MORE_DEFAULT; - if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.more != MORE_SEARCH) { - mf_navi_bar_recover_info_box(ap); - } - mf_naviframe_title_button_delete(ap->mf_MainWindow.pNaviItem); - } - - ap->mf_Status.view_type = mf_view_normal; + mf_compress_pipe_msg msg; + memset(&msg, 0, sizeof(mf_compress_pipe_msg)); + msg.mf_sp_msg_type = MF_SEARCH_PIPE_MSG_FINISHED; + ecore_pipe_write(ap->mf_FileOperation.sync_pipe, &msg, sizeof(msg)); + + pthread_exit(0); MF_TRACE_END; } @@ -2882,7 +2954,7 @@ void mf_callback_paste_here_cb(void *data, Evas_Object *obj, void *event_info) if (ret == 0) { ap->mf_FileOperation.iOperationSuccessFlag = TRUE; mf_fs_monitor_remove_dir_watch(); - ap->mf_MainWindow.pProgressPopup = mf_popup_create_pb_popup(ap, LABEL_COPY, MF_MSG_COPYING, count, mf_callback_progress_bar_cancel_cb, ap); + ap->mf_MainWindow.pProgressPopup = mf_popup_create_progress_pb_popup(ap, LABEL_COPY, MF_MSG_COPYING, count, mf_callback_progress_bar_cancel_cb, ap); } else if (ret == MF_FO_ERR_ARGUMENT) { mf_popup_indicator_popup(ap, mf_util_get_text(MF_LABEL_FILE_NOT_EXIST)); mf_callback_cancel_cb(ap, NULL, NULL); @@ -2983,7 +3055,7 @@ void mf_callback_move_here_cb(void *data, Evas_Object *obj, void *event_info) if (mf_move_move_items(pSourceList, pDestPath, ap->mf_FileOperation.pCancel, TRUE, ap) == 0) { ap->mf_FileOperation.iOperationSuccessFlag = TRUE; mf_fs_monitor_remove_dir_watch(); - ap->mf_MainWindow.pProgressPopup = mf_popup_create_pb_popup(ap, LABEL_MOVE, MF_MSG_MOVING, count, mf_callback_progress_bar_cancel_cb, ap); + ap->mf_MainWindow.pProgressPopup = mf_popup_create_progress_pb_popup(ap, LABEL_MOVE, MF_MSG_MOVING, count, mf_callback_progress_bar_cancel_cb, ap); } else { mf_callback_cancel_cb(ap, NULL, NULL); } diff --git a/src/common/mf-util.c b/src/common/mf-util.c index f3bdf5c..d2e5a3f 100755 --- a/src/common/mf-util.c +++ b/src/common/mf-util.c @@ -151,21 +151,16 @@ static int __mf_util_is_mmc_supported(int *supported) void mf_file_decompression_start(void *data) { struct appdata *ap = (struct appdata *)data; - Evas_Object *popup; - popup = elm_popup_add(ap->mf_MainWindow.pMainLayout); - elm_object_signal_emit(popup, "elm,action,center_popup,entry", ""); + ap->mf_MainWindow.pProgressPopup = mf_popup_create_progress_pb_popup(ap, MF_LABEL_DECOMPRESS, MF_LABEL_DECOMPRESSING, 10, mf_callback_cancel_cb, ap);; - Evas_Object *layout = mf_popup_entry_layout_create(popup); - elm_object_content_set(popup, layout); - Evas_Object *progressbar; + evas_object_show(ap->mf_MainWindow.pProgressPopup); + if (ap->mf_FileOperation.sync_pipe != NULL) { + ecore_pipe_del(ap->mf_FileOperation.sync_pipe); + ap->mf_FileOperation.sync_pipe = NULL; + } - progressbar = elm_progressbar_add(layout); - elm_object_style_set(progressbar, "wheel"); - evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_progressbar_pulse(progressbar, EINA_TRUE); - evas_object_show(progressbar); + ap->mf_FileOperation.sync_pipe = ecore_pipe_add(__mf_decompress_pipe_cb, ap); pthread_t thread; @@ -173,44 +168,38 @@ void mf_file_decompression_start(void *data) pthread_attr_init(&attr); int ret; - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&thread, &attr,(void *)& mf_callback_decompress_cb, (void *) ap); + pthread_detach(thread); - pthread_join(thread, NULL); - SAFE_FREE_OBJ(progressbar); } void mf_file_compression_start(void *data) { struct appdata *ap = (struct appdata *)data; - Evas_Object *popup; - popup = elm_popup_add(ap->mf_MainWindow.pMainLayout); - elm_object_signal_emit(popup, "elm,action,center_popup,entry", ""); - Evas_Object *layout = mf_popup_entry_layout_create(popup); - elm_object_content_set(popup, layout); + ap->mf_MainWindow.pProgressPopup = mf_popup_create_progress_pb_popup(ap, MF_LABEL_COMPRESS, MF_LABEL_COMPRESSING, 10, mf_callback_cancel_cb, ap);; + + + evas_object_show(ap->mf_MainWindow.pProgressPopup); + + if (ap->mf_FileOperation.sync_pipe != NULL) { + ecore_pipe_del(ap->mf_FileOperation.sync_pipe); + ap->mf_FileOperation.sync_pipe = NULL; + } - Evas_Object *progressbar = NULL; + ap->mf_FileOperation.sync_pipe = ecore_pipe_add(__mf_compress_pipe_cb, ap); - progressbar = elm_progressbar_add(layout); - elm_object_style_set(progressbar, "wheel"); - evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_progressbar_pulse(progressbar, EINA_TRUE); - evas_object_show(progressbar); pthread_t thread; pthread_attr_t attr; pthread_attr_init(&attr); int ret; - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&thread, NULL,(void *)& mf_callback_compress_cb, (void *) ap); - pthread_join(thread, NULL); -// mf_view_update(ap); - SAFE_FREE_OBJ(progressbar); - mf_callback_cancel_cb(ap,NULL,NULL); + pthread_detach(thread); } /****************************** diff --git a/src/widget/mf-popup.c b/src/widget/mf-popup.c index 9b154e6..02bd5da 100755 --- a/src/widget/mf-popup.c +++ b/src/widget/mf-popup.c @@ -564,9 +564,6 @@ Evas_Object *mf_popup_create_pb_popup(void *data, char *title, char *context, in elm_object_focus_set(popup, EINA_FALSE); - /*if (title) { - mf_object_text_set(popup, title, "title,text"); - }*/ char edj_path[1024] = {0}; char *path = app_get_resource_path(); snprintf(edj_path, 1024, "%s%s/%s", path, "edje", EDJ_NAME); @@ -582,16 +579,91 @@ Evas_Object *mf_popup_create_pb_popup(void *data, char *title, char *context, in elm_object_focus_set(progressbar, EINA_FALSE); ap->mf_FileOperation.progress_bar = progressbar; elm_object_style_set(progressbar, "wheel"); + evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(progressbar); + + elm_object_part_content_set(layout, "elm.swallow.progressbar", progressbar); + mf_object_text_set(layout, context, "elm.title"); + elm_object_content_set(popup, layout); + evas_object_show(popup); + evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, __mf_popup_pb_popup_del_cb, ap); + if (func) { + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, func, param); + } else { + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL); + } + + return popup; +} + +/****************************** +** Prototype : mf_popup_create_progress_pb_popup +** Description : +** Input : void *data +** char *context +** int file_count +** void*func +** void* param +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2016/13/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +Evas_Object *mf_popup_create_progress_pb_popup(void *data, char *title, char *context, int file_count, void *func, void *param) +{ + + struct appdata *ap; + + ap = (struct appdata *)data; + assert(ap); + + char count[256] = {0,}; + Evas_Object *popup = NULL; + Evas_Object *progressbar = NULL; + Evas_Object *layout = NULL; + + snprintf(count, sizeof(count), "%s0/%d", count, file_count); + popup = elm_popup_add(ap->mf_MainWindow.pMainLayout); + + elm_object_focus_set(popup, EINA_FALSE); + + if (title) { + mf_object_text_set(popup, title, "title,text"); + } + char edj_path[1024] = {0}; + char *path = app_get_resource_path(); + snprintf(edj_path, 1024, "%s%s/%s", path, "edje", EDJ_NAME); + free(path); + + layout = elm_layout_add(popup); + elm_object_focus_set(layout, EINA_FALSE); + elm_layout_file_set(layout, edj_path, "popup_center_progressview"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + ap->mf_MainWindow.pProgressLayout = layout; + + progressbar = elm_progressbar_add(popup); + elm_object_focus_set(progressbar, EINA_FALSE); + ap->mf_FileOperation.progress_bar = progressbar; + elm_object_style_set(progressbar, "list_progress"); elm_progressbar_horizontal_set(progressbar, EINA_TRUE); evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - //elm_progressbar_value_set(progressbar, 0.0); + elm_progressbar_value_set(progressbar, 0.0); + elm_progressbar_unit_format_set(progressbar, NULL); elm_progressbar_pulse(progressbar, EINA_TRUE); evas_object_show(progressbar); elm_object_part_content_set(layout, "elm.swallow.progressbar", progressbar); mf_object_text_set(layout, context, "elm.title"); - /*{//Fixing the P140801-06774 + {//Fixing the P140801-06774 char *fileName = NULL; char *name = NULL; if (ap->mf_FileOperation.pSourceList != NULL) { @@ -607,19 +679,17 @@ Evas_Object *mf_popup_create_pb_popup(void *data, char *title, char *context, in free(name); } } - elm_object_part_text_set(layout, "elm.text.left", "0%"); - elm_object_part_text_set(layout, "elm.text.right", count);*/ elm_object_content_set(popup, layout); - /*Evas_Object *btn1 = mf_object_create_button(popup, - NULL, //"popup_button/default", + Evas_Object *btn1 = mf_object_create_button(popup, + NULL, LABEL_CANCEL, NULL, func, param, EINA_FALSE); - elm_object_part_content_set(popup, "button1", btn1);*/ + elm_object_part_content_set(popup, "button1", btn1); evas_object_show(popup); evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, __mf_popup_pb_popup_del_cb, ap); -- 2.7.4