Added Default Thumbnail when empty thumbnail is received 94/88394/5 submit/tizen_mobile/20160917.144904
authorbhutani.92 <bhutani.92@samsung.com>
Sat, 17 Sep 2016 07:25:05 +0000 (12:55 +0530)
committerbhutani.92 <bhutani.92@samsung.com>
Sat, 17 Sep 2016 10:37:47 +0000 (16:07 +0530)
Change-Id: Ib5f0ff4f863bbbce9bb83ffb06bbd3aee8941028
Signed-off-by: bhutani.92 <bhutani.92@samsung.com>
CMakeLists.txt
src/common/file-operation/mf-miniunzip.c
src/common/file-operation/mf-minizip.c
src/common/file-system/mf-file-attr.c
src/common/mf-callback.c
src/common/mf-fm-svc-wrapper.c
src/mf-main.c
src/thumbnail/mf-thumb-gen.c
src/widget/mf-decompress-view.c
src/widget/mf-genlist.c
src/widget/mf-view.c

index a3eeb0a..74f32fc 100755 (executable)
@@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES(${SRC-DIR}/thumbnail)
 SET( SRCS
        ${SRC-DIR}/mf-main.c
        ${UTILITY-DIR}/mf-callback.c
+       ${UTILITY-DIR}/mf-otg.c
        ${UTILITY-DIR}/mf-util.c
        ${UTILITY-DIR}/mf-file-util.c
        ${UTILITY-DIR}/mf-ta.c
@@ -165,6 +166,7 @@ ADD_DEFINITIONS("-DMYFILE_SEARCH_STRING")
 ADD_DEFINITIONS("-DMYFILE_ENABLE_FOCUS")
 ADD_DEFINITIONS("-DMYFILE_CATEGORY_VIEW")
 ADD_DEFINITIONS("-DMYFILE_HIDEN_FILES_SHOW")
+ADD_DEFINITIONS("-DMYFILE_USB_OTG")
 #END_START_PUBLIC_REMOVED_STRING
 #ADD_DEFINITIONS("-DMYFILE_DOWNLOAD_APP_FEATURE")
 
index 603b0c0..12f2846 100644 (file)
@@ -57,7 +57,7 @@ int mf_create_dir(char *newdir)
        }
 
        buffer = (char*)malloc(len+1);
