diff options
author | Chandan <ch.kumar@samsung.com> | 2017-01-24 14:37:06 +0530 |
---|---|---|
committer | Chandan <ch.kumar@samsung.com> | 2017-01-24 14:37:06 +0530 |
commit | d55e46ff3b94c9f5693fee812775d3f71b616994 (patch) | |
tree | 784d79f190c418cc34485000f8d363d98f44bdcf | |
parent | 29a4450c7957dbff62d34c7fe09781c5b4d8b319 (diff) | |
download | attach-panel-document-d55e46ff3b94c9f5693fee812775d3f71b616994.tar.gz attach-panel-document-d55e46ff3b94c9f5693fee812775d3f71b616994.tar.bz2 attach-panel-document-d55e46ff3b94c9f5693fee812775d3f71b616994.zip |
Aligned Supported FileTypes with MyFiles
Change-Id: Idf68d3eb40d9edf9a1d15b4dafae5a7a019192f3
Signed-off-by: Chandan <ch.kumar@samsung.com>
-rw-r--r-- | include/doc-data.h | 54 | ||||
-rw-r--r-- | include/doc-list.h | 51 | ||||
-rw-r--r-- | src/doc-data.c | 447 | ||||
-rw-r--r-- | src/doc-list.c | 424 |
4 files changed, 502 insertions, 474 deletions
diff --git a/include/doc-data.h b/include/doc-data.h index 9302e5e..16ab4a3 100644 --- a/include/doc-data.h +++ b/include/doc-data.h @@ -20,16 +20,70 @@ #include "doc-local-data.h" #include "attach-panel-document.h" + +typedef enum _FILE_TYPE fsFileType; +enum _FILE_TYPE { + FILE_TYPE_NONE = 0, + FILE_TYPE_DIR, /**< Folder category */ + FILE_TYPE_FILE, /**< File category */ + FILE_TYPE_IMAGE, /**< Image category */ + FILE_TYPE_VIDEO, /**< Video category */ + FILE_TYPE_MUSIC, /**< Music category */ + FILE_TYPE_SOUND, /**< Sound category */ + FILE_TYPE_PDF, /**< Pdf category */ + FILE_TYPE_DOC, /**< Word category */ + FILE_TYPE_PPT, /**< Powerpoint category */ + FILE_TYPE_EXCEL, /**< Excel category */ + FILE_TYPE_VOICE, /**< Voice category */ + FILE_TYPE_HTML, /**< Html category */ + FILE_TYPE_FLASH, /**< Flash category */ + FILE_TYPE_GAME, /**< Game category */ + FILE_TYPE_APP, /**< Application category */ + FILE_TYPE_THEME, /**< Theme category */ + FILE_TYPE_TXT, /**< Txt category */ + FILE_TYPE_VCONTACT, /**< Vcontact category */ + FILE_TYPE_VCALENDAR, /**< Vcalendar category */ + FILE_TYPE_VNOTE, /**< Vnote category */ + FILE_TYPE_VBOOKMARK, /**< Vbookmark category */ + FILE_TYPE_VIDEO_PROJECT, /**< Video editor project category */ + FILE_TYPE_RADIO_RECORDED, /**< radio recorded clips category */ + FILE_TYPE_MOVIE_MAKER, /**< Movie maker project category */ + FILE_TYPE_SVG, /**< Svg category */ + FILE_TYPE_RSS, /**< Rss reader file, *.opml */ + FILE_TYPE_CERTIFICATION, /**< certification file, *.pem */ + FILE_TYPE_JAVA, /**< java file, *.jad, *.jar */ + FILE_TYPE_WGT, /**< wrt , *.wgt, *.wgt */ + FILE_TYPE_TPK, /**< *.tpk>*/ + FILE_TYPE_SNB, /**<*.snb> */ + FILE_TYPE_GUL, /**<*.gul> */ + FILE_TYPE_HWP, /**<*.hwp> */ + FILE_TYPE_ETC, /**< Other files category */ + FILE_TYPE_TASK, + FILE_TYPE_EML, + FILE_TYPE_CSV, + FILE_TYPE_SPD, + FILE_TYPE_ZIP, + FILE_TYPE_MAX +}; + #ifdef _cplusplus extern "C" { #endif +#define SAFE_FREE_CHAR(x) do {\ + if ((x) != NULL) {\ + free(x); \ + x = NULL;\ + } \ + } while (0) + typedef int (*doc_restore_selected_cb) (Eina_List * sel_id, doc_item * ditem); int doc_data_get_item_cnt(doc_ugdata * ugd, int *item_cnt); int doc_data_get_sel_paths(doc_ugdata * ugd, char **filepath, char ***filepath_arr, int *cnt); + int document_file_category(const char *filepath, fsFileType * category); int doc_data_get_media_data(doc_ugdata * ugd, int type, int start_pos, int end_pos, Eina_List ** pmedias_elist, doc_restore_selected_cb restore_cb, diff --git a/include/doc-list.h b/include/doc-list.h index a6b00cb..f18bc70 100644 --- a/include/doc-list.h +++ b/include/doc-list.h @@ -19,51 +19,6 @@ #include "attach-panel-document.h" -typedef enum _FILE_TYPE fsFileType; -enum _FILE_TYPE { - FILE_TYPE_NONE = 0, - FILE_TYPE_DIR, /**< Folder category */ - FILE_TYPE_FILE, /**< File category */ - FILE_TYPE_IMAGE, /**< Image category */ - FILE_TYPE_VIDEO, /**< Video category */ - FILE_TYPE_MUSIC, /**< Music category */ - FILE_TYPE_SOUND, /**< Sound category */ - FILE_TYPE_PDF, /**< Pdf category */ - FILE_TYPE_DOC, /**< Word category */ - FILE_TYPE_PPT, /**< Powerpoint category */ - FILE_TYPE_EXCEL, /**< Excel category */ - FILE_TYPE_VOICE, /**< Voice category */ - FILE_TYPE_HTML, /**< Html category */ - FILE_TYPE_FLASH, /**< Flash category */ - FILE_TYPE_GAME, /**< Game category */ - FILE_TYPE_APP, /**< Application category */ - FILE_TYPE_THEME, /**< Theme category */ - FILE_TYPE_TXT, /**< Txt category */ - FILE_TYPE_VCONTACT, /**< Vcontact category */ - FILE_TYPE_VCALENDAR, /**< Vcalendar category */ - FILE_TYPE_VNOTE, /**< Vnote category */ - FILE_TYPE_VBOOKMARK, /**< Vbookmark category */ - FILE_TYPE_VIDEO_PROJECT, /**< Video editor project category */ - FILE_TYPE_RADIO_RECORDED, /**< radio recorded clips category */ - FILE_TYPE_MOVIE_MAKER, /**< Movie maker project category */ - FILE_TYPE_SVG, /**< Svg category */ - FILE_TYPE_RSS, /**< Rss reader file, *.opml */ - FILE_TYPE_CERTIFICATION, /**< certification file, *.pem */ - FILE_TYPE_JAVA, /**< java file, *.jad, *.jar */ - FILE_TYPE_WGT, /**< wrt , *.wgt, *.wgt */ - FILE_TYPE_TPK, /**< *.tpk>*/ - FILE_TYPE_SNB, /**<*.snb> */ - FILE_TYPE_GUL, /**<*.gul> */ - FILE_TYPE_HWP, /**<*.hwp> */ - FILE_TYPE_ETC, /**< Other files category */ - FILE_TYPE_TASK, - FILE_TYPE_EML, - FILE_TYPE_CSV, - FILE_TYPE_SPD, - FILE_TYPE_ZIP, - FILE_TYPE_MAX -}; - /*************** Default Icon ***********************/ #define DOC_DEFAULT_ICON "doc_icon_etc.png" #define DOC_ICON_FOLDER "doc_icon_folder.png" @@ -94,12 +49,6 @@ enum _FILE_TYPE { #define DOC_ICON_ZIP "doc_icon_zip.png" #define DOC_ICON_SVG "doc_icon_svg.png" -#define SAFE_FREE_CHAR(x) do {\ - if ((x) != NULL) {\ - free(x); \ - x = NULL;\ - } \ - } while (0) void doc_list_change_selection_mode(doc_ugdata * ugd); int doc_list_lang_update(doc_ugdata * ugd); int doc_update_genlist(doc_ugdata * ugd); diff --git a/src/doc-data.c b/src/doc-data.c index 5a5d6e8..13c254d 100644 --- a/src/doc-data.c +++ b/src/doc-data.c @@ -105,6 +105,428 @@ int doc_data_get_sel_paths(doc_ugdata * ugd, char **filepath, return 0; } +static fsFileType _document_attr_get_category_by_file_ext(const char + *file_ext) +{ + int i = 0; + + if (file_ext == NULL) { + return FILE_TYPE_ETC; + } + + if (file_ext[0] == '.') { + i = 1; + } + + switch (file_ext[i]) { + case 'a': + case 'A': + if (strcasecmp("ASF", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("AMR", &file_ext[i]) == 0) { + return FILE_TYPE_VOICE; + } + if (strcasecmp("AWB", &file_ext[i]) == 0) { + return FILE_TYPE_VOICE; + } + if (strcasecmp("AAC", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + if (strcasecmp("AVI", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("AAC", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + + break; + case 'b': + case 'B': + if (strcasecmp("BMP", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + break; + case 'c': + case 'C': + if (strcasecmp("csv", &file_ext[i]) == 0) { + return FILE_TYPE_CSV; + } + break; + case 'd': + case 'D': + if (strcasecmp("DOC", &file_ext[i]) == 0) { + return FILE_TYPE_DOC; + } + if (strcasecmp("DOCX", &file_ext[i]) == 0) { + return FILE_TYPE_DOC; + } + if (strcasecmp("DIVX", &file_ext[i]) == 0) { + { + return FILE_TYPE_VIDEO; + } + } + break; + case 'E': + case 'e': + if (strcasecmp("EML", &file_ext[i]) == 0) { + return FILE_TYPE_EML; + } + break; + case 'f': + case 'F': + if (strcasecmp("FLAC", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + break; + case 'g': + case 'G': + if (strcasecmp("GIF", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + if (strcasecmp("G72", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + if (strcasecmp("GUL", &file_ext[i]) == 0) { + return FILE_TYPE_GUL; + } + break; + case 'h': + case 'H': + if (strcasecmp("HTML", &file_ext[i]) == 0) { + return FILE_TYPE_HTML; + } + if (strcasecmp("HTM", &file_ext[i]) == 0) { + return FILE_TYPE_HTML; + } + if (strcasecmp("HWP", &file_ext[i]) == 0) { + return FILE_TYPE_HWP; + } + break; + case 'i': + case 'I': + if (strcasecmp("IMY", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("IPK", &file_ext[i]) == 0) { + return FILE_TYPE_APP; + } + if (strcasecmp("ICS", &file_ext[i]) == 0) { + return FILE_TYPE_VCALENDAR; + } + break; + case 'j': + case 'J': + if (strcasecmp("JAD", &file_ext[i]) == 0) { + return FILE_TYPE_JAVA; + } + if (strcasecmp("JAR", &file_ext[i]) == 0) { + return FILE_TYPE_JAVA; + } + + if (strcasecmp("JPG", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + if (strcasecmp("JPEG", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + if (strcasecmp("JPE", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + if (strcasecmp("JP2", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + break; + case 'm': + case 'M': + if (strcasecmp("MMF", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("MP3", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + if (strcasecmp("MID", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("MIDI", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("MP4", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("MPG", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("MPEG", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("M4A", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + if (strcasecmp("M3G", &file_ext[i]) == 0) { + return FILE_TYPE_FLASH; + } + if (strcasecmp("MXMF", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("MKV", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("MKA", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + break; + case 'o': + case 'O': + if (strcasecmp("opml", &file_ext[i]) == 0) { + return FILE_TYPE_RSS; + } + if (strcasecmp("ogg", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + break; + case 'p': + case 'P': + if (strcasecmp("PNG", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + if (strcasecmp("PJPEG", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + if (strcasecmp("PDF", &file_ext[i]) == 0) { + return FILE_TYPE_PDF; + } + if (strcasecmp("PPT", &file_ext[i]) == 0) { + return FILE_TYPE_PPT; + } + if (strcasecmp("PPTX", &file_ext[i]) == 0) { + return FILE_TYPE_PPT; + } + if (strcasecmp("PEM", &file_ext[i]) == 0) { + return FILE_TYPE_CERTIFICATION; + } + break; + case 'r': + case 'R': + if (strcasecmp("RA", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + if (strcasecmp("RTF", &file_ext[i]) == 0) { + return FILE_TYPE_DOC; + } + break; + case 's': + case 'S': + if (strcasecmp("SDP", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("SPM", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("SMP", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("SPF", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("SWF", &file_ext[i]) == 0) { + return FILE_TYPE_FLASH; + } + if (strcasecmp("SCN", &file_ext[i]) == 0) { + return FILE_TYPE_MOVIE_MAKER; + } + if (strcasecmp("SVG", &file_ext[i]) == 0) { + return FILE_TYPE_SVG; + } + if (strcasecmp("SVGZ", &file_ext[i]) == 0) { + return FILE_TYPE_SVG; + } + if (strcasecmp("SNB", &file_ext[i]) == 0) { + return FILE_TYPE_SNB; + } + if (strcasecmp("SPD", &file_ext[i]) == 0) { + return FILE_TYPE_SPD; + } + + break; + case 't': + case 'T': + if (strcasecmp("TXT", &file_ext[i]) == 0) { + return FILE_TYPE_TXT; + } + if (strcasecmp("THM", &file_ext[i]) == 0) { + return FILE_TYPE_THEME; + } + if (strcasecmp("TPK", &file_ext[i]) == 0) { + return FILE_TYPE_TPK; + } + if (strcasecmp("TIF", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + break; + case 'v': + case 'V': + if (strcasecmp("VCF", &file_ext[i]) == 0) { + return FILE_TYPE_VCONTACT; + } + if (strcasecmp("VCS", &file_ext[i]) == 0) { + return FILE_TYPE_VCALENDAR; + } + if (strcasecmp("VNT", &file_ext[i]) == 0) { + return FILE_TYPE_VNOTE; + } + if (strcasecmp("VBM", &file_ext[i]) == 0) { + return FILE_TYPE_VBOOKMARK; + } + if (strcasecmp("VTS", &file_ext[i]) == 0) { + return FILE_TYPE_TASK; + } + break; + case 'w': + case 'W': + if (strcasecmp("WAV", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("WBMP", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + if (strcasecmp("WGT", &file_ext[i]) == 0) { + return FILE_TYPE_WGT; + } + if (strcasecmp("WMA", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + if (strcasecmp("WMV", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("WML", &file_ext[i]) == 0) { + return FILE_TYPE_HTML; + } + if (strcasecmp("WAVE", &file_ext[i]) == 0) { + return FILE_TYPE_MUSIC; + } + if (strcasecmp("WMF", &file_ext[i]) == 0) { + return FILE_TYPE_IMAGE; + } + break; + case 'x': + case 'X': + if (strcasecmp("XLS", &file_ext[i]) == 0) { + return FILE_TYPE_EXCEL; + } + if (strcasecmp("XLSX", &file_ext[i]) == 0) { + return FILE_TYPE_EXCEL; + } + if (strcasecmp("XMF", &file_ext[i]) == 0) { + return FILE_TYPE_SOUND; + } + if (strcasecmp("XHTML", &file_ext[i]) == 0) { + return FILE_TYPE_HTML; + } + if (strcasecmp("XML", &file_ext[i]) == 0) { + return FILE_TYPE_HTML; + } + break; + case 'z': + case 'Z': + if (strcasecmp("ZIP", &file_ext[i]) == 0) { + return FILE_TYPE_ZIP; + } + break; + case '3': + if (strcasecmp("3GP", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("3GPP", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + if (strcasecmp("3G2", &file_ext[i]) == 0) { + return FILE_TYPE_VIDEO; + } + break; + } + + return FILE_TYPE_ETC; +} + +static Eina_Bool _doc_list_is_dir(const char *path) +{ + if (!path) { + return 0; + } + + struct stat info = { 0, }; + + if (stat(path, &info) == 0) { + if (S_ISDIR(info.st_mode)) { + return 1; + } + } + + return 0; +} + +static Eina_Bool _document_attr_is_dir(const char *filepath) +{ + DOC_CHECK_FALSE(filepath); + + return _doc_list_is_dir(filepath); +} + +const char *_document_file_get(const char path[]) +{ + char *file = NULL; + if ((file = strrchr(path, '/'))) { + file++; + } else { + file = (char *) path; + } + + return file; +} + +int document_file_category(const char *filepath, fsFileType * category) +{ + int i = 0; + int flag = 0; + + if (_document_attr_is_dir(filepath)) { + *category = FILE_TYPE_DIR; + return 0; + } + + const char *filename = NULL; + filename = _document_file_get(filepath); + if (filename == NULL) { + *category = FILE_TYPE_NONE; + return -1; + } + char *file_ext = NULL; + /*ToDo: error file name like the last letter is "." */ + for (i = strlen(filename); i >= 0; i--) { + if (filename[i] == '.') { + file_ext = g_strdup(&filename[i + 1]); + flag = 1; + break; + } + + if (filename[i] == '/') { + flag = 0; + break; + } + } + + if (flag == 1) { + *category = _document_attr_get_category_by_file_ext(file_ext); + SAFE_FREE_CHAR(file_ext); + return 0; + } else { + *category = FILE_TYPE_NONE; + SAFE_FREE_CHAR(file_ext); + return -1; + } +} + int doc_data_get_media_data(doc_ugdata * ugd, int type, int start_pos, int end_pos, Eina_List ** pmedias_elist, doc_restore_selected_cb restore_cb, @@ -139,6 +561,31 @@ int doc_data_get_media_data(doc_ugdata * ugd, int type, int start_pos, doc_dbgE("Invalid item!"); continue; } + doc_dbgE("Chandan:: Item is %s", item->display_name); + fsFileType type = FILE_TYPE_NONE; + doc_dbgE("1111111"); + document_file_category(item->display_name, &type); + doc_dbgE("Chandan:: Type is %d", type); + + bool isUnsupported = false; + + switch(type) { + case FILE_TYPE_DOC: + case FILE_TYPE_PDF: + case FILE_TYPE_PPT: + case FILE_TYPE_EXCEL: + case FILE_TYPE_TXT: + case FILE_TYPE_HWP: + case FILE_TYPE_SPD: + case FILE_TYPE_SNB: + break; + default: + doc_dbgE("File Type not supported"); + isUnsupported = true; + break; + } + + if (isUnsupported == true) continue; ditem = doc_data_util_calloc_item(); if (ditem == NULL) { diff --git a/src/doc-list.c b/src/doc-list.c index 8bd31cd..a21bb4d 100644 --- a/src/doc-list.c +++ b/src/doc-list.c @@ -343,428 +343,6 @@ static Evas_Object *_doc_nocontent_create(void *data) return layout; } -static Eina_Bool _doc_list_is_dir(const char *path) -{ - if (!path) { - return 0; - } - - struct stat info = { 0, }; - - if (stat(path, &info) == 0) { - if (S_ISDIR(info.st_mode)) { - return 1; - } - } - - return 0; -} - -static Eina_Bool _document_attr_is_dir(const char *filepath) -{ - DOC_CHECK_FALSE(filepath); - - return _doc_list_is_dir(filepath); -} - -const char *_document_file_get(const char path[]) -{ - char *file = NULL; - if ((file = strrchr(path, '/'))) { - file++; - } else { - file = (char *) path; - } - - return file; -} - -static fsFileType _document_attr_get_category_by_file_ext(const char - *file_ext) -{ - int i = 0; - - if (file_ext == NULL) { - return FILE_TYPE_ETC; - } - - if (file_ext[0] == '.') { - i = 1; - } - - switch (file_ext[i]) { - case 'a': - case 'A': - if (strcasecmp("ASF", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("AMR", &file_ext[i]) == 0) { - return FILE_TYPE_VOICE; - } - if (strcasecmp("AWB", &file_ext[i]) == 0) { - return FILE_TYPE_VOICE; - } - if (strcasecmp("AAC", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - if (strcasecmp("AVI", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("AAC", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - - break; - case 'b': - case 'B': - if (strcasecmp("BMP", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - break; - case 'c': - case 'C': - if (strcasecmp("csv", &file_ext[i]) == 0) { - return FILE_TYPE_CSV; - } - break; - case 'd': - case 'D': - if (strcasecmp("DOC", &file_ext[i]) == 0) { - return FILE_TYPE_DOC; - } - if (strcasecmp("DOCX", &file_ext[i]) == 0) { - return FILE_TYPE_DOC; - } - if (strcasecmp("DIVX", &file_ext[i]) == 0) { - { - return FILE_TYPE_VIDEO; - } - } - break; - case 'E': - case 'e': - if (strcasecmp("EML", &file_ext[i]) == 0) { - return FILE_TYPE_EML; - } - break; - case 'f': - case 'F': - if (strcasecmp("FLAC", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - break; - case 'g': - case 'G': - if (strcasecmp("GIF", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - if (strcasecmp("G72", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - if (strcasecmp("GUL", &file_ext[i]) == 0) { - return FILE_TYPE_GUL; - } - break; - case 'h': - case 'H': - if (strcasecmp("HTML", &file_ext[i]) == 0) { - return FILE_TYPE_HTML; - } - if (strcasecmp("HTM", &file_ext[i]) == 0) { - return FILE_TYPE_HTML; - } - if (strcasecmp("HWP", &file_ext[i]) == 0) { - return FILE_TYPE_HWP; - } - break; - case 'i': - case 'I': - if (strcasecmp("IMY", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("IPK", &file_ext[i]) == 0) { - return FILE_TYPE_APP; - } - if (strcasecmp("ICS", &file_ext[i]) == 0) { - return FILE_TYPE_VCALENDAR; - } - break; - case 'j': - case 'J': - if (strcasecmp("JAD", &file_ext[i]) == 0) { - return FILE_TYPE_JAVA; - } - if (strcasecmp("JAR", &file_ext[i]) == 0) { - return FILE_TYPE_JAVA; - } - - if (strcasecmp("JPG", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - if (strcasecmp("JPEG", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - if (strcasecmp("JPE", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - if (strcasecmp("JP2", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - break; - case 'm': - case 'M': - if (strcasecmp("MMF", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("MP3", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - if (strcasecmp("MID", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("MIDI", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("MP4", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("MPG", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("MPEG", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("M4A", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - if (strcasecmp("M3G", &file_ext[i]) == 0) { - return FILE_TYPE_FLASH; - } - if (strcasecmp("MXMF", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("MKV", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("MKA", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - break; - case 'o': - case 'O': - if (strcasecmp("opml", &file_ext[i]) == 0) { - return FILE_TYPE_RSS; - } - if (strcasecmp("ogg", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - break; - case 'p': - case 'P': - if (strcasecmp("PNG", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - if (strcasecmp("PJPEG", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - if (strcasecmp("PDF", &file_ext[i]) == 0) { - return FILE_TYPE_PDF; - } - if (strcasecmp("PPT", &file_ext[i]) == 0) { - return FILE_TYPE_PPT; - } - if (strcasecmp("PPTX", &file_ext[i]) == 0) { - return FILE_TYPE_PPT; - } - if (strcasecmp("PEM", &file_ext[i]) == 0) { - return FILE_TYPE_CERTIFICATION; - } - break; - case 'r': - case 'R': - if (strcasecmp("RA", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - if (strcasecmp("RTF", &file_ext[i]) == 0) { - return FILE_TYPE_DOC; - } - break; - case 's': - case 'S': - if (strcasecmp("SDP", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("SPM", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("SMP", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("SPF", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("SWF", &file_ext[i]) == 0) { - return FILE_TYPE_FLASH; - } - if (strcasecmp("SCN", &file_ext[i]) == 0) { - return FILE_TYPE_MOVIE_MAKER; - } - if (strcasecmp("SVG", &file_ext[i]) == 0) { - return FILE_TYPE_SVG; - } - if (strcasecmp("SVGZ", &file_ext[i]) == 0) { - return FILE_TYPE_SVG; - } - if (strcasecmp("SNB", &file_ext[i]) == 0) { - return FILE_TYPE_SNB; - } - if (strcasecmp("SPD", &file_ext[i]) == 0) { - return FILE_TYPE_SPD; - } - - break; - case 't': - case 'T': - if (strcasecmp("TXT", &file_ext[i]) == 0) { - return FILE_TYPE_TXT; - } - if (strcasecmp("THM", &file_ext[i]) == 0) { - return FILE_TYPE_THEME; - } - if (strcasecmp("TPK", &file_ext[i]) == 0) { - return FILE_TYPE_TPK; - } - if (strcasecmp("TIF", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - break; - case 'v': - case 'V': - if (strcasecmp("VCF", &file_ext[i]) == 0) { - return FILE_TYPE_VCONTACT; - } - if (strcasecmp("VCS", &file_ext[i]) == 0) { - return FILE_TYPE_VCALENDAR; - } - if (strcasecmp("VNT", &file_ext[i]) == 0) { - return FILE_TYPE_VNOTE; - } - if (strcasecmp("VBM", &file_ext[i]) == 0) { - return FILE_TYPE_VBOOKMARK; - } - if (strcasecmp("VTS", &file_ext[i]) == 0) { - return FILE_TYPE_TASK; - } - break; - case 'w': - case 'W': - if (strcasecmp("WAV", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("WBMP", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - if (strcasecmp("WGT", &file_ext[i]) == 0) { - return FILE_TYPE_WGT; - } - if (strcasecmp("WMA", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - if (strcasecmp("WMV", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("WML", &file_ext[i]) == 0) { - return FILE_TYPE_HTML; - } - if (strcasecmp("WAVE", &file_ext[i]) == 0) { - return FILE_TYPE_MUSIC; - } - if (strcasecmp("WMF", &file_ext[i]) == 0) { - return FILE_TYPE_IMAGE; - } - break; - case 'x': - case 'X': - if (strcasecmp("XLS", &file_ext[i]) == 0) { - return FILE_TYPE_EXCEL; - } - if (strcasecmp("XLSX", &file_ext[i]) == 0) { - return FILE_TYPE_EXCEL; - } - if (strcasecmp("XMF", &file_ext[i]) == 0) { - return FILE_TYPE_SOUND; - } - if (strcasecmp("XHTML", &file_ext[i]) == 0) { - return FILE_TYPE_HTML; - } - if (strcasecmp("XML", &file_ext[i]) == 0) { - return FILE_TYPE_HTML; - } - break; - case 'z': - case 'Z': - if (strcasecmp("ZIP", &file_ext[i]) == 0) { - return FILE_TYPE_ZIP; - } - break; - case '3': - if (strcasecmp("3GP", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("3GPP", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - if (strcasecmp("3G2", &file_ext[i]) == 0) { - return FILE_TYPE_VIDEO; - } - break; - } - - return FILE_TYPE_ETC; -} - -int _document_file_category(const char *filepath, fsFileType * category) -{ - int i = 0; - int flag = 0; - - if (_document_attr_is_dir(filepath)) { - *category = FILE_TYPE_DIR; - return 0; - } - - const char *filename = NULL; - filename = _document_file_get(filepath); - if (filename == NULL) { - *category = FILE_TYPE_NONE; - return -1; - } - char *file_ext = NULL; - /*ToDo: error file name like the last letter is "." */ - for (i = strlen(filename); i >= 0; i--) { - if (filename[i] == '.') { - file_ext = g_strdup(&filename[i + 1]); - flag = 1; - break; - } - - if (filename[i] == '/') { - flag = 0; - break; - } - } - - if (flag == 1) { - *category = _document_attr_get_category_by_file_ext(file_ext); - SAFE_FREE_CHAR(file_ext); - return 0; - } else { - *category = FILE_TYPE_NONE; - SAFE_FREE_CHAR(file_ext); - return -1; - } -} - const char *_document_file_attr_get_default_icon_by_type(fsFileType ftype) { const char *icon_path = DOC_DEFAULT_ICON; @@ -798,7 +376,7 @@ static Evas_Object *_doc_list_item_content_get(void *data, if (!g_strcmp0(part, "elm.swallow.icon")) { fsFileType type = FILE_TYPE_NONE; - _document_file_category(item->item->file_url, &type); + document_file_category(item->item->file_url, &type); const char *thumb = _document_file_attr_get_default_icon_by_type(type); |