-       strcpy(buffer,newdir);
+       strncpy(buffer,newdir, strlen(newdir));
 
        if (buffer[len-1] == '/') {
                buffer[len-1] = '\0';
@@ -178,7 +178,7 @@ int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path,
        void *id;
 
        EINA_LIST_FOREACH(ap->edit_file_list, temp, id) {
-               if (!strcmp(filename_inzip, (char *)id)) {
+               if (id && !strcmp(filename_inzip, (char *)id)) {
                        file_found = 1;
                        break;
                } else {
@@ -455,12 +455,12 @@ int mf_do_file_unzip(void *data, int argc, char **argv)
 
                uf = unzOpen(zipfilename);
                if (uf==NULL) {
-                       strcat(filename_try,".zip");
+                       strncat(filename_try,".zip", strlen(".zip"));
                        uf = unzOpen(filename_try);
                }
        }
 
-       if (uf==NULL) {
+       if (uf == NULL) {
                mf_debug("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
                return 1;
        }
index 8b8b7dc..013af6f 100644 (file)
@@ -184,13 +184,13 @@ int mf_file_do_zip(int argc, char **argv, char *cwd)
                        }
 
                if (dot_found==0) {
-                       strcat(filename_try,".zip");
+                       strncat(filename_try,".zip", strlen(".zip"));
                } else {
                        char * ext = strrchr(filename_try, '.');
                        if (ext) {
                                *ext = '\0';
                        }
-                       strcat(filename_try,".zip");
+                       strncat(filename_try,".zip", strlen(".zip"));
                }
 
                if (opt_overwrite==2) {
@@ -221,7 +221,7 @@ int mf_file_do_zip(int argc, char **argv, char *cwd)
                                                        (argv[i][1]=='p') || (argv[i][1]=='P') ||
                                                        ((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
                                                        (strlen(argv[i]) == 2))) {
-                               FILE * fin;
+                               FILE * fin = NULL;
                                int size_read;
                                const char* filenameinzip = argv[i];
                                zip_fileinfo zi;
index edf3090..d2ecb83 100755 (executable)
@@ -1022,7 +1022,7 @@ static bool __mf_local_data_get_media_thumbnail_cb(media_info_h media, void *dat
        media_info_clone(tmp_data->media, media);
        int retcode = media_info_get_thumbnail_path(media, &(tmp_data->thumb_path));
        if (retcode != MEDIA_CONTENT_ERROR_NONE) {
-               mf_debug("Get media thumbnail path failed!![%d]", retcode);
+               mf_error("Get media thumbnail path failed!![%d]", retcode);
        }
 
        return false;
@@ -1058,7 +1058,7 @@ int mf_file_attr_get_file_icon(const char *file_path, int *error_code, int view_
                        return thumbnail_type;
                }
 
-               mf_error("mime is [%s]", mime);
+               mf_debug("mime is [%s]", mime);
                for (index = 0; mime_type[index].mime; index++) {
                        if (strncmp(mime, mime_type[index].mime, strlen(mime)) == 0) {
                                ftype_by_mime = mime_type[index].ftype;
@@ -1083,7 +1083,6 @@ int mf_file_attr_get_file_icon(const char *file_path, int *error_code, int view_
                memset(&tmp_data, 0x00, sizeof(mf_transfer_data_s));
                tmp_data.file_path = file_path;
                tmp_data.media = media_info;
-               //err = mf_file_attr_get_thumbnail(&tmp_data);
                char *condition = NULL;
                condition = g_strdup_printf("%s and MEDIA_PATH=\"%s\"", MF_CONDITION_IMAGE_VIDEO, tmp_data.file_path);
                err = mf_media_content_data_get(&tmp_data, condition, __mf_local_data_get_media_thumbnail_cb);
index cb60c1d..ae29585 100755 (executable)
@@ -2516,13 +2516,15 @@ void mf_callback_compress_rename_cb(void *data, Evas_Object *obj, void *event_in
        char *text = strdup(str);
 
        text = strrchr(text,'/');
-       text++;
-       char * ext = strrchr(text, '.');
-       if(ext){
-               *ext = '\0';
-       }
+       if (text) {
+               text++;
+               char * ext = strrchr(text, '.');
+               if (ext){
+                       *ext = '\0';
+               }
 
-       elm_entry_entry_set(en, text);
+               elm_entry_entry_set(en, text);
+       }
        elm_entry_select_all(en);
 
        mf_object_text_set(popup, LABEL_RENAME_CHAP, "title,text");
@@ -4630,8 +4632,9 @@ bool mf_callback_create_thumbnail(void *data, media_thumbnail_completed_cb callb
                                pListData);
                if (ret != MEDIA_CONTENT_ERROR_NONE) {
                        mf_debug("Failed to create thumbnail! ret is [%d]", ret);
+                       mf_debug("Switching back to default image");
                        if (pListData->file_type == FILE_TYPE_IMAGE || pListData->file_type == FILE_TYPE_VIDEO) {
-                               pListData->thumb_path = g_strdup(pListData->m_ItemName->str);
+                               pListData->thumb_path = g_strdup(mf_file_attr_get_default_icon_by_type(pListData->file_type));
                        }
                        return -1;
                } else {
@@ -5209,12 +5212,11 @@ void mf_callback_decompress_replace_cb(void *data, Evas_Object *obj, void *event
        }
 
        snprintf(olddir,strlen(temp)+8, "rm -rf %s", temp);
-       if (temp) {
-               g_free(temp);
-       }
+
        mf_debug("old dir is %s", olddir);
        int err = system(olddir);
        if (err == -1) {
+               SAFE_FREE_G_CHAR(temp);
                mf_debug("unable to delete file");
                return;
        } else {
@@ -5223,10 +5225,12 @@ void mf_callback_decompress_replace_cb(void *data, Evas_Object *obj, void *event
        char *ptemp = strrchr(dest, '.');
        if (ptemp) {
                *ptemp = '\0';
+               strncpy(ptemp, "\0\0\0\0", 4);
        }
-       strncpy(ptemp, "\0\0\0\0", 4);
        ap->dir_name = g_strdup(dest);
        mf_file_decompression_start(ap);
+
+       SAFE_FREE_G_CHAR(temp);
        return;
 }
 
@@ -5238,7 +5242,7 @@ void mf_callback_decompress_rename_cb(void *data, Evas_Object *obj, void *event_
 
        char *ptr = strstr(dest_string, ".zip");
        if (ptr) {
-               strcpy(ptr,"\0");
+               ptr = NULL;
        }
        GString *fullpath = g_string_new(dest_string);
        GString *filename = NULL;
@@ -5290,7 +5294,9 @@ void mf_file_compress_cb(void *data, Evas_Object *obj, void *event_info)
                        l = source_folder_list;
                }
                it = eina_list_data_get(l);
-               dest_name = g_strdup(it->str);
+               if (it && it>str) {
+                       dest_name = g_strdup(it->str);
+               }
        } else{
                if(mf_util_get_eina_list_len(source_file_list)) {
                        it = eina_list_last_data_get(source_file_list);
@@ -5303,11 +5309,11 @@ void mf_file_compress_cb(void *data, Evas_Object *obj, void *event_info)
 
 
        char * ext = strrchr(dest_name, '/');
-       if(ext){
+       if (ext){
                ext++;
+               snprintf(str, strlen(dest_name)+strlen(ext)+7, "%s/%s.zip", dest_name, ext );
        }
 
-       snprintf(str, strlen(dest_name)+strlen(ext)+7, "%s/%s.zip", dest_name, ext );
 
        mf_debug("\destination is  %s", dest_name);
        mf_debug("string dest is %s", str);
@@ -5342,8 +5348,8 @@ void mf_callback_decompress_done_cb(void *data, Evas_Object *obj, void *event_in
        char *ptemp = strrchr(dest, '.');
        if (ptemp) {
                *ptemp = '\0';
+               strncpy(ptemp, "\0\0\0\0", 4);
        }
-       strncpy(ptemp, "\0\0\0\0", 4);
 
        mf_debug("directory name is %s", dest);
 
index a59e14d..46a544e 100755 (executable)
@@ -290,11 +290,12 @@ int mf_fm_svc_wrapper_file_auto_rename(void *data, GString *fullpath, int file_n
        *filename = mf_fm_svc_wrapper_get_file_parent_path(fullpath);
        GString *file_name = mf_fm_svc_wrapper_get_file_name(fullpath);
 
-       mf_debug("filename is %s", (*filename)->str);
-
        if (*filename == NULL || file_name == NULL) {
                return MYFILE_ERR_GENERATE_NAME_FAIL;
        }
+
+       mf_debug("filename is %s", (*filename)->str);
+
        if ((*filename)->str == NULL || file_name->str == NULL) {
                mf_debug("filename->str is NULL");
                g_string_free(*filename, TRUE);
index 7a819bb..e5ea15b 100755 (executable)
@@ -22,7 +22,6 @@
 #include <app.h>
 #include <Elementary.h>
 #include <system_settings.h>
-#include <E_DBus.h>
 #include <gio/gio.h>
 
 #include "mf-download-app.h"
index 8c8b893..cdc6985 100755 (executable)
@@ -77,7 +77,7 @@ static int myfile_thumb_update_filelist(ThumbGen *pThumbGen)
 
        _mf_thumb_gen_lock();
        if (pThumbGen->bIsRealize == FALSE) {
-               mf_debug(" == pThumbGen->bIsRealize is Fail ==");
+               mf_debug("pThumbGen->bIsRealize is Fail");
                _mf_thumb_gen_unlock();
                return 0;
        }
@@ -96,7 +96,7 @@ static int myfile_thumb_update_filelist(ThumbGen *pThumbGen)
        thumbnail_h thumb_handle;
        while (true) {
                list_tmp = file_list->prev;
-               MF_THUMBNAIL_DEBUG("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>list_tmp = %p", list_tmp);
+               MF_THUMBNAIL_DEBUG("list_tmp = %p", list_tmp);
                if (list_tmp == NULL) {
                        break;
                } else {
@@ -104,9 +104,9 @@ static int myfile_thumb_update_filelist(ThumbGen *pThumbGen)
                }
        }
 
-       MF_THUMBNAIL_DEBUG("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>path = %s", path);
-       MF_THUMBNAIL_DEBUG("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>file_list = %x", pThumbGen->file_list);
-       MF_THUMBNAIL_DEBUG("\nfile count is [%d]", file_count);
+       MF_THUMBNAIL_DEBUG("path = %s", path);
+       MF_THUMBNAIL_DEBUG("file_list = %x", pThumbGen->file_list);
+       MF_THUMBNAIL_DEBUG("file count is [%d]", file_count);
 
        EINA_LIST_FOREACH(file_list, l, pNode) {
                if (pNode) {
@@ -116,7 +116,7 @@ static int myfile_thumb_update_filelist(ThumbGen *pThumbGen)
                        }
 
                        if (pNode != NULL && pNode->name != NULL && pNode->path != NULL) {
-                               MF_THUMBNAIL_DEBUG("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>pNode->path = %s, pNode->name=%s", pNode->path, pNode->name);
+                               MF_THUMBNAIL_DEBUG("pNode->path = %s, pNode->name = %s, pNode->type = %d", pNode->path, pNode->name, pNode->type);
 
                                switch (pNode->type) {
                                case FILE_TYPE_IMAGE:
@@ -127,14 +127,11 @@ static int myfile_thumb_update_filelist(ThumbGen *pThumbGen)
 
                                        pNode->thumbnail_path = calloc(1, sizeof(char) * MF_FILE_NAME_MAX_LENGTH);
                                        if (pNode->thumbnail_path != NULL) {
-                                               MF_THUMBNAIL_DEBUG("\n>>>>>1");
                                                snprintf(pNode->thumbnail_path, MF_FILE_NAME_MAX_LENGTH - 1, MF_THUMB_FILE_NAME_STR, pNode->name);
-                                               MF_THUMBNAIL_DEBUG("\n>>>>>2");
                                                char tmp_path[MF_FILE_NAME_MAX_LENGTH + 1] = {0};
-                                               MF_THUMBNAIL_DEBUG("\n>>>>>3");
+                                               mf_debug("thumbnail path %s and name : %s", pNode->path, pNode->name);
                                                snprintf(tmp_path, MF_FILE_NAME_MAX_LENGTH - 1, "%s/%s", pNode->path, pNode->name);
-                                               MF_THUMBNAIL_DEBUG("\n>>>>>4");
-                                               MF_THUMBNAIL_DEBUG("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>pNode->thumbnail_path1 = %s", pNode->thumbnail_path);
+                                               MF_THUMBNAIL_DEBUG("pNode->thumbnail_path = %s", pNode->thumbnail_path);
                                                thumbnail_util_create(&thumb_handle);
                                                if (thumb_handle) {
                                                        thumbnail_util_set_path(thumb_handle, tmp_path);
@@ -154,7 +151,7 @@ static int myfile_thumb_update_filelist(ThumbGen *pThumbGen)
                                        if (pThumbGen->bIscancel == true) {
                                                goto EXIT;
                                        }
-                                       MF_THUMBNAIL_DEBUG("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>pNode->thumbnail_path2 = %s", pNode->thumbnail_path);
+                                       MF_THUMBNAIL_DEBUG("pNode->thumbnail_path = %s", pNode->thumbnail_path);
                                        break;
                                }
                                default:
index 7d80f13..c2f30a0 100644 (file)
@@ -139,7 +139,7 @@ static Evas_Object * __mf_decompress_view_create_content(void *data)
        uf = unzOpen(source_name);
        if (uf==NULL)
        {
-               strcat(source_name,".zip");
+               strncat(source_name,".zip", strlen(".zip"));
                uf = unzOpen(source_name);
        }
 
index 8d0e920..e88efd6 100755 (executable)
@@ -177,11 +177,7 @@ void mf_genlist_get_thumbnail(mfItemData_s *params)
        int error_code = 0;
        if (params->file_type == FILE_TYPE_DIR) {
                mf_error("params->thumb_path is [%s]", params->thumb_path);
-               //if (params->storage_type == MYFILE_MMC) {
                params->thumb_path = strdup(MF_ICON_FOLDER);
-               //} else  {
-               //      params->thumb_path = strdup(MF_ICON_FOLDER);
-               //}
                params->real_thumb_flag = TRUE;
                params->thumbnail_type = MF_THUMBNAIL_DEFAULT;
        } else {  /* nor directory */
@@ -205,7 +201,6 @@ void mf_genlist_get_thumbnail(mfItemData_s *params)
                                        params->real_thumb_flag = TRUE;
                                        params->thumbnail_type = MF_THUMBNAIL_THUMB;
                                } else {    /* must be image/video file */
-
                                        if (params->file_type == FILE_TYPE_VIDEO) {
                                                params->thumb_path = strdup(MF_ICON_VIDEO);
                                        } else if (params->file_type == FILE_TYPE_IMAGE) {
@@ -468,8 +463,6 @@ static Evas_Object *__mf_genlist_gl_default_icon_get_lite(void *data, Evas_Objec
        char *path = app_get_resource_path();
        snprintf(edj_path, 1024, "%s%s/%s", path, "edje", EDJ_IMAGE);
        if (!strcmp(part, "elm.icon.folder")) {
-
-
                if (params->list_type == mf_list_shortcut) {
                        mf_debug("image need to be added here");
                        Evas_Object *img = elm_image_add(obj);
@@ -607,7 +600,6 @@ static Evas_Object *__mf_genlist_gl_default_icon_get_lite(void *data, Evas_Objec
                     is_phone_or_mmc && params->m_ItemName->str);
 
                if (params->thumbnail_type == MF_THUMBNAIL_DEFAULT && (is_using_original_image_at_phone_or_mmc == false)) {
-                       mf_debug("1");
 
                        thumb = elm_image_add(obj);
                        elm_image_prescale_set(thumb, MF_GENLIST_THUMBNAIL_SIZE);
@@ -627,18 +619,15 @@ static Evas_Object *__mf_genlist_gl_default_icon_get_lite(void *data, Evas_Objec
                                }
                        } else {
                                if (g_is_refresh_at_glist == false) {
-                                       mf_debug("1");
                                        mf_view_refresh_thumbnail_for_other_memory(ap, ap->mf_FileOperation.file_list);
                                } else {
-                                       mf_debug("2");
                                        if (params->pNode && params->pNode->thumbnail_path) { //For supporting the otg thumbnail
-                                               mf_debug("21 params->pNode->thumbnail_path=%s", params->pNode->thumbnail_path);
+                                               mf_debug("params->pNode->thumbnail_path=%s", params->pNode->thumbnail_path);
                                                //elm_image_file_set(thumb, EDJ_IMAGE, params->pNode->thumbnail_path);
                                                elm_image_file_set(thumb, params->pNode->thumbnail_path, NULL);
                                                //elm_object_part_content_set(layout, "default_thumbnail", thumb);
                                                //elm_layout_content_set(layout, "elm.swallow.content", thumb);
                                        } else {
-                                               mf_debug("22");
                                                thumb = elm_image_add(obj);
                                                elm_image_fill_outside_set(thumb, EINA_TRUE);
                                                if (params->file_type == FILE_TYPE_IMAGE) {
@@ -662,7 +651,6 @@ static Evas_Object *__mf_genlist_gl_default_icon_get_lite(void *data, Evas_Objec
                        elm_image_fill_outside_set(thumb, EINA_FALSE);
                        elm_image_smooth_set(thumb, EINA_FALSE);
                        if (is_using_original_image_at_phone_or_mmc) {//Fixed the P131112-03632.
-                               mf_debug("51");
                                //Checking file size, if more than 4M, don't display it, it will be very slow.
                                /*off_t size = 0;//Comment it, for P140606-04570, some times at efl, it will crash at png file.
                                      mf_file_attr_get_file_size(params->m_ItemName->str, &size);
@@ -672,7 +660,6 @@ static Evas_Object *__mf_genlist_gl_default_icon_get_lite(void *data, Evas_Objec
                                        mf_view_refresh_thumbnail_for_other_memory(ap, ap->mf_FileOperation.file_list);
                                } else {*/
                                        if (params->pNode && params->pNode->thumbnail_path) {//For supporting the otg thumbnail
-                                               mf_debug("53");
                                                //elm_image_file_set(thumb, EDJ_IMAGE, params->pNode->thumbnail_path);
                                                elm_image_file_set(thumb, params->pNode->thumbnail_path, NULL);
                                                //      elm_object_part_content_set(layout, "default_thumbnail", thumb);
index 576c6ab..265e10f 100755 (executable)
@@ -373,8 +373,8 @@ Elm_Object_Item *mf_view_item_append(Evas_Object *parent, fsNodeInfo *pNode, voi
                }
        } else {
                if (!(m_TempItem->real_thumb_flag && m_TempItem->thumb_path)) {
-                       //mf_genlist_get_thumbnail(m_TempItem);
-                       //SECURE_ERROR("================= thumbnail is [%s]", m_TempItem->thumb_path);
+                       /*mf_genlist_get_thumbnail(m_TempItem);
+                       SECURE_ERROR("================= thumbnail is [%s]", m_TempItem->thumb_path);*/
                }
        }