diff options
Diffstat (limited to 'src')
29 files changed, 16282 insertions, 0 deletions
diff --git a/src/common/file-system/mf-ug-file-attr.c b/src/common/file-system/mf-ug-file-attr.c new file mode 100644 index 0000000..4376de2 --- /dev/null +++ b/src/common/file-system/mf-ug-file-attr.c @@ -0,0 +1,1319 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <regex.h> +#include <sys/types.h> +#include <media_content.h> +#include <drm_client.h> +#include <drm_client_types.h> +#include "mf-ug-fs-util.h" +#include "mf-ug-util.h" + +#define MF_UG_PHONE_DEFAULT_LEVEL 2 /*the phone path is /opt/media, it consists of opt and media two parts*/ +#define MF_UG_MMC_DEFAULT_LEVEL 3 /*the mmc path is /opt/storage/sdcard, it consists of opt and storage and sdcard three parts*/ +#define CONDITION_LENGTH 200 +#define UG_CONDITION_IMAGE_VIDEO "(MEDIA_TYPE=0 OR MEDIA_TYPE=1)" + +typedef struct __ug_filter_s ug_filter_s; +struct __ug_filter_s { + char *cond; /*set media type or favorite type, or other query statement*/ + media_content_collation_e collate_type; /*collate type*/ + media_content_order_e sort_type; /*sort type*/ + char *sort_keyword; /*sort keyword*/ + int offset; /*offset*/ + int count; /*count*/ + bool with_meta; /*whether get image or video info*/ +}; + +typedef struct __ug_transfer_data_s ug_transfer_data_s; + +struct __ug_transfer_data_s { + const char *file_path; + char *thumbnail_path; +}; + + +struct _ug_ftype_by_mime { + const char *mime; + mf_ug_fs_file_type ftype; +}; + +static struct _ug_ftype_by_mime mime_type[] = { + {"image/png", UG_FILE_TYPE_IMAGE}, + {"image/jpeg", UG_FILE_TYPE_IMAGE}, + {"image/gif", UG_FILE_TYPE_IMAGE}, + {"image/bmp", UG_FILE_TYPE_IMAGE}, + {"image/vnd.wap.wbmp", UG_FILE_TYPE_IMAGE}, + + {"video/x-msvideo", UG_FILE_TYPE_VIDEO}, + {"video/mp4", UG_FILE_TYPE_VIDEO}, + {"video/3gpp", UG_FILE_TYPE_VIDEO}, + {"video/x-ms-asf", UG_FILE_TYPE_VIDEO}, + {"video/x-ms-wmv", UG_FILE_TYPE_VIDEO}, + {"video/x-matroska", UG_FILE_TYPE_VIDEO}, + + {"audio/mpeg", UG_FILE_TYPE_MUSIC}, + {"audio/x-wav", UG_FILE_TYPE_MUSIC}, + {"application/x-smaf", UG_FILE_TYPE_MUSIC}, + {"audio/mxmf", UG_FILE_TYPE_MUSIC}, + {"audio/midi", UG_FILE_TYPE_MUSIC}, + {"audio/x-xmf", UG_FILE_TYPE_MUSIC}, + {"audio/x-ms-wma", UG_FILE_TYPE_MUSIC}, + {"audio/aac", UG_FILE_TYPE_MUSIC}, + {"audio/ac3", UG_FILE_TYPE_MUSIC}, + {"audio/ogg", UG_FILE_TYPE_MUSIC}, + {"audio/vorbis", UG_FILE_TYPE_MUSIC}, + {"audio/imelody", UG_FILE_TYPE_MUSIC}, + {"audio/iMelody", UG_FILE_TYPE_MUSIC}, + {"audio/x-rmf", UG_FILE_TYPE_MUSIC}, + {"application/vnd.smaf", UG_FILE_TYPE_MUSIC}, + {"audio/mobile-xmf", UG_FILE_TYPE_MUSIC}, + {"audio/mid", UG_FILE_TYPE_MUSIC}, + {"audio/vnd.ms-playready.media.pya", UG_FILE_TYPE_MUSIC}, + {"audio/imy", UG_FILE_TYPE_MUSIC}, + {"audio/m4a", UG_FILE_TYPE_MUSIC}, + {"audio/melody", UG_FILE_TYPE_MUSIC}, + {"audio/mmf", UG_FILE_TYPE_MUSIC}, + {"audio/mp3", UG_FILE_TYPE_MUSIC}, + {"audio/mp4", UG_FILE_TYPE_MUSIC}, + {"audio/MP4A-LATM", UG_FILE_TYPE_MUSIC}, + {"audio/mpeg3", UG_FILE_TYPE_MUSIC}, + {"audio/mpeg4", UG_FILE_TYPE_MUSIC}, + {"audio/mpg", UG_FILE_TYPE_MUSIC}, + {"audio/mpg3", UG_FILE_TYPE_MUSIC}, + {"audio/smaf", UG_FILE_TYPE_MUSIC}, + {"audio/sp-midi", UG_FILE_TYPE_MUSIC}, + {"audio/wav", UG_FILE_TYPE_MUSIC}, + {"audio/wave", UG_FILE_TYPE_MUSIC}, + {"audio/wma", UG_FILE_TYPE_MUSIC}, + {"audio/xmf", UG_FILE_TYPE_MUSIC}, + {"audio/x-mid", UG_FILE_TYPE_MUSIC}, + {"audio/x-midi", UG_FILE_TYPE_MUSIC}, + {"audio/x-mp3", UG_FILE_TYPE_MUSIC}, + {"audio/-mpeg", UG_FILE_TYPE_MUSIC}, + {"audio/x-mpeg", UG_FILE_TYPE_MUSIC}, + {"audio/x-mpegaudio", UG_FILE_TYPE_MUSIC}, + {"audio/x-mpg", UG_FILE_TYPE_MUSIC}, + {"audio/x-ms-asf", UG_FILE_TYPE_MUSIC}, + {"audio/x-wave", UG_FILE_TYPE_MUSIC}, + + {"application/pdf", UG_FILE_TYPE_PDF}, + + {"application/msword", UG_FILE_TYPE_DOC}, + {"application/vnd.openxmlformats-officedocument.wordprocessingml.document", UG_FILE_TYPE_DOC}, + + {"application/vnd.ms-powerpoint", UG_FILE_TYPE_PPT}, + {"application/vnd.openxmlformats-officedocument.presentationml.presentation", UG_FILE_TYPE_PPT}, + + {"application/vnd.ms-excel", UG_FILE_TYPE_EXCEL}, + {"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", UG_FILE_TYPE_EXCEL}, + + {"audio/AMR", UG_FILE_TYPE_VOICE}, + {"audio/AMR-WB", UG_FILE_TYPE_VOICE}, + {"audio/amr", UG_FILE_TYPE_VOICE}, + {"audio/amr-wb", UG_FILE_TYPE_VOICE}, + {"audio/x-amr", UG_FILE_TYPE_VOICE}, + + {"text/html", UG_FILE_TYPE_HTML}, + + {"application/x-shockwave-flash", UG_FILE_TYPE_FLASH}, + {"video/x-flv", UG_FILE_TYPE_FLASH}, + + {"text/plain", UG_FILE_TYPE_TXT}, + + {"text/x-opml+xml", UG_FILE_TYPE_RSS}, + + {"text/vnd.sun.j2me.app-descriptor", UG_FILE_TYPE_JAVA}, + {"application/x-java-archive", UG_FILE_TYPE_JAVA}, + + {NULL, UG_FILE_TYPE_ETC}, +}; + +static char *icon_array[UG_FILE_TYPE_MAX] = { + [UG_FILE_TYPE_DIR] = UG_ICON_FOLDER, + [UG_FILE_TYPE_IMAGE] = UG_ICON_IMAGE, + [UG_FILE_TYPE_VIDEO] = UG_ICON_VIDEO, + [UG_FILE_TYPE_MUSIC] = UG_ICON_MUSIC, + [UG_FILE_TYPE_SOUND] = UG_ICON_SOUND, + [UG_FILE_TYPE_PDF] = UG_ICON_PDF, + [UG_FILE_TYPE_DOC] = UG_ICON_DOC, + [UG_FILE_TYPE_PPT] = UG_ICON_PPT, + [UG_FILE_TYPE_EXCEL] = UG_ICON_EXCEL, + [UG_FILE_TYPE_VOICE] = UG_ICON_VOICE, + [UG_FILE_TYPE_HTML] = UG_ICON_HTML, + [UG_FILE_TYPE_FLASH] = UG_ICON_FLASH, + [UG_FILE_TYPE_TXT] = UG_ICON_TXT, + [UG_FILE_TYPE_VCONTACT] = UG_ICON_VCONTACT, + [UG_FILE_TYPE_VCALENDAR] = UG_ICON_VCALENDAR, + [UG_FILE_TYPE_VNOTE] = UG_ICON_VNOTE, + [UG_FILE_TYPE_RSS] = UG_ICON_RSS, + [UG_FILE_TYPE_JAVA] = UG_ICON_JAVA, +}; + +/********************* +**Function name: __mf_ug_file_attr_get_category_by_file_ext +**Parameter: const char* file_ext +**Return value: mf_ug_fs_file_type +** +**Action: +** Get file category by extention +** +*********************/ +static mf_ug_fs_file_type __mf_ug_file_attr_get_category_by_file_ext(const char *file_ext, const char *fullpath) +{ + int i = 0; + + if (file_ext == NULL) { + return UG_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 UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("AMR", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VOICE; + } + if (strcasecmp("AWB", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VOICE; + } + if (strcasecmp("AAC", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + if (strcasecmp("AVI", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("AAC", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + + break; + case 'b': + case 'B': + if (strcasecmp("BMP", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + break; + case 'd': + case 'D': + if (strcasecmp("DOC", &file_ext[i]) == 0) { + return UG_FILE_TYPE_DOC; + } + if (strcasecmp("DOCX", &file_ext[i]) == 0) { + return UG_FILE_TYPE_DOC; + } + if (strcasecmp("DIVX", &file_ext[i]) == 0) { + if (mf_ug_file_attr_is_drm_file(fullpath) == 0) { + return UG_FILE_TYPE_DRM; + } else { + return UG_FILE_TYPE_VIDEO; + } + } + if (strcasecmp("DCF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_DRM; + } + break; + case 'g': + case 'G': + if (strcasecmp("GIF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + if (strcasecmp("G72", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + break; + case 'h': + case 'H': + if (strcasecmp("H263", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + if (strcasecmp("HTML", &file_ext[i]) == 0) { + return UG_FILE_TYPE_HTML; + } + if (strcasecmp("HTM", &file_ext[i]) == 0) { + return UG_FILE_TYPE_HTML; + } + break; + case 'i': + case 'I': + if (strcasecmp("IMY", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("IPK", &file_ext[i]) == 0) { + return UG_FILE_TYPE_APP; + } + if (strcasecmp("isma", &file_ext[i]) == 0) { + if (mf_ug_file_attr_is_drm_file(fullpath) == 0) { + return UG_FILE_TYPE_DRM; + } else { + return UG_FILE_TYPE_SOUND; + } + } + if (strcasecmp("ismv", &file_ext[i]) == 0) { + if (mf_ug_file_attr_is_drm_file(fullpath) == 0) { + return UG_FILE_TYPE_DRM; + } else { + return UG_FILE_TYPE_SOUND; + } + } + break; + case 'j': + case 'J': + if (strcasecmp("JAD", &file_ext[i]) == 0) { + return UG_FILE_TYPE_JAVA; + } + if (strcasecmp("JAR", &file_ext[i]) == 0) { + return UG_FILE_TYPE_JAVA; + } + + if (strcasecmp("JPG", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + if (strcasecmp("JPEG", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + if (strcasecmp("JPE", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + break; + case 'm': + case 'M': + if (strcasecmp("MMF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("MP3", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + if (strcasecmp("MID", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("MIDI", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("MP4", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("MPG", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("MPEG", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("M4A", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + if (strcasecmp("M3G", &file_ext[i]) == 0) { + return UG_FILE_TYPE_FLASH; + } + if (strcasecmp("MXMF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("MKV", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("MKA", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + break; + case 'o': + case 'O': + if (strcasecmp("opml", &file_ext[i]) == 0) { + return UG_FILE_TYPE_RSS; + } + break; + case 'p': + case 'P': + if (strcasecmp("PNG", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + if (strcasecmp("PJPEG", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + if (strcasecmp("PDF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_PDF; + } + if (strcasecmp("PPT", &file_ext[i]) == 0) { + return UG_FILE_TYPE_PPT; + } + if (strcasecmp("PPTX", &file_ext[i]) == 0) { + return UG_FILE_TYPE_PPT; + } + if (strcasecmp("PEM", &file_ext[i]) == 0) { + return UG_FILE_TYPE_CERTIFICATION; + } + break; + case 'r': + case 'R': + break; + case 's': + case 'S': + if (strcasecmp("SDP", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("SPM", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("SMP", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("SPF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("SWF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_FLASH; + } + if (strcasecmp("SCN", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MOVIE_MAKER; + } + if (strcasecmp("SVG", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SVG; + } + if (strcasecmp("SVGZ", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SVG; + } + break; + case 't': + case 'T': + if (strcasecmp("TXT", &file_ext[i]) == 0) { + return UG_FILE_TYPE_TXT; + } + if (strcasecmp("THM", &file_ext[i]) == 0) { + return UG_FILE_TYPE_THEME; + } + break; + case 'v': + case 'V': + if (strcasecmp("VCF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VCONTACT; + } + if (strcasecmp("VCS", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VCALENDAR; + } + if (strcasecmp("VNT", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VNOTE; + } + if (strcasecmp("VBM", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VBOOKMARK; + } + break; + case 'w': + case 'W': + if (strcasecmp("WAV", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("WBMP", &file_ext[i]) == 0) { + return UG_FILE_TYPE_IMAGE; + } + if (strcasecmp("WGT", &file_ext[i]) == 0) { + return UG_FILE_TYPE_WGT; + } + if (strcasecmp("WMA", &file_ext[i]) == 0) { + return UG_FILE_TYPE_MUSIC; + } + if (strcasecmp("WMV", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + break; + case 'x': + case 'X': + if (strcasecmp("XLS", &file_ext[i]) == 0) { + return UG_FILE_TYPE_EXCEL; + } + if (strcasecmp("XLSX", &file_ext[i]) == 0) { + return UG_FILE_TYPE_EXCEL; + } + if (strcasecmp("XMF", &file_ext[i]) == 0) { + return UG_FILE_TYPE_SOUND; + } + if (strcasecmp("XHTML", &file_ext[i]) == 0) { + return UG_FILE_TYPE_HTML; + } + break; + case '3': + if (strcasecmp("3GP", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("3GPP", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + if (strcasecmp("3G2", &file_ext[i]) == 0) { + return UG_FILE_TYPE_VIDEO; + } + break; + } + + return UG_FILE_TYPE_ETC; +} + +/********************* +**Function name: mf_ug_file_attr_is_valid_name +**Parameter: +** const char *filename: the file/dir name we need to check +** +**Return value: +** -0x14 if the name is invalid +** 0 if the name is valid +** +**Action: +** check if the name is valid by file name +** +*********************/ +int mf_ug_file_attr_is_valid_name(const char *filename) +{ + char *pattern; + int ret, z, cflags = 0; + char ebuf[128]; + regex_t reg; + regmatch_t pm[1]; + const size_t nmatch = 1; + /*/ToDo: ignore the file star with . */ + if (strncmp(filename, ".", 1) == 0) { + return MYFILE_ERR_INVALID_FILE_NAME; + } + + pattern = MYFILE_NAME_PATTERN; + z = regcomp(®, pattern, cflags); + + if (z != 0) { + regerror(z, ®, ebuf, sizeof(ebuf)); + fprintf(stderr, "%s: pattern '%s' \n", ebuf, pattern); + return MYFILE_ERR_INVALID_FILE_NAME; + } + + z = regexec(®, filename, nmatch, pm, 0); + if (z == REG_NOMATCH) { + ret = MYFILE_ERR_NONE; + } else { + ret = MYFILE_ERR_INVALID_FILE_NAME; + } + regfree(®); + return ret; +} + + +/****************************** +** Prototype : __mf_ug_file_attr_default_icon_get_by_type +** Description : Samsung +** Input : mf_ug_fs_file_type ftype +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static char *__mf_ug_file_attr_default_icon_get_by_type(mf_ug_fs_file_type ftype) +{ + char *icon_path = NULL; + + if (icon_array[ftype]) { + icon_path = strdup(icon_array[ftype]); + } else { + icon_path = strdup(UG_DEFAULT_ICON); + } + + return icon_path; +} + + +/****************************** +** Prototype : mf_ug_file_attr_get_parent_path +** Description : Samsung +** Input : const char* path +** char* parent_path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +int mf_ug_file_attr_get_parent_path(const char *path, char **parent_path) +{ + ug_mf_retvm_if(path == NULL, MYFILE_ERR_INVALID_ARG, "path is NULL"); + ug_mf_retvm_if(parent_path == NULL, MYFILE_ERR_INVALID_ARG, "parent_path is NULL"); + ug_debug("Path :::: [%s]", path); + + *parent_path = g_strdup(path); + if (*parent_path == NULL) + return MYFILE_ERR_ALLOCATE_FAIL; + + const char *name = NULL; + name = ecore_file_file_get(path); + /* + ** input path and parent_path are check in the caller. + ** parent_path is full path must be like /opt/media/file.ext + ** name is file.ext + ** strlen(parent_path) should large than strlen(name) normally. + ** to take exception like input path is "", we add a if condition + */ + if (strlen(*parent_path) > strlen(name)) + (*parent_path)[strlen(*parent_path) - strlen(name) - 1] = '\0'; + + if (strlen(*parent_path) == 0) { + *parent_path = g_strdup("/"); + } + + return MYFILE_ERR_NONE; +} + + +/********************* +**Function name: mf_get_category +**Parameter: +** const char* filepath: file fullpath +** mf_ug_fs_file_type *category: output parameter of category +**Return value: +** error code +** +**Action: +** Get file category by file full path +** +*********************/ +int mf_ug_file_attr_get_file_category(const char *filepath, mf_ug_fs_file_type * category) +{ + int i = 0; + int flag = 0; + + if (mf_ug_file_attr_is_dir(filepath)) { + *category = UG_FILE_TYPE_DIR; + return MYFILE_ERR_NONE; + } + + const char *filename = NULL; + filename = ecore_file_file_get(filepath); + /*/return value ceck */ + if (filename == NULL) { + *category = UG_FILE_TYPE_NONE; + return MYFILE_ERR_SRC_ARG_INVALID; + } + char file_ext[FILE_EXT_LEN_MAX + 1] = { 0 }; + /*/ToDo: error file name like the last letter is "." */ + for (i = strlen(filename); i >= 0; i--) { + if (filename[i] == '.') { + strncpy(file_ext, &filename[i + 1], FILE_EXT_LEN_MAX); + ug_error("file_ext = %s\n",file_ext); + flag = 1; + break; + } + + if (filename[i] == '/') { + flag = 0; + break; + } + } + + if (flag == 1) { + *category = __mf_ug_file_attr_get_category_by_file_ext(file_ext, filepath); + return MYFILE_ERR_NONE; + } else { + *category = UG_FILE_TYPE_NONE; + return MYFILE_ERR_GET_CATEGORY_FAIL; + } +} + +/********************* +**Function name: mf_ug_file_attr_get_file_stat +**Parameter: +** const char* filename: file name +** ugFsNodeInfo **node: output parameter of what we need to refine +**Return value: +** error code +** +**Action: +** Get file size and last modified date by file path +** +*********************/ +int mf_ug_file_attr_get_file_stat(const char *filename, ugFsNodeInfo ** node) +{ + struct stat statbuf; + + ug_mf_retvm_if(filename == NULL, MYFILE_ERR_INVALID_ARG, "filename is null"); + ug_mf_retvm_if(node == NULL, MYFILE_ERR_INVALID_ARG, "node is null"); + + if (stat(filename, &statbuf) == -1) { + return MYFILE_ERR_GET_STAT_FAIL; + } + + (*node)->size = statbuf.st_size; + (*node)->date = statbuf.st_mtime; + + return MYFILE_ERR_NONE; +} + +/********************* +**Function name: mf_ug_file_attr_is_dir +**Parameter: +** const char* filename: file fullpath +**Return value: +** if path is a directory, return 1 +** else, return 0 +** +**Action: +** check if the file path is Directory +** +*********************/ +int mf_ug_file_attr_is_dir(const char *filepath) +{ + return ecore_file_is_dir(filepath); +} + +/********************* +**Function name: mf_ug_file_attr_get_store_type_by_full +**Parameter: +** const char* filepath: file full path +** mf_ug_storage_type *store_type: output parameter of storage type +**Return value: +** error code +** +**Action: +** Get file storage type by file path +** +*********************/ +int mf_ug_file_attr_get_store_type_by_full(const char *filepath, mf_ug_storage_type * store_type) +{ + if (filepath == NULL || store_type == NULL) { + return MYFILE_ERR_SRC_ARG_INVALID; + } + + if (strncmp(filepath, PHONE_FOLDER, strlen(PHONE_FOLDER)) == 0) { + *store_type = MF_UG_PHONE; + return MYFILE_ERR_NONE; + } else if (strncmp(filepath, MEMORY_FOLDER, strlen(MEMORY_FOLDER)) == 0) { + *store_type = MF_UG_MMC; + return MYFILE_ERR_NONE; + } else { + *store_type = MF_UG_NONE; + return MYFILE_ERR_STORAGE_TYPE_ERROR; + } +} + +/********************* +**Function name: mf_ug_file_attr_is_drm_file +**Parameter: +** const char* filepath: file full path +** +**Return value: +** true if it is a DRM file +** false if it is not a DRM file +** +**Action: +** check if file is drm file +** +*********************/ +int mf_ug_file_attr_is_drm_file(const char *file_fullpath) +{ + if (file_fullpath == NULL) + return MYFILE_ERR_DRM_PERMISSION_DENY; + drm_bool_type_e drmFlag = DRM_FALSE; + int res = 0; + res = drm_is_drm_file(file_fullpath, &drmFlag); + + if (res == DRM_RETURN_SUCCESS && drmFlag == DRM_TRUE) + return 0; + else + return MYFILE_ERR_DRM_PERMISSION_DENY; +} + +/********************* +**Function name: mf_ug_file_attr_get_file_ext +**Parameter: +** const char* filepath: file full path +** char *file_ext: output parameter of file extension +** +**Return value: +** error code +** +**Action: +** get file extension by file full path +** +*********************/ +int mf_ug_file_attr_get_file_ext(const char *filepath, char **file_ext) +{ + ug_mf_retvm_if(filepath == NULL, MYFILE_ERR_INVALID_FILE_NAME, "filepath is NULL"); + ug_mf_retvm_if(file_ext == NULL, MYFILE_ERR_INVALID_FILE_NAME, "file_ext is NULL"); + + const char *filename = NULL; + filename = ecore_file_file_get(filepath); + + if (filename == NULL) { + return MYFILE_ERR_INVALID_FILE_NAME; + } + + char *pdot = strrchr(filename, '.'); + + if (!pdot) { + return MYFILE_ERR_EXT_GET_ERROR; + } else if (pdot != filepath) { + *file_ext = g_strdup(pdot + 1); + return MYFILE_ERR_NONE; + } else { + return MYFILE_ERR_EXT_GET_ERROR; + } +} + + + +/********************* +**Function name: mf_ug_file_attr_is_right_dir_path +**Parameter: +** const char *filename: the file/dir name we need to check +** +**Return value: +** error code +** +**Action: +** check if the dir path is correct +** +*********************/ +int mf_ug_file_attr_is_right_dir_path(const char *dir_path) +{ + int result = MYFILE_ERR_NONE; + int length = 0; + + length = strlen(dir_path); + if (length == 0) { + return MYFILE_ERR_INVALID_DIR_PATH; + } + + if (dir_path[length - 1] == '/' && length > 1) { + return MYFILE_ERR_INVALID_DIR_PATH; + } + + if (dir_path[0] != '/') { + return MYFILE_ERR_INVALID_DIR_PATH; + } + + const char *file_name = NULL; + file_name = ecore_file_file_get(dir_path); + result = mf_ug_file_attr_is_valid_name(file_name); + + if (result != MYFILE_ERR_NONE) { + ug_mf_error("Is NOT Valid dir path name"); + } + + return result; +} + +/********************* +**Function name: mf_ug_file_attr_is_right_file_path +**Parameter: +** const char *filename: the file/dir name we need to check +** +**Return value: +** error code +** +**Action: +** check if the file path is correct +** +*********************/ +int mf_ug_file_attr_is_right_file_path(const char *file_path) +{ + int result = MYFILE_ERR_NONE; + + if (strlen(file_path) == 0) { + return MYFILE_ERR_INVALID_FILE_PATH; + } + + if (file_path[0] != '/') { + return MYFILE_ERR_INVALID_DIR_PATH; + } + + const char *file_name = NULL; + file_name = ecore_file_file_get(file_path); + result = mf_ug_file_attr_is_valid_name(file_name); + if (result != MYFILE_ERR_NONE) { + ug_mf_error("Is NOT Valid dir path name"); + } + + return result; +} + + +static int __mf_ug_create_filter(filter_h *filter, ug_filter_s *condition) +{ + ug_mf_retvm_if(filter == NULL, -1, "filter is NULL"); + ug_mf_retvm_if(condition == NULL, -1, "condition is NULL"); + + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h tmp_filter = NULL; + ret = media_filter_create(&tmp_filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ug_debug("Fail to create filter"); + return ret; + } + if (condition->cond) { + ret = media_filter_set_condition(tmp_filter, condition->cond, + condition->collate_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ug_debug("Fail to set condition"); + goto ERROR; + } + } + + if (condition->sort_keyword) { + ret = media_filter_set_order(tmp_filter, condition->sort_type, + condition->sort_keyword, + condition->collate_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ug_debug("Fail to set order"); + goto ERROR; + } + } + + ug_debug("offset is %d, count is %d", condition->offset, condition->count); + if (condition->offset != -1 && condition->count != -1 && + condition->count > condition->offset) { + ret = media_filter_set_offset(tmp_filter, condition->offset, + condition->count); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ug_debug("Fail to set offset"); + goto ERROR; + } + } + *filter = tmp_filter; + return ret; + ERROR: + if (tmp_filter) { + media_filter_destroy(tmp_filter); + tmp_filter = NULL; + } + return ret; +} + +static int __mf_ug_destroy_filter(filter_h filter) +{ + ug_mf_retvm_if(filter == NULL, -1, "filter is NULL"); + int ret = MEDIA_CONTENT_ERROR_NONE; + ret = media_filter_destroy(filter); + + return ret; +} + +static bool __mf_ug_local_data_get_media_thumbnail_cb(media_info_h media, void *data) +{ + ug_mf_retvm_if(data == NULL, -1, "filter is NULL"); + ug_transfer_data_s *tmp_data = (ug_transfer_data_s *)data; + + media_info_get_thumbnail_path(media, &(tmp_data->thumbnail_path)); + + return false; +} + + + +int static __mf_ug_local_thumbnail_get(void *data, ug_filter_s *condition) +{ + + int ret = -1; + filter_h filter = NULL; + ret = __mf_ug_create_filter(&filter, condition); + if (ret != 0) { + ug_debug("Create filter failed"); + return ret; + } + + + ret = media_info_foreach_media_from_db(filter, + __mf_ug_local_data_get_media_thumbnail_cb, + data); + if (ret != 0) { + ug_debug("media_info_foreach_media_from_db failed: %d", ret); + } else { + ug_debug("media_info_foreach_media_from_db success!", ret); + } + __mf_ug_destroy_filter(filter); + + return ret; + +} + +int mf_ug_file_attr_get_thumbnail(void *data) +{ + ug_mf_retvm_if(data == NULL, -1, "data is NULL"); + + ug_transfer_data_s *mp_data = (ug_transfer_data_s *)data; + ug_filter_s filter; + int ret = -1; + + memset(&filter, 0, sizeof(ug_filter_s)); + + char *condition = NULL; + condition = g_strdup_printf("%s and MEDIA_PATH=\"%s\"", UG_CONDITION_IMAGE_VIDEO, mp_data->file_path); + ug_debug("condition [%s]", condition); + filter.cond = condition; + filter.collate_type = MEDIA_CONTENT_COLLATE_DEFAULT; + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + filter.sort_keyword = MEDIA_MODIFIED_TIME; + filter.with_meta = true; + + ret = __mf_ug_local_thumbnail_get(data, &filter); + UG_SAFE_FREE_CHAR(condition); + + + return ret; +} + +int mf_ug_file_attr_get_file_icon(const char *file_path, int *error_code, char **thumbnail) +{ + int index = 0; + char *icon_path = NULL; + mf_ug_fs_file_type ftype = UG_FILE_TYPE_NONE; + int thumbnail_type = MF_UG_THUMBNAIL_TYPE_DEFAULT; + const char *mime = NULL; + + ug_mf_retvm_if(file_path == NULL, MF_UG_THUMBNAIL_TYPE_DEFAULT, "file_path is NULL"); + + efreet_mime_init(); + mime = efreet_mime_type_get(file_path); + + if (mime == NULL) { + ug_mf_warnig("Fail to aul_get_mime_from_file(), set etc icon"); + efreet_mime_shutdown(); + return thumbnail_type; + } + + for (index = 0; mime_type[index].mime; index++) { + if (strncmp(mime, mime_type[index].mime, strlen(mime)) == 0) { + ftype = mime_type[index].ftype; + break; + } + } + + icon_path = __mf_ug_file_attr_default_icon_get_by_type(ftype); + ug_debug("ftype is [%d] icon_path is [%s]", ftype, icon_path); + + switch (ftype) { + case UG_FILE_TYPE_IMAGE: + case UG_FILE_TYPE_VIDEO: + { + int err = 0; + ug_transfer_data_s tmp_data; + memset(&tmp_data,0x00,sizeof(ug_transfer_data_s)); + tmp_data.file_path = file_path; + err = mf_ug_file_attr_get_thumbnail(&tmp_data); + if (err == 0) { + icon_path = g_strdup(tmp_data.thumbnail_path); + thumbnail_type = MF_UG_THUMBNAIL_TYPE_THUMBNAIL; + } else { + icon_path = NULL; + if (error_code) + *error_code = err; + } + } + break; + default: + icon_path = __mf_ug_file_attr_default_icon_get_by_type(ftype); + thumbnail_type = MF_UG_THUMBNAIL_TYPE_DEFAULT; + break; + } + + ug_debug("mime [%s], file type [%d], icon_path [%s]", mime, ftype, icon_path); + *thumbnail = icon_path; + efreet_mime_shutdown(); + + return thumbnail_type; +} + +static int mf_ug_file_attr_get_path_level(const char *fullpath, int *level) +{ + if (fullpath == NULL) { + return MYFILE_ERR_SRC_ARG_INVALID; + } + + if (mf_ug_file_attr_is_right_dir_path(fullpath) != 0) { + return MYFILE_ERR_INVALID_PATH; + } + + mf_ug_storage_type storage_t = 0; + int start_level = 0; + int error_code = mf_ug_file_attr_get_store_type_by_full(fullpath, &storage_t); + if (error_code != 0) { + return error_code; + } + + if (storage_t == MF_UG_PHONE) { + start_level = MF_UG_PHONE_DEFAULT_LEVEL; + } else if (storage_t == MF_UG_MMC) { + start_level = MF_UG_MMC_DEFAULT_LEVEL; + } + + char *temp = strdup(fullpath); + if (temp == NULL) { + return MYFILE_ERR_UNKNOW_ERROR; + } + + int count = 0; + + gchar **result = NULL; + gchar **params = NULL; + result = g_strsplit(temp, "/", 0); + + if (result == NULL) { + free(temp); + temp = NULL; + return MYFILE_ERR_UNKNOW_ERROR; + } + + for (params = result; *params; params++) { + count++; + } + + g_strfreev(result); + *level = count - start_level - 1; + free(temp); + return MYFILE_ERR_NONE; + +} + + +int mf_ug_file_attr_is_in_system_folder(char *fullpath, int level, bool * result) +{ + if (fullpath == NULL) { + return MYFILE_ERR_SRC_ARG_INVALID; + } + + mf_ug_storage_type storage_t = 0; + int error_code = mf_ug_file_attr_get_store_type_by_full(fullpath, &storage_t); + if (error_code != 0) { + return error_code; + } + + const char *name = NULL; + name = ecore_file_file_get(fullpath); + char *parent_path = malloc(MYFILE_DIR_PATH_LEN_MAX + 1); + + if (parent_path == NULL) { + return MYFILE_ERR_ALLOCATE_FAIL; + } + memset(parent_path, 0, MYFILE_DIR_PATH_LEN_MAX + 1); + error_code = mf_ug_file_attr_get_parent_path(fullpath, &parent_path); + + if (error_code != 0) { + + free(parent_path); + parent_path = NULL; + return error_code; + } + + if (storage_t == MF_UG_PHONE || storage_t == MF_UG_MMC) { + if (level == 1) { + if ((strlen(name) == strlen(IMAGE_AND_VIDEO)) && strcmp(name, IMAGE_AND_VIDEO) == 0) { + *result = true; + } else if ((strlen(name) == strlen(SOUND_AND_MUSIC)) && strcmp(name, SOUND_AND_MUSIC) == 0) { + *result = true; + } else if ((strlen(name) == strlen(DOWNLOADS)) && strcmp(name, DOWNLOADS) == 0) { + *result = true; + } else if ((strlen(name) == strlen(CAMERA_SHOTS)) && strcmp(name, CAMERA_SHOTS) == 0) { + *result = true; + } else { + *result = false; + } + } else if (level == 2) { + const char *parent_name = NULL; + parent_name = ecore_file_file_get(parent_path); + if (storage_t == MF_UG_PHONE && (strlen(parent_name) == strlen(DOWNLOADS)) && strcmp(parent_name, DOWNLOADS) == 0) { + if ((strlen(name) == strlen(OTHERS)) && !strcmp(OTHERS, name)) { + *result = true; + } else { + *result = false; + } + } else if ((strlen(parent_name) == strlen(SOUND_AND_MUSIC)) && strcmp(parent_name, SOUND_AND_MUSIC) == 0) { + if ((strlen(name) == strlen(FM_RADIO)) && !strcmp(FM_RADIO, name)) { + *result = true; + } else if ((strlen(name) == strlen(MUSIC)) && !strcmp(MUSIC, name)) { + *result = true; + } else if ((strlen(name) == strlen(RINGTONES)) && !strcmp(RINGTONES, name)) { + *result = true; + } else if ((strlen(name) == strlen(ALERTS)) && !strcmp(ALERTS, name)) { + *result = true; + } else if ((strlen(name) == strlen(VOICE_RECORDER)) && !strcmp(VOICE_RECORDER, name)) { + *result = true; + } else { + *result = false; + } + } else if ((strlen(parent_name) == strlen(IMAGE_AND_VIDEO)) && strcmp(parent_name, IMAGE_AND_VIDEO) == 0) { + if ((strlen(name) == strlen(WALLPAPER)) && !strcmp(WALLPAPER, name)) { + *result = true; + } else if ((strlen(name) == strlen(MY_PHOTO_CLIPS)) && !strcmp(MY_PHOTO_CLIPS, name)) { + *result = true; + } else if ((strlen(name) == strlen(MY_ALBUM)) && !strcmp(MY_ALBUM, name)) { + *result = true; + } else if ((strlen(name) == strlen(MY_VIDEO_CLIPS)) && !strcmp(MY_VIDEO_CLIPS, name)) { + *result = true; + } else { + *result = false; + } + } else { + *result = false; + } + } else { + if (parent_path) { + free(parent_path); + parent_path = NULL; + } + return MYFILE_ERR_STORAGE_TYPE_ERROR; + } + } + + else { + if (parent_path) { + free(parent_path); + parent_path = NULL; + } + *result = false; + return MYFILE_ERR_STORAGE_TYPE_ERROR; + } + + if (parent_path) { + free(parent_path); + parent_path = NULL; + } + return MYFILE_ERR_NONE; +} + + +int mf_ug_file_attr_is_system_dir(char *fullpath, bool * result) +{ + if (fullpath == NULL) { + ug_debug("source argument invalid"); + return MYFILE_ERR_SRC_ARG_INVALID; + } + + if (mf_ug_file_attr_is_dir(fullpath) == 0) { + ug_debug("source is not exist"); + return MYFILE_ERR_SRC_NOT_EXIST; + } + + int level = 0; + int error_code = 0; + + error_code = mf_ug_file_attr_get_path_level(fullpath, &level); + if (error_code != 0) { + ug_debug("Fail to get path level"); + return error_code; + } + + if (level >= 3 || level <= 0) { + *result = false; + ug_debug("Path Level is wrong"); + return MYFILE_ERR_NONE; + } + error_code = mf_ug_file_attr_is_in_system_folder(fullpath, level, result); + + if (error_code != 0) { + ug_debug("Fail .. is in system folder err :: %d", error_code); + return error_code; + } + + return MYFILE_ERR_NONE; + +} + +mf_ug_fs_file_type mf_ug_file_attr_get_file_type_by_mime(const char *file_path) +{ + int index; + mf_ug_fs_file_type ftype = UG_FILE_TYPE_NONE; + const char *mime = NULL; + efreet_mime_init(); + mime = efreet_mime_type_get(file_path); + + if (mime == NULL) { + ug_debug("Fail to aul_get_mime_from_file(), set etc icon"); + efreet_mime_shutdown(); + return ftype; + } + + for (index = 0; mime_type[index].mime; index++) { + if (strncmp(mime, mime_type[index].mime, strlen(mime)) == 0) { + ftype = mime_type[index].ftype; + return ftype; + } + } + efreet_mime_shutdown(); + + return ftype; +} + +int mf_ug_file_attr_is_duplicated_name(const char *dir, const char *name) +{ + + char *file_path = g_strconcat(dir, "/", name, NULL); + if (ecore_file_exists(file_path)) { + UG_SAFE_FREE_CHAR(file_path); + return MYFILE_ERR_DUPLICATED_NAME; + } else { + UG_SAFE_FREE_CHAR(file_path); + return MYFILE_ERR_NONE; + } +} + +int mf_ug_file_attr_get_logical_path_by_full(const char *full_path, char **path) +{ + ug_mf_retvm_if(full_path == NULL, MYFILE_ERR_INVALID_FILE_PATH, "fullpath is NULL"); + ug_mf_retvm_if(path == NULL, MYFILE_ERR_INVALID_FILE_PATH, "path is NULL"); + + mf_ug_storage_type store_type = 0; + int root_len = 0; + int error_code = 0; + + error_code = mf_ug_file_attr_get_store_type_by_full(full_path, &store_type); + + *path = g_strdup(full_path); + if (*path == NULL) { + return MYFILE_ERR_ALLOCATE_MEMORY_FAIL; + } + + memset(*path, 0, strlen(*path)); + switch (store_type) { + case MF_UG_PHONE: + root_len = strlen(PHONE_FOLDER); + break; + case MF_UG_MMC: + root_len = strlen(MEMORY_FOLDER); + break; + default: + return MYFILE_ERR_STORAGE_TYPE_ERROR; + } + + /* + ** *path has the same length with full_path + ** strlen(*path) is 0 since the memset called + ** we use length of full_path to reprecent the *path's + */ + g_strlcpy(*path, full_path + root_len, strlen(full_path)); + if (strlen(*path) == 0) { + UG_SAFE_FREE_CHAR(*path); + *path = g_strdup("/"); + } + + return MYFILE_ERR_NONE; +} + diff --git a/src/common/file-system/mf-ug-fs-oper.c b/src/common/file-system/mf-ug-fs-oper.c new file mode 100644 index 0000000..ad1c556 --- /dev/null +++ b/src/common/file-system/mf-ug-fs-oper.c @@ -0,0 +1,1034 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <libgen.h> +#include <glib.h> +#include "mf-ug-fs-util.h" +#include "mf-ug-util.h" + +static int __mf_ug_fs_oper_sort_by_date_cb_O2R(const void *d1, const void *d2); +static int __mf_ug_fs_oper_sort_by_name_cb_A2Z(const void *d1, const void *d2); +static int __mf_ug_fs_oper_sort_by_type_cb_A2Z(const void *d1, const void *d2); +static int __mf_ug_fs_oper_sort_by_size_cb_S2L(const void *d1, const void *d2); +static int __mf_ug_fs_oper_sort_by_name_cb_Z2A(const void *d1, const void *d2); +static int __mf_ug_fs_oper_sort_by_date_cb_R2O(const void *d1, const void *d2); +static int __mf_ug_fs_oper_sort_by_type_cb_Z2A(const void *d1, const void *d2); +static int __mf_ug_fs_oper_sort_by_size_cb_L2S(const void *d1, const void *d2); + +/********************* +**Function name: __mf_ug_fs_oper_file_system_error +**Parameter: +** const char* src: source path +** const char* dst: destination path +** int check_option: check option +** +**Return value: +** error code +** +**Action: +** input parameter checking +** +*********************/ +static const char *__mf_ug_fs_oper_get_file(const char *path) +{ + char *result = NULL; + + if (!path) { + return NULL; + } + if ((result = strrchr(path, '/'))) { + result++; + } else { + result = (char *)path; + } + return result; +} + + +static int __mf_ug_fs_oper_file_system_error(const char *src, const char *dst, int check_option) +{ + if ((check_option & MF_ERROR_CHECK_SRC_ARG_VALID) && (src == NULL)) { + return MYFILE_ERR_SRC_ARG_INVALID; + } + if ((check_option & MF_ERROR_CHECK_SRC_EXIST) && (!ecore_file_exists(src))) { + return MYFILE_ERR_SRC_NOT_EXIST; + } + + if (check_option & MF_ERROR_CHECK_SRC_PATH_VALID) { + if (!ecore_file_is_dir(src)) { + if (mf_ug_file_attr_is_right_file_path(src)) { + return MYFILE_ERR_INVALID_FILE_PATH; + } + } else { + if (mf_ug_file_attr_is_right_dir_path(src)) { + return MYFILE_ERR_INVALID_DIR_PATH; + } + } + } + + if (check_option & MF_ERROR_CHECK_DUPLICATED) { + char *parent_path = NULL; + + if (!mf_ug_file_attr_get_parent_path(dst, &parent_path)) { + if (mf_ug_file_attr_is_duplicated_name(parent_path, __mf_ug_fs_oper_get_file(dst))) { + UG_SAFE_FREE_CHAR(parent_path); + return MYFILE_ERR_DUPLICATED_NAME; + } + UG_SAFE_FREE_CHAR(parent_path); + } else { + UG_SAFE_FREE_CHAR(parent_path); + return MYFILE_ERR_GET_PARENT_PATH_FAIL; + } + } + return MYFILE_ERR_NONE; +} + +/********************* +**Function name: mf_ug_fs_oper_read_dir +**Parameter: +** char *path: path which we need to read +** Eina_List** dir_list: output parameter of dir list under specified path +** Eina_List** file_list: output parameter of file list under specified path +** +**Return value: +** error code +** +**Action: +** read element under the specified path +** +*********************/ +int mf_ug_fs_oper_read_dir(const char *path, Eina_List **dir_list, Eina_List **file_list) +{ + UG_TRACE_BEGIN; + DIR *pDir = NULL; + struct dirent *ent; + + ug_mf_retvm_if(path == NULL, MYFILE_ERR_INVALID_ARG, "path is null"); + ug_mf_retvm_if(dir_list == NULL, MYFILE_ERR_INVALID_ARG, "dir_list is null"); + ug_mf_retvm_if(file_list == NULL, MYFILE_ERR_INVALID_ARG, "file_list is null"); + + int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_SRC_EXIST | MF_ERROR_CHECK_SRC_PATH_VALID; + int ret = __mf_ug_fs_oper_file_system_error(path, NULL, option); + + if (ret != MYFILE_ERR_NONE) { + return ret; + } + + pDir = opendir(path); + + if (pDir == NULL) { + return MYFILE_ERR_DIR_OPEN_FAIL; + } + + while ((ent = readdir(pDir)) != NULL) { + GString *childpath = NULL; + ugFsNodeInfo *pNode = NULL; + + if (strncmp(ent->d_name, ".", 1) == 0 || strcmp(ent->d_name, "..") == 0) { + continue; + } + + if ((ent->d_type & DT_DIR) == 0 && (ent->d_type & DT_REG) == 0) { + continue; + } +#ifdef UG_DEBUG_FOLDER_OPTION + if ((ent->d_type & DT_DIR) != 0) { + if ((strlen(path) == strlen(PHONE_FOLDER)) && (strcmp(path, PHONE_FOLDER) == 0) + && (strlen(ent->d_name) == strlen(DEBUG_FOLDER)) && (strcmp(ent->d_name, DEBUG_FOLDER) == 0)) { + continue; + } + } +#endif + pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo)); + + if (pNode == NULL) { + continue; + } + memset(pNode, 0, sizeof(ugFsNodeInfo)); + snprintf(pNode->path, sizeof(pNode->path), "%s", path); + snprintf(pNode->name, sizeof(pNode->name), "%s", ent->d_name); + if (ent->d_type & DT_DIR) { + pNode->type = UG_FILE_TYPE_DIR; + } else if (ent->d_type & DT_REG) { + mf_ug_file_attr_get_file_category(ent->d_name, &(pNode->type)); + } + childpath = g_string_new(path); + if (childpath == NULL) { + free(pNode); + pNode = NULL; + continue; + } + g_string_append_printf(childpath, "/%s", ent->d_name); + mf_ug_file_attr_get_file_stat(childpath->str, &pNode); + if (pNode->type == UG_FILE_TYPE_DIR) { + ug_mf_debug("dir append\n"); + *dir_list = eina_list_append(*dir_list, pNode); + } else { + ug_mf_debug("file append\n"); + ret = mf_ug_file_attr_get_file_ext(childpath->str, &pNode->ext); + if (ret != MYFILE_ERR_NONE) { + pNode->ext = NULL; + } + *file_list = eina_list_append(*file_list, pNode); + } + + g_string_free(childpath, TRUE); + } + closedir(pDir); + UG_TRACE_END; + + return MYFILE_ERR_NONE; +} + +/********************* +**Function name: __mf_ug_fs_oper_exec_filter +**Parameter: +** ugFsNodeInfo* pnode_info: the node we need to check for filter +** int option: filter +** +**Return value: +** error code +** +**Action: +** check if the node satisfied the filter option +*********************/ +static mf_ug_drm_file_mime_type __mf_ug_fs_oper_get_drm_file_type_by_mime(char *mime_type) +{ + gchar **result = NULL; + if (mime_type != NULL) { + result = g_strsplit(mime_type, "/", 0); + if (result && (*result)) { + ug_mf_debug("*result is [%s]", *result); + if (g_strcmp0(*result, "audio") == 0) { + g_strfreev(result); + return MF_UG_DRM_RINGTONE_FILE; + } else if (g_strcmp0(*result, "image") == 0) { + g_strfreev(result); + return MF_UG_DRM_IMAGE_FILE; + } else { + g_strfreev(result); + return MF_UG_DRM_UNKNOW_FILE; + } + } else { + g_strfreev(result); + return MF_UG_DRM_UNKNOW_FILE; + } + } else { + return MF_UG_DRM_UNKNOW_FILE; + } +} + +mf_ug_drm_file_mime_type mf_ug_fs_oper_get_drm_type(char *path) +{ + drm_result_e res = 0; + drm_content_info_s dcf_content_info; + + res = drm_get_content_info(path, &dcf_content_info); + + + if (res == DRM_RETURN_SUCCESS) { + mf_ug_drm_file_mime_type drm_mime_type = __mf_ug_fs_oper_get_drm_file_type_by_mime(dcf_content_info.mime_type); + return drm_mime_type; + } else { + return MF_UG_DRM_UNKNOW_FILE; + } +} + +int mf_ug_fs_oper_drm_is_action_allowed(const char *path, drm_action_type_e action, drm_setas_category_e category) +{ + drm_bool_type_e is_allowed = 0; + drm_action_allowed_data_s action_data; + + int ret = -1; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + UG_SAFE_STRCPY(action_data.file_path, path); + + action_data.data = category; + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){ + return true; + }else{ + return false; + } +} + +bool mf_ug_fs_oper_drm_is_valid(const char *path, drm_permission_type_e perm_type) +{ + int res = DRM_RETURN_SUCCESS; + drm_license_status_e licence_status = DRM_LICENSE_STATUS_UNDEFINED; + if (path) { + res = drm_get_license_status(path, perm_type, &licence_status); + } + + ug_error("res is [%d] licence is [%d]", res, licence_status); + if (res == DRM_RETURN_SUCCESS && licence_status == DRM_LICENSE_STATUS_VALID) { + return true; + } else { + return false; + } + +} +static bool __mf_ug_fs_oper_exec_drm_filter(ugFsNodeInfo *pnode_info, int option) +{ + if (pnode_info == NULL) { + return FALSE; + } + + int result = -1; + char *fullpath = NULL; + drm_result_e res = DRM_RETURN_INTERNAL_ERROR; + if (option & MF_UG_FILTER_DRM_ALL) { + return TRUE; + } + + if (option & MF_UG_FILTER_DRM_WITHOUT_FL) { + fullpath = g_strconcat(pnode_info->path, "/", pnode_info->name, NULL); + res = mf_ug_fs_oper_drm_is_action_allowed(fullpath, DRM_IS_FORWARDING_ALLOWED, DRM_SETAS_NONE); + if (res == DRM_RETURN_SUCCESS) { + return FALSE; + } else { + return TRUE; + } + } + + if (option & MF_UG_FILTER_DRM_IMAGE) { + fullpath = g_strconcat(pnode_info->path, "/", pnode_info->name, NULL); + + result = mf_ug_fs_oper_drm_is_action_allowed(fullpath, DRM_HAS_VALID_SETAS_STATUS, DRM_SETAS_WALLPAPER); + if (result) { + mf_ug_drm_file_mime_type drm_mime_type = mf_ug_fs_oper_get_drm_type(fullpath); + if (drm_mime_type == MF_UG_DRM_IMAGE_FILE) + return TRUE; + else + return FALSE; + } else { + return FALSE; + } + } + + if (option & MF_UG_FILTER_DRM_RINGTONE) { + fullpath = g_strconcat(pnode_info->path, "/", pnode_info->name, NULL); + + result = mf_ug_fs_oper_drm_is_action_allowed(fullpath, DRM_HAS_VALID_SETAS_STATUS, DRM_SETAS_RINGTONE); + if (result) { + mf_ug_drm_file_mime_type drm_mime_type = mf_ug_fs_oper_get_drm_type(fullpath); + if (drm_mime_type == MF_UG_DRM_RINGTONE_FILE) + return TRUE; + else + return FALSE; + } else { + return FALSE; + } + + } + + return FALSE; +} + +static bool __mf_ug_fs_oper_exec_filter(ugFsNodeInfo *pnode_info, int option) +{ + if (pnode_info == NULL) { + return FALSE; + } + if (option & UG_FILTER_CATEGORY_IMAGE) { + if (pnode_info->type == UG_FILE_TYPE_IMAGE) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_VIDEO) { + if (pnode_info->type == UG_FILE_TYPE_VIDEO) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_SOUND) { + if (pnode_info->type == UG_FILE_TYPE_SOUND) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_VOICE) { + if (pnode_info->type == UG_FILE_TYPE_VOICE) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_MUSIC) { + if (pnode_info->type == UG_FILE_TYPE_MUSIC) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_HTML) { + if (pnode_info->type == UG_FILE_TYPE_HTML) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_FLASH) { + if (pnode_info->type == UG_FILE_TYPE_FLASH) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_GAME) { + if (pnode_info->type == UG_FILE_TYPE_GAME) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_APP) { + if (pnode_info->type == UG_FILE_TYPE_APP) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_THEME) { + if (pnode_info->type == UG_FILE_TYPE_THEME) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_DOC) { + if (pnode_info->type == UG_FILE_TYPE_DOC) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_EXCEL) { + if (pnode_info->type == UG_FILE_TYPE_EXCEL) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_PPT) { + if (pnode_info->type == UG_FILE_TYPE_PPT) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_PDF) { + if (pnode_info->type == UG_FILE_TYPE_PDF) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_TXT) { + if (pnode_info->type == UG_FILE_TYPE_TXT) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_VCONTACT) { + if (pnode_info->type == UG_FILE_TYPE_VCONTACT) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_VCALENDAR) { + if (pnode_info->type == UG_FILE_TYPE_VCALENDAR) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_VNOTE) { + if (pnode_info->type == UG_FILE_TYPE_VNOTE) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_VBOOKMARK) { + if (pnode_info->type == UG_FILE_TYPE_VBOOKMARK) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_VIDEO_PROJECT) { + if (pnode_info->type == UG_FILE_TYPE_VIDEO_PROJECT) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_SVG) { + if (pnode_info->type == UG_FILE_TYPE_SVG) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_RSS) { + if (pnode_info->type == UG_FILE_TYPE_RSS) { + return TRUE; + } + } + if (option & UG_FILTER_CATEGORY_ETC) { + if (pnode_info->type == UG_FILE_TYPE_ETC) { + return TRUE; + } + } + return FALSE; +} + +int mf_ug_fs_oper_list_filter(Eina_List *in_list, Eina_List **out_list, int option, int drm_opt) +{ + ug_mf_debug(); + if (in_list == NULL) { + return MYFILE_ERR_SRC_ARG_INVALID; + } + + if (out_list == NULL) { + return MYFILE_ERR_DST_ARG_INVALID; + } + + if (option == 0) { + *out_list = in_list; + return MYFILE_ERR_NONE; + } + + Eina_List *l = NULL; + ugFsNodeInfo *data = NULL; + EINA_LIST_FOREACH(in_list, l, data) { + if (data->type == UG_FILE_TYPE_DRM && __mf_ug_fs_oper_exec_drm_filter(data, drm_opt)) { + ug_debug("file [%s] is drm file", data->name); + *out_list = eina_list_append(*out_list, data); + } else if (__mf_ug_fs_oper_exec_filter(data, option)) { + *out_list = eina_list_append(*out_list, data); + } + } + return MYFILE_ERR_NONE; +} + +/****************************** +** Prototype : ug_mf_list_filter_by_extention +** Description : filter from list by extension +** Input : Eina_List *in_list +** Eina_List **out_list +** char* ext +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +int mf_ug_fs_oper_list_filter_by_extension(Eina_List *in_list, Eina_List **out_list, char *ext) +{ + if (in_list == NULL) { + return MYFILE_ERR_SRC_ARG_INVALID; + } + + if (out_list == NULL) { + return MYFILE_ERR_DST_ARG_INVALID; + } + + if (ext == NULL) { + *out_list = in_list; + return MYFILE_ERR_NONE; + } + + Eina_List *l = NULL; + ugFsNodeInfo *data = NULL; + + char *seps = ";"; + char *temp_ext = malloc(strlen(ext) + 1); + gchar **result = NULL; + gchar **params = NULL; + + EINA_LIST_FOREACH(in_list, l, data) { + memset(temp_ext, 0, strlen(ext) + 1); + strncpy(temp_ext, ext, strlen(ext)); + result = g_strsplit(temp_ext, seps, 0); + if (result == NULL) { + continue; + } + for (params = result; *params; params++) { + if (data->ext == NULL) + break; + if (strcasecmp(data->ext, *params) == 0) { + *out_list = eina_list_append(*out_list, data); + break; + } + } + + g_strfreev(result); + result = NULL; + } + free(temp_ext); + return MYFILE_ERR_NONE; +} + +static int __mf_ug_fs_oper_sort_by_priority(const void *d1, const void *d2, int sequence_type) +{ + int ret = 0; + switch(sequence_type) { + case MF_UG_SORT_BY_PRIORITY_TYPE_A2Z: + ret = __mf_ug_fs_oper_sort_by_date_cb_O2R(d1, d2); + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_size_cb_S2L(d1, d2); + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_name_cb_A2Z(d1, d2); + } + } + break; + case MF_UG_SORT_BY_PRIORITY_TYPE_Z2A: + ret = __mf_ug_fs_oper_sort_by_date_cb_R2O(d1, d2); + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_size_cb_L2S(d1, d2); + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_name_cb_Z2A(d1, d2); + } + } + break; + case MF_UG_SORT_BY_PRIORITY_DATE_O2R: + ret = __mf_ug_fs_oper_sort_by_size_cb_S2L(d1, d2); + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_name_cb_A2Z(d1, d2); + } + break; + case MF_UG_SORT_BY_PRIORITY_DATE_R2O: + ret = __mf_ug_fs_oper_sort_by_size_cb_L2S(d1, d2); + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_name_cb_Z2A(d1, d2); + } + break; + case MF_UG_SORT_BY_PRIORITY_SIZE_S2L: + ret = __mf_ug_fs_oper_sort_by_name_cb_A2Z(d1, d2); + break; + case MF_UG_SORT_BY_PRIORITY_SIZE_L2S: + ret = __mf_ug_fs_oper_sort_by_name_cb_Z2A(d1, d2); + break; + default: + break; + } + return ret; +} +/********************* +**Function name: __sort_by_name_cb +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** -1 if d1 > d2 +** 0 if d1 = d2 +** 1 if d1 > d2 +** +**Action: +** sort the list order by the Assic table + +** +*********************/ +static int __mf_ug_fs_oper_sort_by_name_cb_A2Z(const void *d1, const void *d2) +{ + ugFsNodeInfo *txt1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *txt2 = (ugFsNodeInfo *) d2; + gchar *name1 = NULL; + gchar *name2 = NULL; + int result = 0; + + if (!txt1) { + return (1); + } + if (!txt2) { + return (-1); + } + + name1 = g_ascii_strdown(txt1->name, strlen(txt1->name)); + if (name1 == NULL) { + return (-1); + } + name2 = g_ascii_strdown(txt2->name, strlen(txt2->name)); + if (name2 == NULL) { + g_free(name1); + name1 = NULL; + return (-1); + } + result = g_strcmp0(name1, name2); + + g_free(name1); + name1 = NULL; + g_free(name2); + name2 = NULL; + return result; + +} + +/********************* +**Function name: __sort_by_date_cb +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** -1 if d1 > d2 +** 0 if d1 = d2 +** 1 if d1 > d2 +** +**Action: +** sort the list order by the later created the later shown +*********************/ +static int __mf_ug_fs_oper_sort_by_date_cb_O2R(const void *d1, const void *d2) +{ + int ret = 0; + ugFsNodeInfo *time1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *time2 = (ugFsNodeInfo *) d2; + + if (!d1) { + return 1; + } + if (!d2) { + return -1; + } + + if (time1->date > time2->date) { + ret = 1; + } else if (time1->date < time2->date) { + ret = -1; + } else { + ret = 0; + } + + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_DATE_O2R); + } + return ret; +} + +/********************* +**Function name: __sort_by_type_cb +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** -1 if d1 < d2 +** 0 if d1 = d2 +** 1 if d1 > d2 +** +**Action: +** sort the list order by the category type value +*********************/ +static int __mf_ug_fs_oper_sort_by_type_cb_A2Z(const void *d1, const void *d2) +{ + ugFsNodeInfo *type1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *type2 = (ugFsNodeInfo *) d2; + gchar *ext1 = NULL; + gchar *ext2 = NULL; + int result = 0; + + if (type1 == NULL || type1->ext == NULL) { + return 1; + } + + if (type2 == NULL || type2->ext == NULL) { + return -1; + } + ext1 = g_ascii_strdown(type1->ext, strlen(type1->ext)); + if (ext1 == NULL) { + return (-1); + } + ext2 = g_ascii_strdown(type2->ext, strlen(type2->ext)); + if (ext2 == NULL) { + g_free(ext1); + ext1 = NULL; + return (-1); + } + result = g_strcmp0(ext1, ext2); + + g_free(ext1); + ext1 = NULL; + g_free(ext2); + ext2 = NULL; + + if (result == 0) { + result = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_TYPE_A2Z); + } + + return result; +} + +/*order: the one with smaller size will be shown earlier*/ +/********************* +**Function name: __sort_by_name_cb +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** -1 if d1 > d2 +** 0 if d1 = d2 +** 1 if d1 > d2 +** +**Action: +** sort the list order by size, rule is the smaller the later shown +*********************/ +static int __mf_ug_fs_oper_sort_by_size_cb_S2L(const void *d1, const void *d2) +{ + int ret = 0; + ugFsNodeInfo *size1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *size2 = (ugFsNodeInfo *) d2; + + if (!d1) { + return 1; + } + + if (!d2) { + return -1; + } + + if (size1->size > size2->size) { + ret = 1; + } else if (size1->size < size2->size) { + ret = -1; + } else { + ret = 0; + } + + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_SIZE_S2L); + } + return ret; +} + +/********************* +**Function name: __mf_fs_oper_sort_by_name_cb_Z2A +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** 1 if d1 > d2 +** -1 if d1 <= d2 +** +**Action: +** sort the list order by the Assic table + +** +*********************/ +static int __mf_ug_fs_oper_sort_by_name_cb_Z2A(const void *d1, const void *d2) +{ + ugFsNodeInfo *txt1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *txt2 = (ugFsNodeInfo *) d2; + + int result = 0; + + if (!txt1) { + return (1); + } + if (!txt2) { + return (-1); + } + result = strcasecmp(txt1->name, txt2->name); + + if (result < 0) { + return (1); + } else { + return (-1); + } +} + +/********************* +**Function name: __sort_by_date_cb +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** -1 if d1 > d2 +** 0 if d1 = d2 +** 1 if d1 < d2 +** +**Action: +** sort the list order by the later created the later shown +*********************/ +static int __mf_ug_fs_oper_sort_by_date_cb_R2O(const void *d1, const void *d2) +{ + int ret = 0; + ugFsNodeInfo *time1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *time2 = (ugFsNodeInfo *) d2; + + if (!d1) { + return -1; + } + if (!d2) { + return 1; + } + if (time1->date > time2->date) { + ret = -1; + } else if (time1->date < time2->date) { + ret = 1; + } else { + ret = 0; + } + + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_DATE_R2O); + } + return ret; +} + +/********************* +**Function name: __sort_by_type_cb +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** -1 if d1 > d2 +** 0 if d1 = d2 +** 1 if d1 < d2 +** +**Action: +** sort the list order by the category type value +*********************/ +static int __mf_ug_fs_oper_sort_by_type_cb_Z2A(const void *d1, const void *d2) +{ + ugFsNodeInfo *type1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *type2 = (ugFsNodeInfo *) d2; + gchar *ext1 = NULL; + gchar *ext2 = NULL; + int result = 0; + + if (type1 == NULL || type1->ext == NULL) { + return -1; + } + + if (type2 == NULL || type2->ext == NULL) { + return 1; + } + + ext1 = g_ascii_strdown(type1->ext, strlen(type1->ext)); + if (ext1 == NULL) { + return (1); + } + ext2 = g_ascii_strdown(type2->ext, strlen(type2->ext)); + if (ext2 == NULL) { + g_free(ext1); + ext1 = NULL; + return (-1); + } + result = g_strcmp0(ext1, ext2); + g_free(ext1); + ext1 = NULL; + g_free(ext2); + ext2 = NULL; + if (result == 0) { + result = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_TYPE_Z2A); + } + + return -result; +} + +/*order: the one with smaller size will be shown earlier*/ +/********************* +**Function name: __sort_by_name_cb +**Parameter: +** const void *d1: node1 to compare +** const void *d2: node2 to compare +** +**Return value: +** -1 if d1 > d2 +** 0 if d1 = d2 +** 1 if d1 < d2 +** +**Action: +** sort the list order by size, rule is the smaller the later shown +*********************/ +static int __mf_ug_fs_oper_sort_by_size_cb_L2S(const void *d1, const void *d2) +{ + int ret = 0; + ugFsNodeInfo *size1 = (ugFsNodeInfo *) d1; + ugFsNodeInfo *size2 = (ugFsNodeInfo *) d2; + + if (!d1) { + return -1; + } + + if (!d2) { + return 1; + } + + if (size1->size > size2->size) { + ret = -1; + } else if (size1->size < size2->size) { + ret = 1; + } else { + ret = 0; + } + + if (ret == 0) { + ret = __mf_ug_fs_oper_sort_by_priority(d1, d2, MF_UG_SORT_BY_PRIORITY_SIZE_L2S); + } + return ret; +} + +/********************* +**Function name: mf_fs_oper_sort_list +**Parameter: +** Eina_List **list: the list we need to sort +** int sort_opt: sort option +** +**Return value: +** void +** +**Action: +** sort the list order by sort option with the call back +*********************/ +void mf_ug_fs_oper_sort_list(Eina_List **list, int sort_opt) +{ + Eina_Compare_Cb sort_func = NULL; + if (!(*list)) { + return; + } + switch (sort_opt) { + case MF_UG_SORT_BY_NAME_A2Z: + sort_func = __mf_ug_fs_oper_sort_by_name_cb_A2Z; + break; + case MF_UG_SORT_BY_TYPE_A2Z: + sort_func = __mf_ug_fs_oper_sort_by_type_cb_A2Z; + break; + case MF_UG_SORT_BY_SIZE_S2L: + sort_func = __mf_ug_fs_oper_sort_by_size_cb_S2L; + break; + case MF_UG_SORT_BY_DATE_O2R: + sort_func = __mf_ug_fs_oper_sort_by_date_cb_O2R; + break; + case MF_UG_SORT_BY_NAME_Z2A: + sort_func = __mf_ug_fs_oper_sort_by_name_cb_Z2A; + break; + case MF_UG_SORT_BY_TYPE_Z2A: + sort_func = __mf_ug_fs_oper_sort_by_type_cb_Z2A; + break; + case MF_UG_SORT_BY_SIZE_L2S: + sort_func = __mf_ug_fs_oper_sort_by_size_cb_L2S; + break; + case MF_UG_SORT_BY_DATE_R2O: + sort_func = __mf_ug_fs_oper_sort_by_date_cb_R2O; + break; + default: + sort_func = __mf_ug_fs_oper_sort_by_type_cb_A2Z; + break; + } + *list = eina_list_sort(*list, eina_list_count(*list), sort_func); +} + +int mf_ug_fs_oper_create_dir(const char *dir) +{ + int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_DUPLICATED; + int ret = __mf_ug_fs_oper_file_system_error(dir, dir, option); + + if (ret != 0) { + return ret; + } + + ret = mf_ug_file_attr_is_right_dir_path(dir); + + if (ret != 0) { + return ret; + } + + mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + + if (mkdir(dir, default_mode) < 0) { + return MYFILE_ERR_DIR_CREATE_FAIL; + } + return MYFILE_ERR_NONE; +} + diff --git a/src/common/mf-ug-cb.c b/src/common/mf-ug-cb.c new file mode 100644 index 0000000..f7ad1a5 --- /dev/null +++ b/src/common/mf-ug-cb.c @@ -0,0 +1,1701 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include <Elementary.h> +#include <vconf.h> +#include <vconf-keys.h> +#include <pthread.h> +#include <power.h> + +#include "mf-ug-main.h" +#include "mf-ug-util.h" +#include "mf-ug-inotify-handle.h" +#include "mf-ug-winset.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-resource.h" +#include "mf-ug-list-play.h" + +#define UG_MAX_LEN_VIB_DURATION 0.5 +#ifdef UG_OPERATION_SELECT_MODE +#define RESULT_KEY "http://tizen.org/appcontrol/data/selected" +#endif +/****************************** +** Prototype : mf_ug_cb_back_button_cb +** Description : +** Input : void *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +void mf_ug_cb_back_button_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + if (ugd->ug_Status.ug_bCancelDisableFlag) { + return; + } + if (0 != ugd->ug_ListPlay.ug_Player) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + if (ugd->ug_Status.ug_iMore == UG_MORE_SEARCH) { + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navi failed"); + Evas_Object *playout = ugd->ug_MainWindow.ug_pNaviLayout; + ug_mf_retm_if(playout == NULL, "get conformant failed"); + Evas_Object *newContent = NULL; + + newContent = mf_ug_genlist_create_content_list_view(ugd); + + Evas_Object *unUsed = elm_object_part_content_unset(playout, "part1"); + evas_object_del(unUsed); + + elm_object_part_content_set(playout, "part1", newContent); + ugd->ug_Status.ug_iMore = UG_MORE_DEFAULT; + } else { + if (ugd->ug_Status.ug_bSettingEntry == true && ugd->ug_Status.ug_bInSettingView == false) { + Eina_List *l = NULL; + void *item = NULL; + ugNaviBar *pNavi_s = NULL; + ugNaviBar *pNavi_toshow = NULL; + GString *title = NULL; + + if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PLAYING || ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PAUSED) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + + EINA_LIST_FOREACH(ugd->ug_MainWindow.ug_pNaviBarList, l, item) { + pNavi_s = (ugNaviBar *)item; + if (pNavi_s == NULL) + return; + if (g_strcmp0(pNavi_s->ug_pNaviLabel, MF_UG_LABEL_PHONE) == 0) { + if (pNavi_s->ug_pCurrentPath != NULL) { + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + } + pNavi_s->ug_pCurrentPath = strdup(ugd->ug_Status.ug_pEntryPath); + pNavi_s->ug_bNaviFlagInUse = true; + pNavi_toshow = pNavi_s; + } else { + if (pNavi_s->ug_pCurrentPath != NULL) { + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + } + pNavi_s->ug_pCurrentPath = strdup(MEMORY_FOLDER); + pNavi_s->ug_bNaviFlagInUse = false; + } + + } + + if (pNavi_toshow == NULL) { + ug_debug("pNavi_toshow is NULL"); + return; + } + + if (ugd->ug_Status.ug_pPath) { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + + ugd->ug_Status.ug_bInSettingView = true; + + if (ugd->ug_Status.ug_pPath) { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + + pNavi_toshow->ug_pCurrentPath = strdup(ugd->ug_Status.ug_pEntryPath); + ugd->ug_Status.ug_pPath = g_string_new(pNavi_toshow->ug_pCurrentPath); + title = mf_ug_fm_svc_wapper_get_file_name(ugd->ug_Status.ug_pPath); + + if (title != NULL) { + pNavi_toshow->ug_pNaviTitle = g_strdup(title->str); + g_string_free(title, TRUE); + title = NULL; + } + ugd->ug_Status.ug_iViewType = mf_ug_view_normal; + mf_ug_navi_bar_create_default_view(ugd); + mf_ug_ctrl_bar_set_item_disable(ugd); + + elm_object_item_text_set(ugd->ug_MainWindow.ug_pNaviItem, pNavi_toshow->ug_pNaviTitle); + elm_naviframe_item_title_visible_set(ugd->ug_MainWindow.ug_pNaviItem, EINA_TRUE); + + } else { + ug_destroy_me(ugd->ug); + } + + } + UG_TRACE_END; + +} + +/****************************** +** Prototype : mf_ug_cb_add_button_cb +** Description : +** Input : void *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +void mf_ug_cb_add_button_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + service_h service; + + char *result = NULL; + + if (ugd->ug_Status.ug_b_NaviPushFlag) { + UG_TRACE_END; + return; + } + + if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE) { + result = g_strdup(ugd->ug_Status.ug_pPath->str); + } else { + result = mf_ug_util_get_send_result(ugd); + } + if (ugd->ug_Status.ug_bRingtoneSet) { + ug_error("result is [%s]", result); + int ret = MYFILE_ERR_NONE; + ret = mf_ug_file_attr_is_drm_file(result); + ug_error("ret is [%d]", ret); + if (ret == MYFILE_ERR_NONE) { + ret = mf_ug_fs_oper_drm_is_valid(result, DRM_PERMISSION_TYPE_PLAY); + ug_error("ret is [%d]", ret); + if (ret == true) { + ret = mf_ug_fs_oper_drm_is_action_allowed(result, DRM_HAS_VALID_SETAS_STATUS, DRM_SETAS_RINGTONE); + ug_error("ret is [%d]", ret); + } + if (ret == false) { + mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_DRM_UNABLE_SET, NULL, NULL, NULL, NULL, NULL); + return; + } + } + } + if (result) { + int ret = 0; + ret = service_create(&service); + if (ret == SERVICE_ERROR_NONE) { +#ifdef UG_OPERATION_SELECT_MODE + if (ugd->ug_UiGadget.ug_bOperationSelectFlag) { + service_add_extra_data(service, RESULT_KEY, result); + } else { + service_add_extra_data(service, "result", result); + } +#else + service_add_extra_data(service, "result", result); +#endif + ug_send_result(ugd->ug, service); + service_destroy(service); + } + ug_debug("result is [%s]", result); + UG_SAFE_FREE_CHAR(result); + } + + if (0 != ugd->ug_ListPlay.ug_Player) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + ug_destroy_me(ugd->ug); + UG_TRACE_END; +} + +void mf_ug_cb_list_by_response_cb(void *data) +{ + ugData *ugd = (ugData *)data; + assert(ugd); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navi failed"); + Evas_Object *playout = ugd->ug_MainWindow.ug_pNaviLayout; + ug_mf_retm_if(playout == NULL, "get conformant failed"); + Evas_Object *newContent = NULL; + + newContent = mf_ug_genlist_create_content_list_view(ugd); + + Evas_Object *unUsed = elm_object_part_content_unset(playout, "part1"); + evas_object_del(unUsed); + + elm_object_part_content_set(playout, "part1", newContent); + +} + + +void mf_ug_cb_list_by_button_callback(void *data, Evas_Object * obj, void *event_info) +{ + assert(data); + assert(obj); + ugData *ugd = (ugData *)data; + + Evas_Object *btn = (Evas_Object *)obj; + const char *label = elm_object_text_get(btn); + int iListBySortType = 0; + + if (g_strcmp0(label, MF_UG_LABEL_ASCENDING) == 0 ) { + switch(ugd->ug_Status.ug_iSelectedSortType) { + case 0: + iListBySortType = MF_UG_SORT_BY_NAME_Z2A; + break; + case 1: + iListBySortType = MF_UG_SORT_BY_DATE_R2O; + break; + + case 2: + iListBySortType = MF_UG_SORT_BY_SIZE_L2S; + break; + case 3: + iListBySortType = MF_UG_SORT_BY_TYPE_Z2A; + break; + default: + iListBySortType = MF_UG_SORT_BY_DATE_R2O; + break; + } + } else if(g_strcmp0(label, MF_UG_LABEL_DESCENDING) == 0 ) { + switch(ugd->ug_Status.ug_iSelectedSortType) { + case 0: + iListBySortType = MF_UG_SORT_BY_NAME_A2Z; + break; + case 1: + iListBySortType = MF_UG_SORT_BY_DATE_O2R; + break; + + case 2: + iListBySortType = MF_UG_SORT_BY_SIZE_S2L; + break; + case 3: + iListBySortType = MF_UG_SORT_BY_TYPE_A2Z; + break; + default: + iListBySortType = MF_UG_SORT_BY_DATE_O2R; + break; + } + + } + ugd->ug_Status.ug_iSortType = iListBySortType; + mf_ug_cb_list_by_response_cb(ugd); +} + + +void mf_ug_cb_popup_deleted_cb(void *data, Evas_Object * obj, void *event_info) +{ + ugData *ugd = (ugData *)data; + assert(ugd); + + mf_ug_cb_list_by_button_callback(data, obj, event_info); + + if (ugd->ug_MainWindow.ug_pNormalPopup != NULL) { + evas_object_del(ugd->ug_MainWindow.ug_pNormalPopup); + } + ugd->ug_MainWindow.ug_pNormalPopup = NULL; + +} + +void mf_ug_cb_sort_by_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + if (ugd->ug_Status.ug_b_NaviPushFlag) { + UG_TRACE_END; + return; + } + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_LIST_BY, MF_UG_LABEL_LIST_BY, + NULL, NULL, NULL, NULL, mf_ug_cb_popup_deleted_cb, ugd); + UG_TRACE_END; +} + +void mf_ug_cb_goto_myfile_button_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + if (ugd->ug_Status.ug_bCancelDisableFlag) { + ug_debug("ug_Status.ug_bCancelDisableFlag is true"); + return; + } + ugNaviBar *item = NULL; + Eina_List *l = NULL; + + ugNaviBar *pNavi_s = NULL; + ugNaviBar *pNavi_toshow = NULL; + + EINA_LIST_FOREACH(ugd->ug_MainWindow.ug_pNaviBarList, l, item) { + pNavi_s = (ugNaviBar *)item; + if (pNavi_s == NULL) + return; + if (g_strcmp0(pNavi_s->ug_pNaviLabel, MF_UG_LABEL_PHONE) == 0) { + if (pNavi_s->ug_pCurrentPath != NULL) { + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + } + pNavi_s->ug_pCurrentPath = strdup(PHONE_FOLDER); + pNavi_s->ug_bNaviFlagInUse = true; + pNavi_toshow = pNavi_s; + } else { + if (pNavi_s->ug_pCurrentPath != NULL) { + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + } + pNavi_s->ug_pCurrentPath = strdup(MEMORY_FOLDER); + pNavi_s->ug_bNaviFlagInUse = false; + } + + } + + + if (0 != ugd->ug_ListPlay.ug_Player) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + + if (ugd->ug_Status.ug_pPath) { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + ugd->ug_Status.ug_pPath = g_string_new(SOUNDS_FOLDER); + UG_SAFE_FREE_CHAR(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = strdup(ugd->ug_Status.ug_pPath->str); + + ugd->ug_Status.ug_bInSettingView = false; + + mf_ug_navi_bar_create_default_view(ugd); + ugd->ug_Status.ug_bCancelDisableFlag = true; + mf_ug_ctrl_bar_set_item_disable(ugd); +} + + +/****************************** +** Prototype : _ug_popup_exit +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +void mf_ug_cb_mass_storage_popup_cb(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + mf_ug_cb_back_button_cb(ugd, NULL, NULL); + + if (ugd->ug_MainWindow.ug_pNormalPopup) { + evas_object_del(ugd->ug_MainWindow.ug_pNormalPopup); + ugd->ug_MainWindow.ug_pNormalPopup = NULL; + } + UG_TRACE_END; +} + +void mf_ug_cb_upper_button_pressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + + Evas_Object *upper_ic = (Evas_Object *)data; + elm_image_file_set(upper_ic, UG_TITLE_ICON_UPPER_PRESS, NULL); +} + +void mf_ug_cb_upper_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + + Evas_Object *upper_ic = (Evas_Object *)data; + elm_image_file_set(upper_ic, UG_TITLE_ICON_UPPER, NULL); +} + + +/****************************** +** Prototype : mf_ug_cb_upper_click_cb +** Description : Samsung +** Input : void *data +** Evas_Object * obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_cb_upper_click_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "pNavi_s is NULL"); + + if (ugd->ug_Status.ug_b_NaviPushFlag) { + UG_TRACE_END; + return; + } + + if (ugd->ug_Status.ug_pPath != NULL && pNavi_s->ug_pCurrentPath != NULL) { + if (g_strcmp0(pNavi_s->ug_pCurrentPath, MF_UG_LABEL_PHONE) == 0 + || g_strcmp0(pNavi_s->ug_pCurrentPath, MF_UG_LABEL_MMC) == 0) { + mf_ug_navi_bar_create_default_view(ugd); + return; + } + GString *new_path = NULL; + char *file_dir = ecore_file_dir_get(pNavi_s->ug_pCurrentPath); + if (file_dir) { + new_path = g_string_new(file_dir); + UG_SAFE_FREE_GSTRING(ugd->ug_Status.ug_pPath); + ugd->ug_Status.ug_pPath = new_path; + UG_SAFE_FREE_CHAR(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = strdup(new_path->str); + free(file_dir); + file_dir = NULL; + } else { + ug_debug("file_dir is NULL"); + } + } else { + ugd->ug_Status.ug_pPath = g_string_new(MF_UG_LABEL_PHONE); + pNavi_s->ug_pCurrentPath = strdup(MF_UG_LABEL_PHONE); + } + mf_ug_navi_bar_create_default_view(ugd); + mf_ug_ctrl_bar_set_item_disable(ugd); + UG_TRACE_END; +} + +void mf_ug_cb_home_button_pressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + + Evas_Object *home_ic = (Evas_Object *)data; + elm_image_file_set(home_ic, UG_TITLE_ICON_HOME_PRESS, NULL); +} + +void mf_ug_cb_home_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + + Evas_Object *home_ic = (Evas_Object *)data; + elm_image_file_set(home_ic, UG_TITLE_ICON_HOME, NULL); +} + +void mf_ug_cb_home_button_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "pNavi_s is NULL"); + + if (ugd->ug_Status.ug_b_NaviPushFlag) { + UG_TRACE_END; + return; + } + + int storage = MF_UG_PHONE; + + storage = mf_ug_fm_svc_wapper_get_location(ugd->ug_Status.ug_pPath->str); + switch (storage) { + case MF_UG_PHONE: + UG_SAFE_FREE_GSTRING(ugd->ug_Status.ug_pPath); + ugd->ug_Status.ug_pPath = g_string_new(PHONE_FOLDER); + UG_SAFE_FREE_CHAR(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = g_strdup(PHONE_FOLDER); + mf_ug_util_set_current_state(ugd, STATE_PHONE); + break; + case MF_UG_MMC: + UG_SAFE_FREE_GSTRING(ugd->ug_Status.ug_pPath); + ugd->ug_Status.ug_pPath = g_string_new(MEMORY_FOLDER); + UG_SAFE_FREE_CHAR(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = g_strdup(MEMORY_FOLDER); + mf_ug_util_set_current_state(ugd, STATE_MEMORY); + break; + default: + return; + } + + mf_ug_navi_bar_create_default_view(ugd); + mf_ug_ctrl_bar_set_item_disable(ugd); + UG_TRACE_END; +} + +/****************************** +** Prototype : tab_callback +** Description : +** Input : void *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_cb_tab_bar_cb(void *data, const char *path) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + + const char *label = NULL; + Evas_Object *newContent = NULL; + Evas_Object *pNaviBar = NULL; + ugNaviBar *pNavi_s_toshow = NULL; + ugNaviBar *pNavi_s_inuse = NULL; + + if (ugd->ug_Status.ug_bSettingEntry == true && ugd->ug_Status.ug_bInSettingView == true) { + return; + } + + int optStorage = 0; + optStorage = mf_ug_fm_svc_wapper_get_location(path); + switch (optStorage) { + case MF_UG_PHONE: + label = MF_UG_LABEL_PHONE; + break; + case MF_UG_MMC: + label = MF_UG_LABEL_MMC; + break; + default: + break; + } + + + if (label != NULL) { + char *rootpath = NULL; + + /*0. set the previous navi to be out of use */ + pNavi_s_inuse = mf_ug_navi_bar_get_in_use_navi(ugd); + + if (pNavi_s_inuse == NULL || pNavi_s_inuse->ug_pNaviLabel == NULL) { + UG_TRACE_END; + return; + } + + pNavi_s_inuse->ug_bNaviFlagInUse = FALSE; + + if (0 != ugd->ug_ListPlay.ug_Player) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + + /*if the muisc is playing, destory the play */ + + /*1. get navi bar pointer by the label */ + pNaviBar = ugd->ug_MainWindow.ug_pNaviBar; + pNavi_s_toshow = ug_mf_navi_bar_get_navi_from_navilist(ugd->ug_MainWindow.ug_pNaviBarList, label); + + ug_debug("label is %s", label); + /*2. create navi bar if not created, otherwise get it by pNaviBar */ + if (pNavi_s_toshow == NULL) { + /*2.0 get root path by storage label */ + rootpath = mf_ug_fm_svc_wapper_get_root_path_by_tab_label(label); + if (rootpath == NULL) { + UG_TRACE_END; + return; + } + /*2.1 create the navi for the tab */ + pNavi_s_toshow = calloc(1, sizeof(ugNaviBar)); + if (pNavi_s_toshow == NULL) { + ug_debug("pNavi_s_toshow is NULL"); + free(rootpath); + rootpath = NULL; + return; + } + + pNavi_s_toshow->ug_bNaviFlagInUse = TRUE; + /*2.2 set path as root path of the storage */ + pNavi_s_toshow->ug_pCurrentPath = g_strdup(rootpath); + pNavi_s_toshow->ug_pNaviLabel = strdup(label); + free(rootpath); + rootpath = NULL; + /*2.3 insert phone navi into the navi_list */ + ugd->ug_MainWindow.ug_pNaviBarList = eina_list_append(ugd->ug_MainWindow.ug_pNaviBarList, pNavi_s_toshow); + + } else { + /*/2.1 get the navi of the tab */ + pNavi_s_toshow = mf_ug_navi_bar_get_navi_struct_by_label(ugd, label); + + pNavi_s_toshow->ug_bNaviFlagInUse = TRUE; + } + /*/2.2 set related status value. */ + if (ugd->ug_Status.ug_pPath != NULL) { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + ugd->ug_Status.ug_pPath = g_string_new(pNavi_s_toshow->ug_pCurrentPath); + ugd->ug_Status.ug_iViewType = mf_ug_view_normal; + mf_ug_navi_bar_create_default_view(ugd); + + mf_ug_ctrl_bar_set_item_disable(ugd); + } else { + ug_debug("Invalid argument: label is NULL\n"); + } + UG_TRACE_END; +} + + +void mf_ug_cb_ctrl_bar_button_cb(void *data, Evas_Object *obj, void *event_info) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + ug_mf_retm_if(event_info == NULL, "event_info is NULL"); + const char *label = NULL; + + if (ugd->ug_Status.ug_b_NaviPushFlag) + return; + label = elm_object_item_text_get((Elm_Object_Item *)event_info); + ug_mf_retm_if(label == NULL, "label is NULL"); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + if (g_strcmp0(label, MF_UG_LABEL_RINGTONES) == 0) { + if (g_strcmp0(ugd->ug_Status.ug_pPath->str, UG_RINGTION_PATH) != 0) { + UG_SAFE_FREE_GSTRING(ugd->ug_Status.ug_pPath); + ugd->ug_Status.ug_pPath = g_string_new(UG_RINGTION_PATH); + UG_SAFE_FREE_CHAR(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = g_strdup(UG_RINGTION_PATH); + mf_ug_util_set_current_state(ugd, STATE_PHONE); + ugd->ug_Status.ug_iCtrlBarType = CTRL_BAR_MUSIC; + mf_ug_navi_bar_create_default_view(ugd); + } + } else if (g_strcmp0(label, MF_UG_LABEL_OTHER_MUSIC) == 0) { + if (g_strcmp0(ugd->ug_Status.ug_pPath->str, UG_MUSIC_PATH) != 0) { + UG_SAFE_FREE_GSTRING(ugd->ug_Status.ug_pPath); + ugd->ug_Status.ug_pPath = g_string_new(UG_MUSIC_PATH); + UG_SAFE_FREE_CHAR(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = g_strdup(UG_MUSIC_PATH); + mf_ug_util_set_current_state(ugd, STATE_PHONE); + ugd->ug_Status.ug_iCtrlBarType = CTRL_BAR_RINGTONE; + mf_ug_navi_bar_create_default_view(ugd); + } + } + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_cb_list_play_cb +** Description : Samsung +** Input : ugListItemData *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_cb_list_play_cb(ugListItemData *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ugData *ugd = NULL; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + ug_mf_retm_if(itemData->ug_pData == NULL, "ug_pData is NULL"); + + ugd = itemData->ug_pData; + + if (itemData->ug_pData->ug_Status.ug_b_NaviPushFlag) + return; + + mf_ug_list_play_play_music_item(itemData); + + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_cb_select_info_show_cb +** Description : Samsung +** Input : void *data +** Evas *e +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_cb_select_info_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + edje_object_signal_emit(_EDJ(ugd->ug_MainWindow.ug_pMainLayout), "elm,state,show,default", "elm"); + UG_TRACE_END; + return; +} + +/****************************** +** Prototype : mf_ug_cb_select_info_hide_cb +** Description : Samsung +** Input : void *data +** Evas *e +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_cb_select_info_hide_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + edje_object_signal_emit(_EDJ(ugd->ug_MainWindow.ug_pMainLayout), "elm,state,hide,default", "elm"); + UG_TRACE_END; + return; +} + +/****************************** +** Prototype : mf_ug_cb_select_info_timeout_cb +** Description : Samsung +** Input : void *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_cb_select_info_timeout_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + edje_object_signal_emit(_EDJ(ugd->ug_MainWindow.ug_pMainLayout), "elm,state,hide,default", "elm"); + UG_TRACE_END; + return; +} + + +/****************************** +** Prototype : mf_ug_cb_mmc_changed_cb +** Description : Samsung +** Input : keynode_t *key +** void* data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_cb_mmc_remove_view_operation(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Evas_Object *parent = NULL; + const char *labelStorage = NULL; + parent = ugd->ug_MainWindow.ug_pNaviGenlist; + labelStorage = MEMORY_FOLDER; + + mf_ug_genlist_item_remove(parent, labelStorage); + +} + +void mf_ug_cb_mmc_changed_cb(keynode_t *key, void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + ug_mf_retm_if(ugd->ug_Status.ug_pPath == NULL || ugd->ug_Status.ug_pPath->str == NULL, "ugd->ug_Status.ug_pPath is NULL"); + + int optStorage = MF_UG_NONE; + char *labelStorage = NULL; + + if (VCONF_TYPE_INT == vconf_keynode_get_type(key) + && VCONFKEY_SYSMAN_MMC_MOUNTED == vconf_keynode_get_int(key)) { + if (ugd->ug_Status.ug_bInSettingView && ugd->ug_Status.ug_bSettingEntry) { + ugd->ug_Status.ug_iMmcFlag = MMC_ON; + return; + } + ugd->ug_Status.ug_iMmcFlag = MMC_ON; + + mf_ug_util_storage_insert_action(ugd, MF_UG_LABEL_MMC); + } else { + ugNaviBar *pNaviInUseStruct = NULL; + + if (VCONFKEY_SYSMAN_MMC_REMOVED == vconf_keynode_get_int(key) + || VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED == vconf_keynode_get_int(key)) { + ug_debug("mmc removed"); + if (ugd->ug_Status.ug_bInSettingView && ugd->ug_Status.ug_bSettingEntry) { + ugd->ug_Status.ug_iMmcFlag = MMC_OFF; + return; + } + optStorage = MF_UG_MMC; + ugd->ug_Status.ug_iMmcFlag = MMC_OFF; + } + + if (optStorage == MF_UG_NONE) { + ug_debug("get removed storage failed"); + return; + } + + labelStorage = MF_UG_LABEL_MMC; + if (mf_ug_fm_svc_wapper_get_location(ugd->ug_Status.ug_pPath->str) == optStorage) { + if (0 != ugd->ug_ListPlay.ug_Player) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + + mf_ug_navi_bar_remove_navi_list_item_by_label(ugd, labelStorage); + pNaviInUseStruct = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_debug("label is [%s]pNaviInUseStruct->ug_pCurrentPath is [%s]", pNaviInUseStruct->ug_pNaviLabel, pNaviInUseStruct->ug_pCurrentPath); + mf_ug_navi_bar_refresh_navibar_recovered_view(ugd, pNaviInUseStruct); + } + } + + if(mf_ug_fm_svc_wapper_is_root_path(ugd->ug_Status.ug_pPath)) + { + elm_naviframe_item_title_visible_set(ugd->ug_MainWindow.ug_pNaviItem, EINA_FALSE); + mf_ug_callback_tab_click(ugd); + } + else + { + mf_ug_navi_bar_title_set(ugd); + } + + UG_TRACE_END; + return; +} + +/****************************** +** Prototype : mf_ug_cb_dir_update_cb +** Description : Samsung +** Input : mf_ug_inotify_event event +** char *name +** void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_cb_dir_update_cb(mf_ug_inotify_event event, char *name, void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + ug_debug("event : %d, name : %s", event, name); + + ug_dir_event_t buffer; + + buffer.event = event; + buffer.name = strdup(name); + + ecore_pipe_write(ugd->ug_UiGadget.ug_pInotifyPipe, &buffer, sizeof(buffer)); + UG_TRACE_END; + + return; +} + +/****************************** +** Prototype : mf_ug_cb_dir_pipe_cb +** Description : Samsung +** Input : void *data +** void *buffer +** unsigned int nbyte +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static GString *__mf_ug_cb_dir_pipe_get_parent(GString *path) +{ + + ug_mf_retvm_if(path == NULL, NULL, "path is NULL"); + ug_mf_retvm_if(path->str == NULL, NULL, "path->str is NULL"); + + if (ecore_file_exists(path->str)) { + return path; + } else if (mf_ug_fm_svc_wapper_is_root_path(path)) { + return path; + } else { + GString *parent = mf_ug_fm_svc_wrapper_get_file_parent_path(path); + UG_SAFE_FREE_GSTRING(path); + __mf_ug_cb_dir_pipe_get_parent(parent); + } + return path; +} + +void mf_ug_cb_dir_pipe_cb(void *data, void *buffer, unsigned int nbyte) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + + if (ugd->ug_ListPlay.ug_iPlayState != PLAY_STATE_INIT) { + return; + } + + if (g_strcmp0(ugd->ug_Status.monitor_path, ugd->ug_Status.ug_pPath->str)) { + return; + } + if (buffer) { + ug_dir_event_t *msg = (ug_dir_event_t *) buffer; + ug_debug("event : %d, name : %s", msg->event, msg->name); + + Evas_Object *newContent = NULL; + ugListItemData *itemData = NULL; + Elm_Object_Item *it = NULL; + GString *parent = NULL; + char *path = NULL; + int count = 0; + + switch (msg->event) { + case UG_MF_INOTI_CREATE: + case UG_MF_INOTI_MOVE_IN: + /*/1 TODO: add new item to list */ + if(msg->name) { + path = g_strconcat(ugd->ug_Status.ug_pPath->str, "/", msg->name, NULL); + int file_type = 0; + if (mf_ug_file_attr_is_dir(path)) { + file_type = UG_FILE_TYPE_DIR; + } else { + file_type = UG_FILE_TYPE_FILE; + } + ugFsNodeInfo *pNode = mf_ug_util_generate_pnode(path, file_type); + if (ugd->ug_MainWindow.ug_pNaviGenlist == NULL) { + + Evas_Object *genlist = NULL; + genlist = elm_genlist_add(ugd->ug_MainWindow.ug_pNaviBar); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + + ugd->ug_MainWindow.ug_pNaviGenlist = genlist; + evas_object_smart_callback_add(genlist, "selected", mf_ug_genlist_selected_gl, ugd); + + evas_object_del(elm_object_part_content_unset(ugd->ug_MainWindow.ug_pNaviLayout, "part1")); + + elm_object_part_content_set(ugd->ug_MainWindow.ug_pNaviLayout, "part1", newContent); + elm_object_part_content_set(ugd->ug_MainWindow.ug_pNaviLayout, "part1", genlist); + } + if (file_type == UG_FILE_TYPE_DIR) { + if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + + mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, pNode, ugd, 0, &ugd->ug_Status.ug_normalitc); + } else { + int groupValue = elm_genlist_items_count(ugd->ug_MainWindow.ug_pNaviGenlist); + mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, pNode, ugd, groupValue, &ugd->ug_Status.ug_itc); + } + } else { + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + int groupValue = elm_genlist_items_count(ugd->ug_MainWindow.ug_pNaviGenlist); + mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, pNode, ugd, groupValue, &ugd->ug_Status.ug_itc); + } else if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE) { + mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, pNode, ugd, 0, &ugd->ug_Status.ug_normalitc); + } else { + mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, pNode, ugd, 0, &ugd->ug_Status.ug_itc); + } + + } + + if (pNode != NULL) { + UG_SAFE_FREE_CHAR(pNode->ext); + free(pNode); + pNode = NULL; + } + } + break; + case UG_MF_INOTI_DELETE: + case UG_MF_INOTI_MOVE_OUT: + /*/1 TODO: remove item from list */ + path = g_strconcat(ugd->ug_Status.ug_pPath->str, "/", msg->name, NULL); + it = elm_genlist_first_item_get(ugd->ug_MainWindow.ug_pNaviGenlist); + while (it) { + itemData = elm_object_item_data_get(it); + if (itemData->ug_pItemName == NULL || itemData->ug_pItemName->str == NULL) { + ug_debug(); + continue; + } + if (g_strcmp0(path, itemData->ug_pItemName->str) == 0) { + elm_object_item_del(it); + break; + } + + it = elm_genlist_item_next_get(it); + } + count = elm_genlist_items_count(ugd->ug_MainWindow.ug_pNaviGenlist); + ugd->ug_Status.ug_bNoContentFlag = !count; + + break; + case UG_MF_INOTI_MODIFY: + /*/1 TODO: update item in list */ + ugd->ug_MainWindow.ug_pNaviGenlist = newContent = mf_ug_genlist_create_content_list_view(ugd); + mf_ug_navi_bar_set_new_content(ugd->ug_MainWindow.ug_pNaviLayout, newContent); + break; + case UG_MF_INOTI_DELETE_SELF: + case UG_MF_INOTI_MOVE_SELF: + /*/1 TODO: watching directory is removed, change current directory. */ + { + GString *current = NULL; + current = g_string_new(ugd->ug_Status.ug_pPath->str); + parent = __mf_ug_cb_dir_pipe_get_parent(current); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + + + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + ugd->ug_Status.ug_pPath = parent; + + if (pNavi_s->ug_pCurrentPath != NULL) { + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + } + pNavi_s->ug_pCurrentPath = g_strdup(parent->str); + + + + mf_ug_navi_bar_create_default_view(ugd); + } + break; + default: + ug_mf_error("Unknown event"); + break; + } + mf_ug_ctrl_bar_set_item_disable(ugd); + if (msg->name) { + free(msg->name); + msg->name = NULL; + } + } + UG_TRACE_END; +} + + +#ifdef UG_THUMB_REAL_TIME_UPDATE +Eina_Bool mf_ug_cb_thumb_timer_cb(void *data) +{ + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retvm_if(itemData == NULL, EINA_FALSE, "input params is NULL"); + ugData *ugd = (ugData *)itemData->ug_pData; + ug_mf_retvm_if(ugd == NULL, EINA_FALSE, "ugd is NULL"); + + bool allright_flag = true; + Evas_Object *pContent = NULL; + + if (ugd->ug_Status.ug_pThumbUpdateTimer == NULL) { + return EINA_FALSE; + } + + /****read the realized part of the list****/ + if (itemData->ug_pItem) { + pContent = elm_object_item_widget_get(itemData->ug_pItem); + if (pContent == NULL) { + ugd->ug_Status.ug_pThumbUpdateTimer = NULL; + return EINA_FALSE; + } + } else { + ugd->ug_Status.ug_pThumbUpdateTimer = NULL; + return EINA_FALSE; + } + Eina_List *realized_list = elm_genlist_realized_items_get(pContent); + Eina_List *list = NULL; + Elm_Object_Item *it; + ugListItemData *item_data = NULL; + + if (realized_list == NULL) { + allright_flag = false; + } + + EINA_LIST_FOREACH(realized_list, list, it) { + item_data = (ugListItemData *)elm_object_item_data_get(it); + if (item_data == NULL) + continue; + + if (item_data->ug_bRealThumbFlag == false) { + ug_debug("Update item: %s", item_data->ug_pItemName->str); + if (ecore_file_is_dir(item_data->ug_pItemName->str) == true) { + item_data->ug_pThumbPath = strdup(UG_ICON_FOLDER); + item_data->ug_bRealThumbFlag = true; + elm_object_item_data_set(it, item_data); + elm_genlist_item_update(it); + + } else if (ecore_file_exists(item_data->ug_pItemName->str)) { + char *new_thumb = NULL; + int thumbnail_type = 0; + thumbnail_type = mf_ug_file_attr_get_file_icon(item_data->ug_pItemName->str, NULL, &new_thumb); + if (new_thumb) { + if (thumbnail_type == MF_UG_THUMBNAIL_TYPE_DEFAULT) { + if (item_data->ug_pThumbPath && g_strcmp0(new_thumb, item_data->ug_pThumbPath) == 0) { + allright_flag = FALSE; + } else { + if (item_data->ug_pThumbPath) { + free(item_data->ug_pThumbPath); + item_data->ug_pThumbPath = NULL; + } + item_data->ug_pThumbPath = strdup(new_thumb); + item_data->ug_bRealThumbFlag = TRUE; + elm_object_item_data_set(it, item_data); + elm_genlist_item_update(it); + free(new_thumb); + new_thumb = NULL; + } + + } else { + if (item_data->ug_pThumbPath) { + free(item_data->ug_pThumbPath); + item_data->ug_pThumbPath = NULL; + } + item_data->ug_pThumbPath = strdup(new_thumb); + item_data->ug_bRealThumbFlag = TRUE; + elm_object_item_data_set(it, item_data); + elm_genlist_item_update(it); + free(new_thumb); + new_thumb = NULL; + } + } else { + allright_flag = false; + } + } + } + } + + if (allright_flag == false) { + return EINA_TRUE; + } else { + ugd->ug_Status.ug_pThumbUpdateTimer = NULL; + return EINA_FALSE; + } +} +#endif + +void mf_ug_cb_create_new_folder(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + + ugData *ugd = (ugData *)data; + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pContextPopup); + + if (ugd->ug_Status.ug_b_NaviPushFlag) { + UG_TRACE_END; + return; + } + + if (ugd->ug_Status.ug_iMore == UG_MORE_CREATE_FOLDER) + return; + + int ret = 0; + ugd->ug_Status.ug_iMore = UG_MORE_CREATE_FOLDER; + + ret = mf_ug_util_check_disk_space(ugd); + if (ret == MYFILE_ERR_NO_FREE_SPACE) { + ugd->ug_Status.ug_iMore = UG_MORE_DEFAULT; + return; + } +#ifdef UG_THUMB_REAL_TIME_UPDATE + if (ugd->ug_Status.ug_pThumbUpdateTimer != NULL) { + ecore_timer_del(ugd->ug_Status.ug_pThumbUpdateTimer); + ugd->ug_Status.ug_pThumbUpdateTimer = NULL; + } +#endif + ugd->ug_MainWindow.ug_pNewFolderPopup = mf_ug_popup_create_new_folder_popup(ugd, MF_UG_LABEL_CREATE); + +} + +void mf_ug_cb_warning_popup_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + Evas_Object *btn = (Evas_Object *)obj; + const char *label = elm_object_text_get(btn); + + if (g_strcmp0(label, MF_UG_LABEL_OK) == 0 ) { + evas_object_del(ugd->ug_MainWindow.ug_pNormalPopup); + ugd->ug_MainWindow.ug_pNormalPopup = NULL; + } +} + +void mf_ug_cb_reach_max_len_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + mf_ug_popup_indicator_popup(MF_UG_LABEL_MAX_CHARACTER_REACHED); + + UG_TRACE_END; +} + +void mf_ug_cb_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + elm_entry_entry_set(data, ""); +} + +void mf_ug_cb_cancel_new_folder_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + ugd->ug_Status.ug_iMore = UG_MORE_DEFAULT; + ecore_imf_context_input_panel_hide(elm_entry_imf_context_get(ugd->ug_MainWindow.ug_pEntry)); + evas_object_del(ugd->ug_MainWindow.ug_pEntry); + + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pNewFolderPopup); +} + +static int __mf_cb_imk_cancel_cb(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(data == NULL, false, "data is NULL"); + ugData *ugd = (ugData *)data; + + mf_ug_cb_cancel_new_folder_cb(ugd, NULL, NULL); + ugd->ug_Status.popup_del_idler = NULL; + return 0; +} + + +static void __mf_ug_cb_illegal_char_popup_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + Evas_Object *btn = (Evas_Object *)obj; + const char *label = elm_object_text_get(btn); + + if (g_strcmp0(label, MF_UG_LABEL_YES) == 0 ) { + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pNormalPopup); + + Evas_Object *entry = ugd->ug_MainWindow.ug_pEntry; + if (entry != NULL) + elm_object_focus_set(entry, EINA_TRUE); + + } else if (g_strcmp0(label, MF_UG_LABEL_NO) == 0 ) { + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pNormalPopup); + ugd->ug_Status.popup_del_idler = ecore_idler_add((Ecore_Task_Cb) __mf_cb_imk_cancel_cb, ugd); + } + +} + +static int __mf_ug_cb_ime_mkdir_cb(void *data, char *fileName) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + + ug_mf_retvm_if(ugd == NULL, MYFILE_ERR_SRC_ARG_INVALID, "ugd is NULL"); + ug_mf_retvm_if(fileName == NULL, MYFILE_ERR_SRC_ARG_INVALID, "data is NULL"); + ug_mf_retvm_if(ugd->ug_Status.ug_pPath == NULL, MYFILE_ERR_SRC_ARG_INVALID, "ugd is NULL"); + ug_mf_retvm_if(ugd->ug_Status.ug_pPath->str == NULL, MYFILE_ERR_SRC_ARG_INVALID, "ugd is NULL"); + + + int ret = 0; + const char *message = NULL; + const char *left_label = NULL; + const char *right_label = NULL; + + left_label = MF_UG_LABEL_YES; + right_label = MF_UG_LABEL_NO; + if (strlen(fileName)) { + + GString *fullpathdir = g_string_new(ugd->ug_Status.ug_pPath->str); + + if (fullpathdir == NULL) { + mf_ug_util_operation_alloc_failed(ugd); + return MYFILE_ERR_ALLOCATE_MEMORY_FAIL; + } + GString *fullpathname = g_string_new(fileName); + + if (fullpathname == NULL) { + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + mf_ug_util_operation_alloc_failed(ugd); + return MYFILE_ERR_ALLOCATE_MEMORY_FAIL; + } + /*check the space */ + gchar *test_space = g_strdup(fileName); + if (test_space == NULL) { + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + mf_ug_util_operation_alloc_failed(ugd); + return MYFILE_ERR_ALLOCATE_MEMORY_FAIL; + } + if (strlen(g_strchug(test_space)) == 0) { + message = MF_UG_LABEL_NAME_INVALID; /*TODO */ + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT_TWO_BTN, NULL, message, + left_label, right_label, NULL, + __mf_ug_cb_illegal_char_popup_cb, ugd); + + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + g_free(test_space); + test_space = NULL; + return MYFILE_ERR_DIR_CREATE_FAIL; + } + + g_free(test_space); + test_space = NULL; + + /*check if input name is valid */ + if (mf_ug_file_attr_is_valid_name(fullpathname->str) == MYFILE_ERR_INVALID_FILE_NAME) { + + message = MF_UG_LABEL_ILLEGAL_CHAR; + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT_TWO_BTN, NULL, message, + left_label, right_label, NULL, + __mf_ug_cb_illegal_char_popup_cb, ugd); + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + + return MYFILE_ERR_DIR_CREATE_FAIL; + } + + GString *fullpath = NULL; + char *temp_fullpath = g_strconcat(fullpathdir->str, "/", fullpathname->str, NULL); + if (temp_fullpath) { + fullpath = g_string_new(temp_fullpath); + + free(temp_fullpath); + temp_fullpath = NULL; + if (fullpath == NULL) { + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + mf_ug_util_operation_alloc_failed(ugd); + return MYFILE_ERR_ALLOCATE_MEMORY_FAIL; + } + } else { + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + return MYFILE_ERR_ALLOCATE_MEMORY_FAIL; + } + + /*check whether DIR name is override(DIR name has no extention) */ + /*check whether path length is override */ + if ((strlen(fullpathdir->str) + strlen(fullpathname->str)) > MYFILE_FILE_PATH_LEN_MAX) { + + message = MF_UG_LABEL_PATH_REACH_MAX_LEN; + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT_TWO_BTN, NULL, message, + left_label, right_label, NULL, + __mf_ug_cb_illegal_char_popup_cb, ugd); + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + ret = MYFILE_ERR_DIR_CREATE_FAIL; + } + /*check if duplicated name */ + else if (mf_ug_file_attr_is_duplicated_name(ugd->ug_Status.ug_pPath->str, fileName) == MYFILE_ERR_DUPLICATED_NAME) { + message = MF_UG_LABEL_DUP_NAME; + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT_TWO_BTN, NULL, message, + left_label, right_label, NULL, + __mf_ug_cb_illegal_char_popup_cb, ugd); + + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + ret = MYFILE_ERR_DIR_CREATE_FAIL; + } + /*check if DIR name is all spaces */ + else { + ret = mf_ug_fm_svc_wrapper_create_service(ugd, fullpath); + /*check whether operate on read only area */ + if (errno == EROFS) { + message = MF_UG_LABEL_OPER_READ_ONLY; + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL); + ret = MYFILE_ERR_DIR_CREATE_FAIL; + } else if (ret) { + message = MF_UG_LABEL_CREATE_DIR_FAILED; + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL); + } + + g_string_free(fullpathdir, TRUE); + fullpathdir = NULL; + g_string_free(fullpathname, TRUE); + fullpathname = NULL; + g_string_free(fullpath, TRUE); + fullpath = NULL; + + } + } else { + message = MF_UG_LABEL_EMPTY_FOLDER_NAME; + + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT_TWO_BTN, NULL, message, + left_label, right_label, NULL, + __mf_ug_cb_illegal_char_popup_cb, ugd); + ret = MYFILE_ERR_DIR_CREATE_FAIL; + } + return ret; +} + + +void mf_ug_cb_save_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + if (ugd->ug_Status.ug_b_NaviPushFlag) { + UG_TRACE_END; + return; + } + + int ret = 0; + const char *message = NULL; + const char *left_label = NULL; + const char *right_label = NULL; + + if (ugd->ug_Status.ug_iMore == UG_MORE_CREATE_FOLDER) { + const char *entry_data = NULL; + char *name = NULL; + + /*hide IMF*/ + if (ugd->ug_MainWindow.ug_pEntry != NULL) { + Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ugd->ug_MainWindow.ug_pEntry); + if (imf_context != NULL) + ecore_imf_context_hide(imf_context); + } + + entry_data = elm_entry_entry_get(ugd->ug_MainWindow.ug_pEntry); + + if (entry_data) { + name = elm_entry_markup_to_utf8(entry_data); + } else { + message = MF_UG_LABEL_GET_NAME_FAILED; + left_label = MF_UG_LABEL_YES; + right_label = MF_UG_LABEL_NO; + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT_TWO_BTN, NULL, message, + left_label, right_label, NULL, + __mf_ug_cb_illegal_char_popup_cb, ugd); + return; + } + + if (name == NULL) + return; + + ret = __mf_ug_cb_ime_mkdir_cb(ugd, name); + if (ret == 0) { + ugd->ug_Status.ug_iMore = UG_MORE_DEFAULT; + ecore_imf_context_input_panel_hide(elm_entry_imf_context_get(ugd->ug_MainWindow.ug_pEntry)); + evas_object_del(ugd->ug_MainWindow.ug_pEntry); + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pNewFolderPopup); + mf_ug_navi_bar_create_default_view(ugd); + } + + if (name != NULL) { + free(name); + name = NULL; + } + } +} + +void mf_ug_cb_lcd_state_changed_cb(power_state_e state, void *user_data) +{ + UG_TRACE_BEGIN; + + ug_mf_retm_if(user_data == NULL, "user_data is NULL"); + ugData *ugd = (ugData *)user_data; + + if(state == POWER_STATE_SCREEN_OFF){ + if (0 != ugd->ug_ListPlay.ug_Player) { + ug_debug("destory the playing file"); + mf_ug_list_play_destory_playing_file(ugd); + mf_ug_list_disable_play_itc(ugd, true); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + } + UG_TRACE_END; +} + + +Eina_Bool mf_ug_cb_popup_del_idler_cb(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(data == NULL, ECORE_CALLBACK_CANCEL, "data is NULL"); + ugData *ugd = (ugData *)data; + + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pSearchPopup); + ugd->ug_Status.popup_del_idler = NULL; + + return ECORE_CALLBACK_CANCEL; +} + +void mf_ug_cb_entry_button_pressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + + Evas_Object *home_button_ic = (Evas_Object *)data; + elm_image_file_set(home_button_ic, UG_ICON_ENTRY_FOLDER_PRESS, NULL); +} + +void mf_ug_cb_entry_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + + Evas_Object *home_button_ic = (Evas_Object *)data; + elm_image_file_set(home_button_ic, UG_ICON_ENTRY_FOLDER, NULL); +} + +void mf_ug_cb_play_button_pressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + const char *play_icon = NULL; + + Evas_Object *music_icon = elm_object_part_content_get(obj, "icon"); + if(ugd->ug_ListPlay.ug_iPlayState != PLAY_STATE_PLAYING) { + play_icon = UG_ICON_MUSIC_PLAY_WHITE_PRESS; + } else { + play_icon = UG_ICON_MUSIC_PAUSE_WHITE_PRESS; + } + + elm_image_file_set(music_icon, play_icon, NULL); +} + +void mf_ug_cb_play_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + const char *play_icon = NULL; + + Evas_Object *music_icon = elm_object_part_content_get(obj, "icon"); + if(ugd->ug_ListPlay.ug_iPlayState != PLAY_STATE_PLAYING) { + play_icon = UG_ICON_MUSIC_PLAY_WHITE; + } else { + play_icon = UG_ICON_MUSIC_PAUSE_WHITE; + } + + elm_image_file_set(music_icon, play_icon, NULL); +} + +void mf_ug_cb_more_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + mf_ug_context_popup_create_more(ugd, obj); +} + + diff --git a/src/common/mf-ug-fm-svc-wapper.c b/src/common/mf-ug-fm-svc-wapper.c new file mode 100644 index 0000000..4cea7b6 --- /dev/null +++ b/src/common/mf-ug-fm-svc-wapper.c @@ -0,0 +1,946 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <sys/statvfs.h> + +#include "mf-ug-util.h" +#include "mf-ug-cb.h" +#include "mf-ug-main.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-resource.h" + +#define UG_FILTER_CATEGORY_ALL \ +UG_FILTER_CATEGORY_NONE | UG_FILTER_CATEGORY_IMAGE | UG_FILTER_CATEGORY_VIDEO \ +| UG_FILTER_CATEGORY_SOUND | UG_FILTER_CATEGORY_VOICE | UG_FILTER_CATEGORY_MUSIC \ +| UG_FILTER_CATEGORY_HTML | UG_FILTER_CATEGORY_FLASH | UG_FILTER_CATEGORY_GAME \ +| UG_FILTER_CATEGORY_APP | UG_FILTER_CATEGORY_THEME | UG_FILTER_CATEGORY_DOC \ +| UG_FILTER_CATEGORY_EXCEL | UG_FILTER_CATEGORY_PPT | UG_FILTER_CATEGORY_PDF \ +| UG_FILTER_CATEGORY_TXT | UG_FILTER_CATEGORY_VCONTACT | UG_FILTER_CATEGORY_VCALENDAR \ +| UG_FILTER_CATEGORY_VNOTE | UG_FILTER_CATEGORY_VBOOKMARK | UG_FILTER_CATEGORY_VIDEO_PROJECT\ +| UG_FILTER_CATEGORY_SVG | UG_FILTER_CATEGORY_ETC + + +#define MF_UG_PATH_INFO_RETRENCH 128 +#define MF_UG_PATH_INFO_HEAD_LEN(x) strlen(x) +#define MF_UG_PATH_INFO_TRANS_OMIT elm_entry_utf8_to_markup("..") +#define MF_UG_PATH_INFO_LEVEL_BOUNDARY 3 +#define MF_UG_PATH_INFO_LEN_THRESHOLD 4 +#define MF_UG_PATH_INFO_SEP elm_entry_utf8_to_markup("/") +typedef struct { + int len_orig; + int len_trans; + char *original; + char *transfer; + bool flag_trans; +}ug_pNode; + +/********************* +**Function name: __mf_ug_fm_svc_wapper_COMESFROM +**Parameter: +** GString* fullpath: fullpath to check the location +** +**Return value: +** location of the path +** +**Action: +** get storage type by fullpath +*********************/ +static int __mf_ug_fm_svc_wapper_COMESFROM(char *fullpath) +{ + int len_phone = strlen(PHONE_FOLDER); + int len_memory = strlen(MEMORY_FOLDER); + + if (strncmp(fullpath, PHONE_FOLDER, len_phone) == 0) { + return MF_UG_PHONE; + } else if (strncmp(fullpath, MEMORY_FOLDER, len_memory) == 0) { + return MF_UG_MMC; + } else { + return MYFILE_ERR_STORAGE_TYPE_ERROR; + } +} + +/****************************** +** Prototype : _ug_mf_get_file_list +** Description : +** Input : struct ugmyfiledata *data +** GString* folder_name +** Eina_List** dir_list +** Eina_List** file_list +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static int __mf_ug_fm_svc_wapper_get_file_list(GString *fullpath, Eina_List **dir_list, Eina_List **file_list) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(fullpath == NULL, MYFILE_ERR_INVALID_ARG, "fullpath is NULL"); + ug_mf_retvm_if(fullpath->str == NULL, MYFILE_ERR_INVALID_ARG, "fullpath->str is NULL"); + ug_mf_retvm_if(fullpath->len == 0, MYFILE_ERR_INVALID_ARG, "fullpath->len is 0"); + + int error_code = 0; + + error_code = mf_ug_fs_oper_read_dir(fullpath->str, dir_list, file_list); + if (error_code != 0) { + ug_debug("error_code is [%d]\n", error_code); + } else { + ug_debug("success get the file list\n"); + } + UG_TRACE_END; + return error_code; +} + + +/****************************** +** Prototype : mfUgGetFileListWithFormat +** Description : +** Input : struct ugmyfiledata *data +** GString* folder_name +** Eina_List** dir_list +** Eina_List** file_list +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +unsigned long mf_ug_fm_svc_wapper_get_file_filter(int file_filter_mode) +{ + unsigned long filter = 0; + switch (file_filter_mode) { + case SHOW_ALL_LIST: + filter |= UG_FILTER_CATEGORY_ALL; + ug_debug("show_all_list:::::::::::::::::::::::::::::::::: filter is [%d]", filter); + break; + case SHOW_IMAGE_LIST: + filter |= UG_FILTER_CATEGORY_IMAGE; + break; + case SHOW_SOUND_LIST: + filter |= UG_FILTER_CATEGORY_MUSIC | UG_FILTER_CATEGORY_SOUND | UG_FILTER_CATEGORY_VOICE; + break; + case SHOW_VIDEO_LIST: + filter |= UG_FILTER_CATEGORY_VIDEO; + break; + case SHOW_FLASH_LIST: + filter |= UG_FILTER_CATEGORY_FLASH; + break; + case SHOW_FOLDER_LIST: + break; + case SHOW_IMAGE_VIDEO_LIST: + filter |= UG_FILTER_CATEGORY_IMAGE | UG_FILTER_CATEGORY_VIDEO; + break; + case SHOW_IMAGE_SOUND_LIST: + filter |= UG_FILTER_CATEGORY_IMAGE | UG_FILTER_CATEGORY_SOUND | UG_FILTER_CATEGORY_MUSIC | UG_FILTER_CATEGORY_VOICE; + break; + case SHOW_VIDEO_SOUND_LIST: + filter |= UG_FILTER_CATEGORY_SOUND | UG_FILTER_CATEGORY_VIDEO | UG_FILTER_CATEGORY_MUSIC | UG_FILTER_CATEGORY_VOICE; + break; + default: + break; + } + return filter; +} + +int mf_ug_fm_svc_wapper_get_drm_filter(int drm_filter_mode, unsigned long file_filter) +{ + int drm_filter = 0; + unsigned long filter = file_filter; + unsigned long all = (unsigned long)(UG_FILTER_CATEGORY_ALL); + + switch (drm_filter_mode) { + case DRM_FILTER_ALL: + if (filter == all) { + ug_debug("drm_filter is ALL"); + drm_filter |= MF_UG_FILTER_DRM_ALL; + } else { + if (filter & UG_FILTER_CATEGORY_IMAGE) { + ug_debug("drm_filter is IMAGE"); + drm_filter |= MF_UG_FILTER_DRM_IMAGE; + } + if (filter & UG_FILTER_CATEGORY_SOUND) { + ug_debug("drm_filter is SOUND"); + drm_filter |= MF_UG_FILTER_DRM_RINGTONE; + } + if (filter & UG_FILTER_CATEGORY_MUSIC) { + ug_debug("drm_filter is MUSIC"); + drm_filter |= MF_UG_FILTER_DRM_RINGTONE; + } + } + break; + case DRM_FILTER_WITHOUT_FL: + drm_filter |= MF_UG_FILTER_DRM_WITHOUT_FL; + if (filter == all) { + drm_filter |= MF_UG_FILTER_DRM_ALL; + } else { + if (filter & UG_FILTER_CATEGORY_IMAGE) { + drm_filter |= MF_UG_FILTER_DRM_IMAGE; + } + if (filter & UG_FILTER_CATEGORY_SOUND) { + drm_filter |= MF_UG_FILTER_DRM_RINGTONE; + } + if (filter & UG_FILTER_CATEGORY_MUSIC) { + drm_filter |= MF_UG_FILTER_DRM_RINGTONE; + } + } + break; + default: + break; + } + return drm_filter; +} + +int mf_ug_fm_svc_wapper_get_file_list_by_filter(ugData *data, GString *fullpath, Eina_List **dir_list, Eina_List **filter_list) +{ + ugData *ugd = data; + ug_mf_retvm_if(ugd == NULL, MYFILE_ERR_INVALID_ARG, "ugd is NULL"); + ug_mf_retvm_if(fullpath == NULL, MYFILE_ERR_INVALID_ARG, "fullpath is NULL"); + ug_mf_retvm_if(fullpath->str == NULL, MYFILE_ERR_INVALID_ARG, "fullpath->str is NULL"); + ug_mf_retvm_if(fullpath->len == 0, MYFILE_ERR_INVALID_ARG, "fullpath->len is 0"); + + int error_code = 0; + int filter_mode = 0; + int file_filter = 0; + int drm_filter = 0; + int file_list_len = 0; + Eina_List *file_list = NULL; + char *extension = NULL; + + filter_mode = ugd->ug_UiGadget.ug_iFilterMode; + file_filter = ugd->ug_UiGadget.ug_iFileFilter; + drm_filter = ugd->ug_UiGadget.ug_iDrmFilter; + + ug_debug("fullpath is [%s]", fullpath->str); + error_code = __mf_ug_fm_svc_wapper_get_file_list(fullpath, dir_list, &file_list); + + if (error_code == 0) { + ug_debug(); + file_list_len = eina_list_count(file_list); + + if (file_list_len > 0) { + ug_debug("file_filter is [%d]\n", filter_mode); + + if (filter_mode != SHOW_BY_EXTENSION) { + ug_debug("file_filter is [%d] drm_filter is [%d]", file_filter, drm_filter); + error_code = mf_ug_fs_oper_list_filter(file_list, filter_list, file_filter, drm_filter); + } else if (ugd->ug_UiGadget.ug_pExtension != NULL) { + extension = strdup(ugd->ug_UiGadget.ug_pExtension); + error_code = mf_ug_fs_oper_list_filter_by_extension(file_list, filter_list, extension); + free(extension); + } + ug_debug("error is [%d]%s %d\n", error_code, __func__, __LINE__); + return error_code; + } + } + ug_debug("error is [%d]%s %d\n", error_code, __func__, __LINE__); + return error_code; +} + + + +/****************************** +** Prototype : mfUgIsRootPath +** Description : +** Input : None +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +bool mf_ug_fm_svc_wapper_is_root_path(void *data) +{ + GString *g_path = (GString *)data; + ug_mf_retvm_if(g_path == NULL, false, "g_path is NULL"); + + if (!strcmp(g_path->str, PHONE_FOLDER)) { + return true; + } else if (!strcmp(g_path->str, MEMORY_FOLDER)) { + return true; + } else { + return false; + } +} + + +/****************************** +** Prototype : mfUgGetFileName +** Description : +** Input : GString* path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +GString *mf_ug_fm_svc_wapper_get_file_name(GString *path) +{ + GString *ret = NULL; + if (ecore_file_exists(path->str)) { + ret = g_string_new(ecore_file_file_get(path->str)); + } else { + ret = NULL; + } + return ret; +} + +char *mf_ug_fm_svc_wapper_get_root_path_by_tab_label(const char *label) +{ + if (g_strcmp0(label, MF_UG_LABEL_PHONE) == 0) { + return g_strdup(PHONE_FOLDER); + } else if (g_strcmp0(label, MF_UG_LABEL_MMC) == 0) { + return g_strdup(MEMORY_FOLDER); + } else + return NULL; +} + +/****************************** +** Prototype : mf_ug_fm_svc_wapper_get_location +** Description : Samsung +** Input : char* fullpath +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +int mf_ug_fm_svc_wapper_get_location(char *fullpath) +{ + return __mf_ug_fm_svc_wapper_COMESFROM(fullpath); +} + +gint mf_ug_fm_svc_wapper_get_folder_foldersystem(GString *path, bool * result) +{ + + int error_code = 0; + error_code = mf_ug_file_attr_is_system_dir(path->str, result); + return error_code; + +} + +GString *mf_ug_fm_svc_wrapper_get_file_parent_path(GString *fullpath) +{ + GString *ret = NULL; + char *path = NULL; + int error_code = 0; + + if (fullpath == NULL || fullpath->str == NULL) { + return NULL; + } + error_code = mf_ug_file_attr_get_parent_path(fullpath->str, &path); + if (error_code != 0) { + return NULL; + } + + ret = g_string_new(path); + free(path); + path = NULL; + return ret; +} + +char *mf_ug_fm_svc_path_info_retrench(const char *string) +{ + ug_mf_retvm_if(string == NULL, g_strdup(MF_UG_PATH_INFO_TRANS_OMIT), "input path is NULL"); + char *retrench = NULL; + char *utf8_string = elm_entry_utf8_to_markup(string); + if (utf8_string && strlen (string) > MF_UG_PATH_INFO_LEN_THRESHOLD) { + if (g_utf8_strlen(utf8_string, -1) > 2) { + retrench = calloc(1, MF_UG_PATH_INFO_RETRENCH); + if (retrench) { + char *omit = MF_UG_PATH_INFO_TRANS_OMIT; + char *temp = g_utf8_strncpy(retrench, utf8_string, 2); + retrench = g_strconcat(temp, omit, NULL); + UG_SAFE_FREE_CHAR(omit); + UG_SAFE_FREE_CHAR(temp); + } + UG_SAFE_FREE_CHAR(utf8_string); + + } else { + retrench = utf8_string; + } + return retrench; + } else { + return utf8_string; + } +} + +static void __mf_ug_fm_svc_wrapper_path_info_node_free(Eina_List *list) +{ + ug_mf_retm_if(list == NULL, "list is NULL"); + const Eina_List *l = NULL; + void *data = NULL; + EINA_LIST_FOREACH(list, l, data) { + ug_pNode *node = (ug_pNode *)data; + if (node != NULL) { + UG_SAFE_FREE_CHAR(node->original); + UG_SAFE_FREE_CHAR(node->transfer); + UG_SAFE_FREE_CHAR(node); + } + } + eina_list_free(list); +} + + +char *mf_ug_fm_svc_path_info_translate(char *path_info, int path_info_max_len) +{ + + ug_mf_retvm_if(path_info == NULL, g_strdup(dgettext("sys_string", "IDS_COM_BODY_UNKNOWN")), "input path is NULL"); + + int top = 0; + bool flag = TRUE; + Eina_List *temp_list = NULL; + const Eina_List *l = NULL; + gchar **result = NULL; + gchar **params = NULL; + int count = 0; + int max_len = 0; + int total_len = 0; + int i = 0; + char *output = NULL; + void *pnode = NULL; + char *omit = MF_UG_PATH_INFO_TRANS_OMIT; + + if (strlen(path_info) < path_info_max_len) { + UG_SAFE_FREE_CHAR(omit); + return path_info; + } + + result = g_strsplit(path_info, "/", 0); + if (result == NULL) { + free(path_info); + path_info = NULL; + UG_SAFE_FREE_CHAR(omit); + return g_strdup(dgettext("sys_string", "IDS_COM_BODY_UNKNOWN")); + } + + params = result; + count = g_strv_length(result); + + if (count > MF_UG_PATH_INFO_LEVEL_BOUNDARY) + { + top = MF_UG_PATH_INFO_LEVEL_BOUNDARY; + flag = FALSE; + max_len = path_info_max_len - MF_UG_PATH_INFO_LEVEL_BOUNDARY - MF_UG_PATH_INFO_HEAD_LEN(omit);//(2 is length of ..) ../aa../bb../*** + } + else + { + top = count; + flag = TRUE; + max_len = path_info_max_len - (count-1); + } + + for(i = top; i > 1; i--) + { + ug_pNode *nodeB = calloc(sizeof(ug_pNode), 1); + nodeB->original = elm_entry_utf8_to_markup(params[count -i]); + nodeB->len_orig = strlen(params[count - i]); + nodeB->transfer = mf_ug_fm_svc_path_info_retrench(params[count-i]); + nodeB->len_trans = strlen(nodeB->transfer); + nodeB->flag_trans = FALSE; + total_len += nodeB->len_orig; + + temp_list = eina_list_append(temp_list, nodeB); + } + + total_len += strlen(params[count - 1]); + + for (i = 0 ; i < eina_list_count(temp_list); i++) + { + if (total_len > max_len) + { + ug_pNode *data = NULL; + data = eina_list_nth(temp_list, i); + total_len -= (data->len_orig - data->len_trans); + data->flag_trans = TRUE; + } + + if (total_len <= max_len) + break; + } + + + if (flag == FALSE) + { + output = elm_entry_utf8_to_markup(".."); + } + char *temp = NULL; + char *sep = MF_UG_PATH_INFO_SEP; + EINA_LIST_FOREACH(temp_list, l, pnode) + { + ug_pNode *node = (ug_pNode *)pnode; + temp = output; + if(node->flag_trans == TRUE) + { + if (output != NULL) + output = g_strconcat(output, sep, node->transfer, NULL); + else + output = g_strdup(node->transfer); + } + else + { + if (output != NULL) + output = g_strconcat(output, sep ,node->original, NULL); + else + output = g_strdup(node->original); + } + UG_SAFE_FREE_CHAR(temp); + } + temp = output; + char *last_string = params[count - 1]; + char *utf8_last = elm_entry_utf8_to_markup(last_string); + + if (output != NULL) { + int last_len = strlen(last_string); + int output_len = strlen(output); + int d_value = path_info_max_len - output_len; + if ((last_len + output_len) > path_info_max_len) { + const char *end = NULL; + gboolean ret = FALSE; + ret = g_utf8_validate(utf8_last, d_value, &end); + if (ret == TRUE) { + d_value = last_len - strlen(end); + utf8_last[d_value] = '\0'; + output = g_strconcat(output, sep, utf8_last, omit, NULL); + UG_SAFE_FREE_CHAR(temp); + } + } else { + output = g_strconcat(output, sep, utf8_last, NULL); + UG_SAFE_FREE_CHAR(temp); + } + } + else { + output = g_strdup(utf8_last); + UG_SAFE_FREE_CHAR(temp); + } + UG_SAFE_FREE_CHAR(utf8_last); + UG_SAFE_FREE_CHAR(sep); + UG_SAFE_FREE_CHAR(omit); + UG_SAFE_FREE_CHAR(path_info); + __mf_ug_fm_svc_wrapper_path_info_node_free(temp_list); + temp_list = NULL; + g_strfreev(result); + result = NULL; + return output; +} + + +char *mf_ug_fm_svc_wrapper_translate_path(char *original_path) +{ + ug_mf_retvm_if(original_path == NULL, g_strdup(dgettext("sys_string", "IDS_COM_BODY_UNKNOWN")), "input path is NULL"); + + char *new_path = NULL; + int root_len = 0; + + if (mf_ug_fm_svc_wapper_get_location(original_path) == MF_UG_PHONE) { + root_len = strlen(PHONE_FOLDER); + new_path = g_strconcat(MF_UG_LABEL_PHONE, original_path + root_len, "/", NULL); + } else if (mf_ug_fm_svc_wapper_get_location(original_path) == MF_UG_MMC) { + root_len = strlen(MEMORY_FOLDER); + new_path = g_strconcat(MF_UG_LABEL_MMC, original_path + root_len, "/", NULL); + } else { + new_path = g_strdup(original_path); + } + + ug_debug("new path is %s", new_path); + return new_path; +} + +char *mf_ug_fm_svc_wapper_path_info_get(char *original_path) +{ + ug_mf_retvm_if(original_path == NULL, g_strdup(dgettext("sys_string", "IDS_COM_BODY_UNKNOWN")), "input path is NULL"); + char *path_info = NULL; + int len = 0; + + path_info = mf_ug_fm_svc_wrapper_translate_path(original_path); + if (path_info) { + len = strlen(path_info); + if (len > 0 && path_info[len - 1] == '/') { + path_info[len - 1] = '\0'; + } + } + return path_info; + +} + +unsigned long mf_ug_fm_svc_wrapper_get_free_space(int state) +{ + struct statvfs info; + char *path = NULL; + + if (state == MF_UG_PHONE) { + path = PHONE_FOLDER; + } else if (state == MF_UG_MMC) { + path = MEMORY_FOLDER; + } else { + return -1; + } + + if (-1 == statvfs(path, &info)) { + return -2; + } + return (info.f_bsize) * info.f_bfree; +} + +bool mf_ug_fm_svc_wrapper_detect_duplication(GString *to) +{ + int existing = MYFILE_ERR_NONE; + if (to == NULL) { + return false; + } + GString *parent_path = mf_ug_fm_svc_wrapper_get_file_parent_path(to); + GString *file_name = mf_ug_fm_svc_wapper_get_file_name(to); + + ug_debug("full path and file name %s", to->str); + if (file_name == NULL || parent_path == NULL || file_name->len == 0) { + return false; + } + + if (parent_path->str != NULL) { + ug_debug("parent_path->str is %s", parent_path->str); + } + if (file_name->str != NULL) { + ug_debug("file_name->str is %s", file_name->str); + } + + existing = mf_ug_file_attr_is_duplicated_name(parent_path->str, file_name->str); + + ug_debug("EXIST result is %d", existing); + + if (parent_path != NULL) { + g_string_free(parent_path, TRUE); + } + parent_path = NULL; + + if (file_name != NULL) { + g_string_free(file_name, TRUE); + } + file_name = NULL; + + if (existing == MYFILE_ERR_NONE) { + return false; + } else { + return true; + } +} + +static int __mf_ug_fm_svc_wrapper_get_next_number(char *file_name_without_ext, int file_name_type) +{ + int nCount = 0; + int nLength = 0; + int nUnderline = 0; + bool bAllDigits = true; + int i; + + /* check _02d format */ + nLength = strlen(file_name_without_ext); + + if (file_name_type == FILE_NAME_WITH_UNDERLINE) { + if (nLength < 3) { /*4 means the # of minimum characters (*_n) */ + return 1; /*doesn't match */ + } else { /* input is more than 3 bytes */ + /* find '_' */ + for (nUnderline = nLength - 1; nUnderline >= 0; nUnderline--) { + if (file_name_without_ext[nUnderline] == '_') { + break; + } + } + + if (nUnderline == 0 && file_name_without_ext[0] != '_') { + return 1; /* doesn't match */ + } + /* check the right characters are all digits */ + for (i = nUnderline + 1; i < nLength; i++) { + if (file_name_without_ext[i] < '0' || file_name_without_ext[i] > '9') { + bAllDigits = false; + break; + } + } + + if (bAllDigits) { + for (i = nUnderline + 1; i < nLength; i++) { + nCount *= 10; + nCount += file_name_without_ext[i] - '0'; + } + + file_name_without_ext[nUnderline] = '\0'; /* truncate the last '_dd' */ + } + } + } else { + + if (nLength < 5) { /* 5 means the # of minimum characters (*_(n)) */ + return 1; /*doesn't match */ + } else { /* input is more than 3 bytes */ + /* find '_' */ + for (nUnderline = nLength - 1; nUnderline >= 0; nUnderline--) { + if (file_name_without_ext[nUnderline] == '(') { + break; + } + } + + if (nUnderline == 0 && file_name_without_ext[0] != '(') { + return 1; /* doesn't match */ + } + /* check the right characters are all digits */ + for (i = nUnderline + 1; i < nLength - 1; i++) { + if (file_name_without_ext[i] < '0' || file_name_without_ext[i] > '9') { + bAllDigits = false; + break; + } + } + + /* and more than 2 columns. */ + if (bAllDigits) { + for (i = nUnderline + 1; i < nLength - 1; i++) { + nCount *= 10; + nCount += file_name_without_ext[i] - '0'; + } + + file_name_without_ext[nUnderline] = '\0'; /* truncate the last '_dd' */ + } + } + } + + /* increase nCount by 1 */ + nCount++; + + return nCount; +} + +static int __mf_ug_fm_svc_wrapper_get_unique_name(const char *default_dir_full_path, char *original_file_name, char **unique_file_name, + int file_name_type, void *data) +{ + //mf_debug("%s %d\n", __func__, __LINE__); + ug_mf_retvm_if(unique_file_name == NULL, MYFILE_ERR_SRC_ARG_INVALID, "unique_file_name is NULL"); + ug_mf_retvm_if(data == NULL, MYFILE_ERR_SRC_ARG_INVALID, "data is NULL"); + + char *file_name_without_ext = NULL; + char *file_ext = NULL; + char *new_file_name = NULL; + bool result = false; + char *dir_rel_path = NULL; + int slash = 1; + int nCount = 0; + bool bExt = false; + int error_code = 0; + + if (default_dir_full_path == NULL || original_file_name == NULL) { + ug_debug("default_dir_full_path == NULL || \ + original_file_name == NULL || \ + unique_file_name == NULL || \ + error_code == NULL "); + error_code = MYFILE_ERR_SRC_ARG_INVALID; + goto Exception; + } + result = mf_ug_file_attr_get_logical_path_by_full(default_dir_full_path, &dir_rel_path); + + if (result) { + error_code = MYFILE_ERR_GET_LOGIC_PATH_FAIL; + goto Exception; + } + + if (strncmp(dir_rel_path, "/", strlen(dir_rel_path)) == 0) { + slash = 0; + } + error_code = mf_ug_file_attr_is_duplicated_name(default_dir_full_path, original_file_name); + if (error_code == 0) { + ug_debug("unique_file_name [%s]", *unique_file_name); + ug_debug("original_file_name [%s]", new_file_name); + *unique_file_name = g_strdup(original_file_name); + ug_debug("unique_file_name [%s]", *unique_file_name); + } + + while (error_code < 0) { + error_code = 0; + bExt = mf_ug_file_attr_get_file_ext(original_file_name, &file_ext); + file_name_without_ext = g_strdup(original_file_name); + + if (file_name_without_ext == NULL) { + error_code = MYFILE_ERR_ALLOCATE_MEMORY_FAIL; + goto Exception; + } + + /* add a condition, whether extention is or not. */ + if (bExt == 0) { + file_name_without_ext[strlen(file_name_without_ext) - strlen(file_ext) - 1] = '\0'; + } + + nCount = __mf_ug_fm_svc_wrapper_get_next_number(file_name_without_ext, file_name_type); + if (nCount == 1 && file_name_type == FILE_NAME_WITH_BRACKETS) { + char *file_name_with_space = g_strconcat(file_name_without_ext, " ", NULL); + if (file_name_with_space) { + UG_SAFE_FREE_CHAR(file_name_without_ext); + file_name_without_ext = file_name_with_space; + file_name_with_space = NULL; + } + } + + if (bExt == 0) { + if (file_name_type == FILE_NAME_WITH_BRACKETS) + new_file_name = g_strdup_printf("%s(%d).%s", file_name_without_ext, nCount, file_ext); + else + new_file_name = g_strdup_printf("%s_%d.%s", file_name_without_ext, nCount, file_ext); + } else { + + if (file_name_type == FILE_NAME_WITH_BRACKETS) + new_file_name = g_strdup_printf("%s(%d)", file_name_without_ext, nCount); + else + new_file_name = g_strdup_printf("%s_%d", file_name_without_ext, nCount); + } + //mf_debug("new_file_name [%s]", new_file_name); + //mf_debug("original_file_name [%s]", new_file_name); + UG_SAFE_FREE_CHAR(file_name_without_ext); + + ug_debug("new name is %s\n", new_file_name); + + error_code = mf_ug_file_attr_is_duplicated_name(default_dir_full_path, new_file_name); + if (error_code == 0) { + *unique_file_name = g_strdup(new_file_name); + //mf_debug("rename finished\n"); + error_code = MYFILE_ERR_NONE; + goto Exception; + } else { + //mf_debug("rename continue\n"); + original_file_name = g_strdup(new_file_name); + UG_SAFE_FREE_CHAR(new_file_name); + } + UG_SAFE_FREE_CHAR(file_ext); + } + + return MYFILE_ERR_NONE; + +Exception: + UG_SAFE_FREE_CHAR(dir_rel_path); + UG_SAFE_FREE_CHAR(file_ext); + UG_SAFE_FREE_CHAR(new_file_name); + return error_code; +} + +int mf_ug_fm_svc_wrapper_file_auto_rename(void *data, GString *fullpath, int file_name_type, GString **filename) +{ + ug_mf_retvm_if(data == NULL, MYFILE_ERR_SRC_ARG_INVALID, "data is NULL"); + ugData *ugd = (ugData *)data; + + GString *parent_path = mf_ug_fm_svc_wrapper_get_file_parent_path(fullpath); + GString *file_name = mf_ug_fm_svc_wapper_get_file_name(fullpath); + + if (parent_path == NULL || file_name == NULL) { + return MYFILE_ERR_GENERATE_NAME_FAIL; + } + if (parent_path->str == NULL || file_name->str == NULL) { + g_string_free(parent_path, TRUE); + parent_path = NULL; + g_string_free(file_name, TRUE); + file_name = NULL; + return MYFILE_ERR_GENERATE_NAME_FAIL; + } + + char *name = NULL; + int error_code = 0; + + if (parent_path->str != NULL) { + //mf_debug("parent_full_path is [%s]", parent_path->str); + } + + if (file_name->str != NULL) { + //mf_debug("original_file_name is [%s]", file_name->str); + } + error_code = __mf_ug_fm_svc_wrapper_get_unique_name(parent_path->str, file_name->str, &name, file_name_type, ugd); + if (error_code) { + UG_SAFE_FREE_CHAR(name); + return MYFILE_ERR_GENERATE_NAME_FAIL; + } + g_string_append_printf(parent_path, "/%s", name); + ug_debug("After gstring append, PATH ::: [%s]", parent_path->str); + + if (file_name != NULL) { + g_string_free(file_name, TRUE); + } + + file_name = NULL; + if (name != NULL) { + free(name); + name = NULL; + } + + *filename = parent_path; + return MYFILE_ERR_NONE; +} + +int mf_ug_fm_svc_wrapper_create_service(void *data, GString *fullpath) +{ + int error_code; + + mf_ug_util_remove_dir_watch(); + error_code = mf_ug_fs_oper_create_dir(fullpath->str); + + if (error_code != 0) { + ug_debug("Make DIR error\n"); + } + + return error_code; +} + +int mf_ug_fm_svc_wrapper_create_p(const char *fullpath) +{ + UG_TRACE_BEGIN; + + ug_debug("path is [%s]", fullpath); + int error_code = MYFILE_ERR_NONE; + + char *parent = NULL; + error_code = mf_ug_file_attr_get_parent_path(fullpath, &parent); + + goto_if(error_code != MYFILE_ERR_NONE, EXIT); + + if (ecore_file_exists(parent) == false) { + error_code = mf_ug_fm_svc_wrapper_create_p(parent); + goto_if(error_code != MYFILE_ERR_NONE, EXIT); + + } + + ug_debug("create [%s]", fullpath); + error_code = mf_ug_fs_oper_create_dir(fullpath); + goto_if(error_code != MYFILE_ERR_NONE, EXIT); + +EXIT: + return error_code; +} diff --git a/src/common/mf-ug-inotify-handle.c b/src/common/mf-ug-inotify-handle.c new file mode 100644 index 0000000..53734db --- /dev/null +++ b/src/common/mf-ug-inotify-handle.c @@ -0,0 +1,349 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include <glib.h> +#include <sys/inotify.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <stdint.h> +#include <fcntl.h> +#include <errno.h> +#include <pthread.h> + +#include "mf-ug-dlog.h" +#include "mf-ug-inotify-handle.h" + +#define MF_WATCH_FLAGS \ + IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF | IN_MOVED_FROM | IN_MOVED_TO | IN_CLOSE_WRITE + +#define MF_EVENT_SIZE (sizeof(struct inotify_event)) +/** reasonable guess as to size of 1024 events */ +#define MF_EVENT_BUF_LEN (1024 * (MF_EVENT_SIZE + 16)) +#define MF_U32_MAX 0xFFFFFFFF +typedef struct _mf_inotify_t { + int fd; + int wd; + gchar *path; + unsigned int prev_event; + pthread_t monitor; + mf_ug_inotify_cb callback; + void *u_data; +} mf_inotify_t; + +static pthread_mutex_t mf_noti_lock; +static mf_inotify_t *g_handle; + +static void __mf_ug_inotify_handle_free_handle(void) +{ + pthread_mutex_destroy(&mf_noti_lock); + + if (g_handle) { + if (g_handle->fd >= 0) { + close(g_handle->fd); + g_handle->fd = -1; + } + if (g_handle->path) { + g_free(g_handle->path); + g_handle->path = NULL; + } + g_free(g_handle); + g_handle = NULL; + } + + return; +} + +static mf_inotify_t *__mf_ug_inotify_handle_init_handle(void) +{ + __mf_ug_inotify_handle_free_handle(); + g_handle = g_new0(mf_inotify_t, 1); + + if (g_handle) { + g_handle->fd = -1; + pthread_mutex_init(&mf_noti_lock, NULL); + pthread_mutex_lock(&mf_noti_lock); + g_handle->wd = -1; + pthread_mutex_unlock(&mf_noti_lock); + } + + return g_handle; +} + +static void __mf_ug_inotify_handle_clean_up_thread(void *data) +{ + pthread_mutex_t *lock = (pthread_mutex_t *) data; + ug_mf_debug("Thread cancel Clean_up function"); + if (lock) { + pthread_mutex_unlock(lock); + } + return; +} + + +static gpointer __mf_ug_inotify_handle_watch_thread(gpointer user_data) +{ + mf_inotify_t *handle = (mf_inotify_t *) user_data; + int oldtype = 0; + + ug_mf_retvm_if(handle == NULL, NULL, "handle is NULL"); + ug_mf_debug("Create __mf_ug_inotify_handle_watch_thread!!! "); + + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); + + while (1) { + ssize_t len = 0; + uint32_t i = 0; + char event_buff[MF_EVENT_BUF_LEN] = { 0, }; + + if (handle->fd < 0) { + ug_mf_error("fd is not a vaild one"); + pthread_exit(NULL); + } + + len = read(handle->fd, event_buff, sizeof(event_buff) - 1); + if (len <= 0 || len > sizeof(event_buff) - 1) { + ug_mf_error("Fail to read() -fd : %d, len : %d", handle->fd, len); + continue; + } + + while (i < len) { + struct inotify_event *pevent = (struct inotify_event *)&event_buff[i]; + mf_ug_inotify_event s_event = UG_MF_INOTI_NONE; + ug_mf_error("mask=%x dir=%s len=%d name=%s", + pevent->mask, (pevent->mask & IN_ISDIR) ? "yes" : "no", pevent->len, (pevent->len) ? pevent->name : NULL); + + if (pevent->len && strncmp(pevent->name, ".", 1) == 0) { + s_event = UG_MF_INOTI_NONE; + } else if (pevent->mask & IN_ISDIR) { + if (pevent->mask & IN_DELETE_SELF) + s_event = UG_MF_INOTI_DELETE_SELF; + + if (pevent->mask & IN_MOVE_SELF) + s_event = UG_MF_INOTI_MOVE_SELF; + + if (pevent->mask & IN_CREATE) + s_event = UG_MF_INOTI_CREATE; + + if (pevent->mask & IN_DELETE) + s_event = UG_MF_INOTI_DELETE; + + if (pevent->mask & IN_MOVED_FROM) + s_event = UG_MF_INOTI_MOVE_OUT; + + if (pevent->mask & IN_MOVED_TO) + s_event = UG_MF_INOTI_MOVE_IN; + } else { + if (pevent->mask & IN_CREATE) { + s_event = UG_MF_INOTI_NONE; + handle->prev_event = IN_CREATE; + } + + if (pevent->mask & IN_CLOSE_WRITE) { + if (handle->prev_event == IN_CREATE) { + s_event = UG_MF_INOTI_CREATE; + } else { + s_event = UG_MF_INOTI_MODIFY; + } + handle->prev_event = 0; + } + + if (pevent->mask & IN_DELETE) + s_event = UG_MF_INOTI_DELETE; + + if (pevent->mask & IN_MOVED_FROM) + s_event = UG_MF_INOTI_MOVE_OUT; + + if (pevent->mask & IN_MOVED_TO) + s_event = UG_MF_INOTI_MOVE_IN; + } + + ug_mf_debug("s_event : %d, prev_event: %x, callback : %p", s_event, handle->prev_event, handle->callback); + if (s_event != UG_MF_INOTI_NONE) { + pthread_cleanup_push(__mf_ug_inotify_handle_clean_up_thread, (void *)&mf_noti_lock); + pthread_mutex_lock(&mf_noti_lock); + if (handle->callback) { + handle->callback(s_event, (pevent->len) ? pevent->name : NULL, handle->u_data); + } + pthread_mutex_unlock(&mf_noti_lock); + pthread_cleanup_pop(0); + } + + if ((MF_U32_MAX - pevent->len) >= MF_EVENT_SIZE) { + i += sizeof(struct inotify_event) + pevent->len; + } else { + break; + } + } + } + + ug_mf_debug("end __mf_ug_inotify_handle_watch_thread!!! "); + + return NULL; +} + +int mf_ug_inotify_handle_init_inotify(void) +{ + mf_inotify_t *handle = NULL; + handle = __mf_ug_inotify_handle_init_handle(); + ug_mf_retvm_if(handle == NULL, -1, "fail to __mf_ug_inotify_handle_init_handle()"); + + handle->fd = inotify_init(); + + if (handle->fd < 0) { + switch (errno) { + case EMFILE: + ug_mf_error("The user limit on the total number of inotify instances has been reached.\n"); + break; + case ENFILE: + ug_mf_error("The system limit on the total number of file descriptors has been reached.\n"); + break; + case ENOMEM: + ug_mf_error("Insufficient kernel memory is available.\n"); + break; + default: + ug_mf_error("Fail to inotify_init(), Unknown error.\n"); + break; + } + return -1; + } + pthread_create(&handle->monitor, NULL, __mf_ug_inotify_handle_watch_thread, handle); + return 0; +} + +int mf_ug_inotify_handle_add_inotify_watch(const char *path, mf_ug_inotify_cb callback, void *user_data) +{ + mf_inotify_t *handle = NULL; + handle = g_handle; + ug_mf_retvm_if(handle == NULL, -1, "handle is NULL"); + + if (handle->wd >= 0) { + ug_mf_warnig("The mf_notify module supports single instance, the watch descript [%d] is removed automatically\n", handle->wd); + mf_ug_inotify_handle_rm_inotify_watch(); + } + + pthread_mutex_lock(&mf_noti_lock); + handle->wd = inotify_add_watch(handle->fd, path, MF_WATCH_FLAGS); + + if (handle->wd < 0) { + switch (errno) { + case EACCES: + ug_mf_error("Read access to the given file is not permitted.\n"); + break; + case EBADF: + ug_mf_error("The given file descriptor is not valid.\n"); + handle->fd = -1; + break; + case EFAULT: + ug_mf_error("pathname points outside of the process's accessible address space.\n"); + break; + case EINVAL: + ug_mf_error("The given event mask contains no legal events; or fd is not an inotify file descriptor.\n"); + break; + case ENOMEM: + ug_mf_error("Insufficient kernel memory is available.\n"); + break; + case ENOSPC: + ug_mf_error("User limit on the total num of inotify watch was reached or the kernel failed to alloc a needed resource.\n"); + break; + default: + ug_mf_error("Fail to ug_ug_mf_inotify_add_watch(), Unknown error.\n"); + break; + } + pthread_mutex_unlock(&mf_noti_lock); + return -1; + } + + ug_mf_debug("start watching [%s] directory", path); + if (handle->path) { + g_free(handle->path); + handle->path = NULL; + } + handle->path = g_strdup(path); + handle->callback = callback; + handle->u_data = user_data; + pthread_mutex_unlock(&mf_noti_lock); + + return 0; +} + + + +int mf_ug_inotify_handle_rm_inotify_watch(void) +{ + int ret = -1; + mf_inotify_t *handle = NULL; + + handle = g_handle; + ug_mf_retvm_if(handle == NULL, -1, "handle is NULL"); + + if (handle->fd < 0 || handle->wd < 0) { + ug_mf_warnig("inotify is not initialized or has no watching dir - fd [%d] wd [%d]", handle->fd, handle->wd); + return 0; + } + + pthread_mutex_lock(&mf_noti_lock); + + ret = inotify_rm_watch(handle->fd, handle->wd); + if (ret < 0) { + switch (errno) { + case EBADF: + ug_mf_error("fd is not a valid file descriptor\n"); + handle->fd = -1; + break; + case EINVAL: + ug_mf_error("The watch descriptor wd is not valid; or fd is not an inotify file descriptor.\n"); + handle->wd = -1; + break; + default: + ug_mf_error("Fail to mf_ug_inotify_handle_add_inotify_watch(), Unknown error.\n"); + break; + } + pthread_mutex_unlock(&mf_noti_lock); + return -1; + } + ug_mf_debug("stop watching [%s] directory", handle->path); + if (handle->path) { + g_free(handle->path); + handle->path = NULL; + } + handle->callback = NULL; + handle->u_data = NULL; + handle->wd = -1; + pthread_mutex_unlock(&mf_noti_lock); + + return 0; +} + +void mf_ug_inotify_handle_finalize_inotify(void) +{ + mf_inotify_t *handle = NULL; + handle = g_handle; + + ug_mf_retm_if(handle == NULL, "handle is NULL"); + + if (handle->fd >= 0 && handle->wd >= 0) { + mf_ug_inotify_handle_rm_inotify_watch(); + } + + pthread_cancel(handle->monitor); + pthread_join(handle->monitor, NULL); + + __mf_ug_inotify_handle_free_handle(); + + return; +} diff --git a/src/common/mf-ug-list-play.c b/src/common/mf-ug-list-play.c new file mode 100644 index 0000000..74f46c6 --- /dev/null +++ b/src/common/mf-ug-list-play.c @@ -0,0 +1,1785 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include <Elementary.h> +#include <Ecore_X.h> +#include <vconf.h> +#include <stdbool.h> + + +#include "mf-ug-main.h" +#include "../../data/ug_edc_common.h" +#include "mf-ug-conf.h" +#include "mf-ug-cb.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-util.h" +#include "mf-ug-winset.h" +#include "mf-ug-dlog.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-resource.h" +#include "mf-ug-list-play.h" +static mf_player_cbs *g_player_cbs = NULL; +static Ecore_Pipe *g_player_pipe = NULL; + +static void __mf_ug_list_play_control_cb(void *data); +static bool __mf_ug_list_play_play_current_file(void *data); + + +/****************************** +** Prototype : __mf_ug_list_play_init_data +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_list_play_init_data(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + if (ugd->ug_ListPlay.ug_Player != 0) { + mf_ug_list_play_destory_playing_file(ugd); + ugd->ug_ListPlay.ug_Player = 0; + } + ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_INIT; + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + UG_TRACE_END; +} + +/****************************** +** Prototype : __mf_ug_list_play_drm_has_valid_ro +** Description : Samsung +** Input : char *path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_drm_has_valid_ro(char *path) +{ + UG_TRACE_BEGIN; + drm_result_e res = DRM_RETURN_INVALID_ARG; + drm_license_status_e licence_status; + + if (path) { + res = drm_get_license_status(path, DRM_PERMISSION_TYPE_PLAY, &licence_status); + } + + if (res == DRM_RETURN_SUCCESS && licence_status == DRM_LICENSE_STATUS_VALID) { + return true; + } else { + return false; + } +} + + +/****************************** +** Prototype : __mf_ug_list_play_check_drm_left_ro +** Description : Samsung +** Input : void *data +** char *path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_check_drm_left_ro(void *data, char *path) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + + char left_ro_message[MAX_MESSAGE_LEN] = "\0"; + + bool ro_valid = false; + bool expired = false; + + + const char *title = ecore_file_file_get(path); + ugd->ug_ListPlay.ug_bDrmContentCanPlay = false; + + if (__mf_ug_list_play_drm_has_valid_ro(path)) + { + drm_constraint_info_s constraint; + memset(&constraint, 0x0, sizeof(drm_constraint_info_s)); + + int res = drm_get_constraint_info(path, DRM_PERMISSION_TYPE_PLAY, &constraint); + if (res == DRM_RETURN_SUCCESS) { + if (constraint.const_type.is_unlimited) { + ug_debug("UNLIMITED"); + ugd->ug_ListPlay.ug_bDrmContentCanPlay = TRUE; + return TRUE; + } + + if (constraint.const_type.is_count) { + int remain_count = constraint.remaining_count; + + if (remain_count == 1) { + snprintf(left_ro_message, sizeof(left_ro_message), "You can play \"%s\" just one more time", title); + ro_valid = true; + ugd->ug_ListPlay.ug_bDrmContentCanPlay = true; + } else if (remain_count == 0) { + snprintf(left_ro_message, sizeof(left_ro_message), "You can't play \"%s\" anymore", title); + ro_valid = false; + } else { + ro_valid = true; + ugd->ug_ListPlay.ug_bDrmContentCanPlay = true; + } + } + + if (constraint.const_type.is_datetime) { + ug_debug("DRM_DATETIME\n"); + snprintf(ugd->ug_ListPlay.ug_DrmInfo.validity, sizeof(ugd->ug_ListPlay.ug_DrmInfo.validity), + "%d.%d.%d %d:%d~%d.%d.%d %d:%d", + constraint.start_time.tm_mday, + constraint.start_time.tm_mon + 1, + constraint.start_time.tm_year + 109, + constraint.start_time.tm_hour, + constraint.start_time.tm_min, + constraint.end_time.tm_mday, + constraint.end_time.tm_mon + 1, + constraint.end_time.tm_year + 109, + constraint.end_time.tm_hour, + constraint.end_time.tm_min); + } + + if (constraint.const_type.is_interval) { + ug_debug("DRM_INTERVAL\n"); + snprintf(ugd->ug_ListPlay.ug_DrmInfo.validity, sizeof(ugd->ug_ListPlay.ug_DrmInfo.validity), + "until %d.%d.%d %d:%d", + constraint.interval_time.tm_mon, + constraint.interval_time.tm_mday, + constraint.interval_time.tm_year, + constraint.interval_time.tm_hour, + constraint.interval_time.tm_min); + } + + if (constraint.const_type.is_timedcount) { + int count = constraint.timed_remaining_count; + int time = constraint.timed_count_timer; + snprintf(ugd->ug_ListPlay.ug_DrmInfo.validity, sizeof(ugd->ug_ListPlay.ug_DrmInfo.validity), + "%d left (%d sec)", count, time); + ug_debug("DRM_TIMED_COUNT [%d]\n", count); + if (count == 1) + { + snprintf(left_ro_message, sizeof(left_ro_message), + "You can play \"%s\" just one more time", title); + ugd->ug_ListPlay.ug_bDrmContentCanPlay = TRUE; + } + else if (count == 0) + { + snprintf(left_ro_message, sizeof(left_ro_message), + "You can't play \"%s\" anymore", title); + } + } + + if (constraint.const_type.is_accumulated) { + int sec = constraint.accumulated_remaining_seconds; + int ndays = sec / ACCUMULATED_DATE; + ug_debug("DRM_ACCUMULATED [%d]\n", ndays); + snprintf(ugd->ug_ListPlay.ug_DrmInfo.validity, sizeof(ugd->ug_ListPlay.ug_DrmInfo.validity), + "%" UG_TIME_FORMAT " left", UG_TIME_ARGS(ndays)); + + if (ndays < ACCUMULATED_DATE) + { + snprintf(left_ro_message, sizeof(left_ro_message), + "You can play %s just one day", title); + + ugd->ug_ListPlay.ug_bDrmContentCanPlay = TRUE; + } + } + + if (constraint.const_type.is_individual) { + ug_debug("DRM_INDIVISUAL_ID [%s]", constraint.individual_id); + } + + if (constraint.const_type.is_system) { + ug_debug("DRM_SYSTEM [ID:%s, type:%d]", constraint.system_id, constraint.system_identity_type); + } + } + } else { + ug_debug("have no valid ro\n"); + snprintf(left_ro_message, sizeof(left_ro_message), "No valid RO for <br>\"%s\"", title); + ro_valid = false; + expired = true; + } + + + UG_TRACE_END; + + return true; +} + +/****************************** +** Prototype : __mf_ug_list_play_check_drm_forward +** Description : Samsung +** Input : void *data +** char *path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static drm_file_type_e __drm_get_file_type(void *path) +{ + drm_file_type_e type = DRM_TYPE_UNDEFINED; + drm_result_e res = -1; + + res = drm_get_file_type(path, &type); + if (res == DRM_RETURN_SUCCESS) { + return type; + } else { + return DRM_TYPE_UNDEFINED; + } +} +static bool __mf_ug_list_play_check_drm_forward(void *data, char *path) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + drm_file_type_e type = __drm_get_file_type(path); + + if (type == DRM_TYPE_OMA_V1 || type == DRM_TYPE_OMA_V2) { + + drm_file_info_s info; + memset(&info, 0x0, sizeof(drm_file_info_s)); + int ret = drm_get_file_info(path, &info); + if (ret == DRM_RETURN_SUCCESS) { + if (info.oma_info.method == DRM_METHOD_TYPE_FORWARD_LOCK) { + ugd->ug_ListPlay.ug_DrmInfo.forward = true; + return TRUE; + } + } + ugd->ug_ListPlay.ug_DrmInfo.forward = false; + return false; + } else if (type == DRM_TYPE_PLAYREADY) { + ug_debug("playready drm file"); + ugd->ug_ListPlay.ug_DrmInfo.forward = true; + } else { + ug_debug("Not supported drm type"); + UG_TRACE_END; + return false; + } + UG_TRACE_END; + return true; +} + +/****************************** +** Prototype : mf_ug_list_play_update_item_icon +** Description : +** Input : ugListItemData *data +** int state +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_list_play_icon_hide(ugListItemData *itemData) +{ + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + ug_mf_retm_if(itemData->ug_pItem == NULL, "itemData->ug_pItem is NULL"); + + Evas_Object *btn = elm_object_item_part_content_unset(itemData->ug_pItem, "elm.icon.3"); + evas_object_hide(btn); + UG_SAFE_FREE_OBJ(btn); + itemData->ug_pPlaybtn = NULL; + +} +void mf_ug_list_disable_play_itc(void *data, bool disable) +{ + UG_TRACE_BEGIN; + + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Elm_Object_Item *gl_item = NULL; + ugListItemData *itemData = NULL; + Evas_Object *pGenlist = NULL; + + if (ugd->ug_ListPlay.ug_pPlayFilePath == NULL || strlen(ugd->ug_ListPlay.ug_pPlayFilePath) == 0) { + + UG_TRACE_END; + return; + } + pGenlist = ugd->ug_MainWindow.ug_pNaviGenlist; + + gl_item = elm_genlist_first_item_get(pGenlist); + while (gl_item) { + itemData = elm_object_item_data_get(gl_item); + if (itemData && itemData->ug_pItemName) { + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, itemData->ug_pItemName->str) == 0) { + if (disable) { + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + elm_genlist_item_fields_update(itemData->ug_pItem, "elm.icon.3", ELM_GENLIST_ITEM_FIELD_CONTENT); + //elm_genlist_item_item_class_update(itemData->ug_pItem, &ugd->ug_Status.ug_noplayitc); + } else { + elm_genlist_item_fields_update(itemData->ug_pItem, "elm.icon.3", ELM_GENLIST_ITEM_FIELD_CONTENT); + } + UG_TRACE_END; + return; + } + } + gl_item = elm_genlist_item_next_get(gl_item); + } + + ug_debug("mf_ug_list_play_update_item_icon failed"); + UG_TRACE_END; +} + + +void mf_ug_list_paly_hide_play_icon(void *data) +{ + UG_TRACE_BEGIN; + + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Elm_Object_Item *gl_item = NULL; + ugListItemData *itemData = NULL; + Evas_Object *pGenlist = NULL; + + if (ugd->ug_ListPlay.ug_pPlayFilePath == NULL || strlen(ugd->ug_ListPlay.ug_pPlayFilePath) == 0) { + + UG_TRACE_END; + return; + } + pGenlist = ugd->ug_MainWindow.ug_pNaviGenlist; + + gl_item = elm_genlist_first_item_get(pGenlist); + while (gl_item) { + itemData = elm_object_item_data_get(gl_item); + if (itemData && itemData->ug_pItemName) { + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, itemData->ug_pItemName->str) == 0) { + __mf_ug_list_play_icon_hide(itemData); + UG_TRACE_END; + return; + } + } + gl_item = elm_genlist_item_next_get(gl_item); + } + + ug_debug("mf_ug_list_play_update_item_icon failed"); + UG_TRACE_END; +} +void mf_ug_list_play_update_play_icon(ugListItemData *itemData) +{ + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + ugData *ugd = (ugData *)itemData->ug_pData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + Evas_Object *btn = itemData->ug_pPlaybtn; + Evas_Object *music_icon = elm_object_part_content_get(btn, "icon"); + const char *play_icon = NULL; + const char *pause_icon = NULL; + if (ugd->ug_ListPlay.ug_pPlayFilePath) { + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, itemData->ug_pItemName->str) == 0) { + if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PLAYING) { + pause_icon = strdup(UG_ICON_MUSIC_PAUSE_WHITE); + elm_image_file_set(music_icon, pause_icon, NULL); + } else if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PAUSED) { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } else { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } + } else { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } + } else { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } + +} + +void mf_ug_list_play_update_item_icon(void *data) +{ + UG_TRACE_BEGIN; + + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Elm_Object_Item *gl_item = NULL; + ugListItemData *itemData = NULL; + Evas_Object *pGenlist = NULL; + + if (ugd->ug_ListPlay.ug_pPlayFilePath == NULL || strlen(ugd->ug_ListPlay.ug_pPlayFilePath) == 0) { + + UG_TRACE_END; + return; + } + pGenlist = ugd->ug_MainWindow.ug_pNaviGenlist; + + gl_item = elm_genlist_first_item_get(pGenlist); + while (gl_item) { + itemData = elm_object_item_data_get(gl_item); + if (itemData && itemData->ug_pItemName) { + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, itemData->ug_pItemName->str) == 0) { + elm_genlist_item_fields_update(itemData->ug_pItem, "elm.icon.3", ELM_GENLIST_ITEM_FIELD_CONTENT); + //mf_ug_list_play_update_play_icon(itemData); + UG_TRACE_END; + return; + } + } + gl_item = elm_genlist_item_next_get(gl_item); + } + + ug_debug("mf_ug_list_play_update_item_icon failed"); + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_list_play_set_play_start_status +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_list_play_set_play_start_status(void *data, char *path) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_PLAYING; + UG_TRACE_END; +} + +/****************************** +** Prototype : __mf_ug_list_play_set_play_resume_status +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_list_play_set_play_resume_status(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_PLAYING; + UG_TRACE_END; +} + +/****************************** +** Prototype : __mf_ug_list_play_set_play_pause_status +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_list_play_set_play_pause_status(ugData *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_PAUSED; + UG_TRACE_END; +} + +/****************************** +** Prototype : _mp_player_mgr_create +** Description : +** Input : void *data +** const gchar *path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_player_mgr_callback_pipe_handler(void *data, void *buffer, unsigned int nbyte) +{ + UG_TRACE_BEGIN; + mf_player_cb_extra_data *extra_data = buffer; + ug_mf_retm_if(extra_data == NULL, "NULL"); + ug_mf_retm_if(g_player_cbs == NULL, "NULL"); + + switch (extra_data->cb_type) { + /*note: start callback and paused callback for player have been removed*/ + /*case MF_PLAYER_CB_TYPE_STARTED: + if (g_player_cbs->started_cb) + g_player_cbs->started_cb(g_player_cbs->user_data[MF_PLAYER_CB_TYPE_STARTED]); + break; + + case MF_PLAYER_CB_TYPE_PAUSED: + if (g_player_cbs->paused_cb) + g_player_cbs->paused_cb(g_player_cbs->user_data[MF_PLAYER_CB_TYPE_PAUSED]); + break;*/ + + case MF_PLAYER_CB_TYPE_COMPLETED: + if (g_player_cbs->completed_cb) + g_player_cbs->completed_cb(g_player_cbs->user_data[MF_PLAYER_CB_TYPE_COMPLETED]); + break; + + case MF_PLAYER_CB_TYPE_INTURRUPTED: + if (g_player_cbs->interrupted_cb) + g_player_cbs->interrupted_cb(extra_data->param.interrupted_code, g_player_cbs->user_data[MF_PLAYER_CB_TYPE_INTURRUPTED]); + break; + + case MF_PLAYER_CB_TYPE_ERROR: + if (g_player_cbs->error_cb) + g_player_cbs->error_cb(extra_data->param.error_code, g_player_cbs->user_data[MF_PLAYER_CB_TYPE_ERROR]); + break; + + case MF_PLAYER_CB_TYPE_BUFFERING: + if (g_player_cbs->buffering_cb) + g_player_cbs->buffering_cb(extra_data->param.percent ,g_player_cbs->user_data[MF_PLAYER_CB_TYPE_BUFFERING]); + break; + case MF_PLAYER_CB_TYPE_PREPARE: + if (g_player_cbs->prepare_cb) + g_player_cbs->prepare_cb(g_player_cbs->user_data[MF_PLAYER_CB_TYPE_PREPARE]); + break; + + default: + ug_debug("Not suppoted callback type [%d]", extra_data->cb_type); + } +} + + +static void +__mf_ug_list_play_mgr_completed_cb(void *userdata) +{ + UG_TRACE_BEGIN; + MF_CHECK(g_player_pipe); + + mf_player_cb_extra_data extra_data; + extra_data.cb_type = MF_PLAYER_CB_TYPE_COMPLETED; + + ecore_pipe_write(g_player_pipe, &extra_data, sizeof(mf_player_cb_extra_data)); +} + +static void +__mf_ug_list_play_mgr_interrupted_cb(player_interrupted_code_e code, void *userdata) +{ + UG_TRACE_BEGIN; + MF_CHECK(g_player_pipe); + + mf_player_cb_extra_data extra_data; + extra_data.cb_type = MF_PLAYER_CB_TYPE_INTURRUPTED; + extra_data.param.interrupted_code = code; + + ecore_pipe_write(g_player_pipe, &extra_data, sizeof(mf_player_cb_extra_data)); +} + + +static void +__mf_ug_list_play_mgr_error_cb(int error_code, void *userdata) +{ + UG_TRACE_BEGIN; + MF_CHECK(g_player_pipe); + + mf_player_cb_extra_data extra_data; + extra_data.cb_type = MF_PLAYER_CB_TYPE_ERROR; + extra_data.param.error_code = error_code; + + ecore_pipe_write(g_player_pipe, &extra_data, sizeof(mf_player_cb_extra_data)); +} + +static bool __mf_ug_list_play_set_uri(player_h player, const char *uri) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(player == NULL, false, "player is NULL"); + ug_mf_retvm_if(uri == NULL, false, "uri is NULL"); + + int ret = 0; + ret = player_set_uri(player, uri); + //player_set_sound_type(ugd->ug_ListPlay.ug_Player, SOUND_TYPE_MEDIA); + if (ret != PLAYER_ERROR_NONE) { + ug_error(">>>>>>>>>>>>>g_err_name : %d\n", ret); + UG_TRACE_END; + return false; + } else { + UG_TRACE_END; + return true; + } + +} + +static bool __mf_ug_list_play_set_sound_type(player_h player, sound_type_e type) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(player == NULL, false, "player is NULL"); + + int ret = 0; + ret = player_set_sound_type(player, type); + //player_set_sound_type(ugd->ug_ListPlay.ug_Player, SOUND_TYPE_MEDIA); + if (ret != PLAYER_ERROR_NONE) { + ug_error(">>>>>>>>>>>>>g_err_name : %d\n", ret); + UG_TRACE_END; + return false; + } else { + UG_TRACE_END; + return true; + } + +} + +static bool __mf_ug_list_play_create_player(player_h *player) +{ + UG_TRACE_BEGIN; + + int ret = 0; + ret = player_create(player); + //player_set_sound_type(ugd->ug_ListPlay.ug_Player, SOUND_TYPE_MEDIA); + if (ret != PLAYER_ERROR_NONE) { + ug_error(">>>>>>>>>>>>>g_err_name : %d\n", ret); + UG_TRACE_END; + return false; + } else { + UG_TRACE_END; + return true; + } + +} + +static bool __mf_ug_list_play_create_player_mgr(void *data, const char *path) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + int path_len = strlen(path); + char *g_err_name = NULL; + int ret = 0; + + if (path_len > 0 && path_len < MYFILE_DIR_PATH_LEN_MAX) { + if (ugd->ug_ListPlay.ug_Player == 0) { + ret = __mf_ug_list_play_create_player(&ugd->ug_ListPlay.ug_Player); + if (ret == false) { + UG_TRACE_END; + return false; + } + ug_debug("player is [%s]", ugd->ug_ListPlay.ug_Player); + /*avsysaudiosink volume table setting */ + + //ret = mm_player_set_attribute(ugd->ug_ListPlay.ug_Player, &g_err_name, "sound_volume_type", MM_SOUND_VOLUME_TYPE_MEDIA, + // "profile_uri", path, strlen(path), NULL); + ret = __mf_ug_list_play_set_uri(ugd->ug_ListPlay.ug_Player, path); + if (ret == false) { + UG_TRACE_END; + return false; + } + + ret = __mf_ug_list_play_set_sound_type(ugd->ug_ListPlay.ug_Player, SOUND_TYPE_MEDIA); + if (ret == false) { + ug_error("set sound type failed"); + } else { + ug_error("set sound type success"); + } + UG_SAFE_FREE_CHAR(g_player_cbs); + if (g_player_pipe) { + ecore_pipe_del(g_player_pipe); + g_player_pipe = NULL; + } + g_player_cbs = calloc(1, sizeof(mf_player_cbs)); + g_player_pipe = ecore_pipe_add(__mf_player_mgr_callback_pipe_handler, ugd); + + + player_set_completed_cb(ugd->ug_ListPlay.ug_Player, __mf_ug_list_play_mgr_completed_cb, NULL); + player_set_interrupted_cb(ugd->ug_ListPlay.ug_Player, __mf_ug_list_play_mgr_interrupted_cb, NULL); + player_set_error_cb(ugd->ug_ListPlay.ug_Player, __mf_ug_list_play_mgr_error_cb, NULL); + + } else { + ug_debug("player handle is exist"); + + ret = __mf_ug_list_play_set_uri(ugd->ug_ListPlay.ug_Player, path); + if (ret == false) { + UG_TRACE_END; + return false; + } + UG_TRACE_END; + return true; + } + } else { + ug_debug("the path_len is too long"); + UG_TRACE_END; + return false; + } + + //player_set_buffering_cb(ugd->ug_ListPlay.ug_Player, _mp_player_mgr_buffering_cb, NULL); + return true; + +} + +/****************************** +** Prototype : _mp_player_mgr_set_msg_callback +** Description : +** Input : MMMessageCallback cb +** gpointer user_data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_list_play_start(void *data) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + ugData *ugd = itemData->ug_pData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + int error_code = -1; + player_state_e state = PLAYER_STATE_NONE; + + error_code = player_get_state(ugd->ug_ListPlay.ug_Player, &state); + ug_debug("state is [%d]", state); + if (error_code == 0 && state == PLAYER_STATE_PLAYING) { + if (ugd->ug_ListPlay.ug_pPlayFilePath == NULL) { + ugd->ug_ListPlay.ug_pPlayFilePath = g_strdup(itemData->ug_pItemName->str); + } + __mf_ug_list_play_set_play_start_status(ugd, itemData->ug_pItemName->str); + } else if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PAUSED) { + if (ugd->ug_ListPlay.ug_pPlayFilePath == NULL) { + ugd->ug_ListPlay.ug_pPlayFilePath = g_strdup(itemData->ug_pItemName->str); + } + __mf_ug_list_play_set_play_resume_status(ugd); + } + + UG_TRACE_END; +} + +static void __mf_ug_list_play_pauset(void *data) +{ + UG_TRACE_BEGIN; + + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + __mf_ug_list_play_set_play_pause_status(ugd); + UG_TRACE_END; +} + +static void __mf_ug_list_play_complete_cb(void *data) +{ + UG_TRACE_BEGIN; + + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + mf_ug_list_play_destory_playing_file(ugd); + mf_ug_list_disable_play_itc(ugd, true); + //mf_ug_list_play_update_item_icon(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + UG_TRACE_END; +} + +static void __mf_ug_list_play_interrupt_cb(player_interrupted_code_e code, void *data) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + + ugData *ugd = (ugData *)itemData->ug_pData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + switch (code) { + case PLAYER_INTERRUPTED_BY_MEDIA: + ug_debug("Interrupt :: PLAYER_INTERRUPTED_BY_MEDIA"); + break; + case PLAYER_INTERRUPTED_BY_CALL: + ug_debug("Interrupt :: PLAYER_INTERRUPTED_BY_CALL_START"); + break; + case PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT: + ug_debug("Interrupt :: PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT"); + break; + case PLAYER_INTERRUPTED_BY_ALARM: + ug_debug("Interrupt :: PLAYER_INTERRUPTED_BY_ALARM_START"); + break; + case PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG: + ug_debug("Interrupt :: PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG"); + break; + case PLAYER_INTERRUPTED_COMPLETED: + ug_debug("PLAYER_INTERRUPTED_COMPLETED"); + /* ready to resume */ + ug_debug("ugd->ug_ListPlay.ug_iPlayState is [%d]", ugd->ug_ListPlay.ug_iPlayState); + if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PAUSED) { + ug_debug(); + __mf_ug_list_play_control_cb(itemData); + } + return; + default: + break; + } + __mf_ug_list_play_set_play_pause_status(ugd); + mf_ug_list_play_update_item_icon(ugd); + UG_TRACE_END; + +} + +static void +__mf_list_play_control_prepare_cb(void *userdata) +{ + UG_TRACE_BEGIN; + + __mf_ug_list_play_play_current_file(userdata); +} + + +/****************************** +** Prototype : _mp_player_mgr_realize +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void +__mf_ug_list_play_prepare_cb(void *userdata) +{ + UG_TRACE_BEGIN; + MF_CHECK(g_player_pipe); + + mf_player_cb_extra_data extra_data; + memset(&extra_data, 0, sizeof(mf_player_cb_extra_data)); + extra_data.cb_type = MF_PLAYER_CB_TYPE_PREPARE; + + ecore_pipe_write(g_player_pipe, &extra_data, sizeof(mf_player_cb_extra_data)); +} + +static bool __mf_ug_list_play_realize_player_mgr(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + int error_code = 0; + player_state_e state = PLAYER_STATE_NONE; + + if (ugd->ug_ListPlay.ug_Player != 0) { + error_code = player_get_state(ugd->ug_ListPlay.ug_Player, &state); + ug_debug("state is [%d]", state); + + if (0 == error_code && PLAYER_STATE_IDLE == state) { + ug_debug("player_prepare_async"); + if (player_prepare_async(ugd->ug_ListPlay.ug_Player, __mf_ug_list_play_prepare_cb, ugd) != PLAYER_ERROR_NONE) + { + ug_debug("Error when mp_player_mgr_realize\n"); + UG_TRACE_END; + return FALSE; + } else { + return true; + } + //ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_READY; + + } else { + UG_TRACE_END; + return false; + } + } + UG_TRACE_END; + + return false; +} + + +/****************************** +** Prototype : __mf_ug_list_play_ready_new_file_play +** Description : Samsung +** Input : void *data +** bool drm_check_flag +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +/*void mf_player_mgr_set_started_cb(player_started_cb callback, void *user_data) +{ + MF_CHECK(g_player_cbs); + + g_player_cbs->started_cb = callback; + g_player_cbs->user_data[MF_PLAYER_CB_TYPE_STARTED] = user_data; +} + +void mf_player_mgr_set_paused_cb(player_paused_cb callback, void *user_data) +{ + MF_CHECK(g_player_cbs); + + g_player_cbs->paused_cb = callback; + g_player_cbs->user_data[MF_PLAYER_CB_TYPE_PAUSED] = user_data; +}*/ + +void mf_player_mgr_set_completed_cb(player_completed_cb callback, void *user_data) +{ + + MF_CHECK(g_player_cbs); + + g_player_cbs->completed_cb = callback; + g_player_cbs->user_data[MF_PLAYER_CB_TYPE_COMPLETED] = user_data; +} + +void mf_player_mgr_set_interrupted_cb(player_interrupted_cb callback, void *user_data) +{ + + MF_CHECK(g_player_cbs); + + g_player_cbs->interrupted_cb = callback; + g_player_cbs->user_data[MF_PLAYER_CB_TYPE_INTURRUPTED] = user_data; +} + +void mf_player_mgr_set_error_cb(player_error_cb callback, void *user_data) +{ + + MF_CHECK(g_player_cbs); + + g_player_cbs->error_cb = callback; + g_player_cbs->user_data[MF_PLAYER_CB_TYPE_ERROR] = user_data; +} + +void mf_player_mgr_set_buffering_cb(player_buffering_cb callback, void *user_data) +{ + MF_CHECK(g_player_cbs); + + g_player_cbs->buffering_cb = callback; + g_player_cbs->user_data[MF_PLAYER_CB_TYPE_BUFFERING] = user_data; +} + +void mf_player_mgr_set_prepare_cb(player_prepared_cb callback, void *user_data) +{ + MF_CHECK(g_player_cbs); + + g_player_cbs->prepare_cb = callback; + g_player_cbs->user_data[MF_PLAYER_CB_TYPE_PREPARE] = user_data; +} + +static Eina_Bool __mf_play_control_error(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + mf_ug_list_play_destory_playing_file(ugd); + mf_ug_list_disable_play_itc(ugd, true); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + ugd->ug_ListPlay.playing_err_idler = NULL; + return EINA_FALSE; +} + +static void __mf_play_control_error_cb(int error_code, void *userdata) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)userdata; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + switch (error_code) + { + case PLAYER_ERROR_OUT_OF_MEMORY: + ug_error("PLAYER_ERROR_OUT_OF_MEMORY"); + break; + case PLAYER_ERROR_INVALID_PARAMETER: + ug_error("PLAYER_ERROR_INVALID_PARAMETER"); + //mp_widget_text_popup(ad, GET_STR("IDS_MUSIC_POP_UNABLE_TO_PLAY_ERROR_OCCURRED")); + break; + case PLAYER_ERROR_NOT_SUPPORTED_FILE: //can receive error msg while playing. + ug_error("receive MM_ERROR_PLAYER_CODEC_NOT_FOUND\n"); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNSUPPORT_FILE_TYPE, NULL, NULL, NULL, NULL, NULL); + break; + case PLAYER_ERROR_CONNECTION_FAILED: + ug_error("MM_ERROR_PLAYER_STREAMING_CONNECTION_FAIL"); + + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_CONNECT_FAILED, NULL, NULL, NULL, NULL, NULL); + break; + default: + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNSUPPORT_FILE_TYPE, NULL, NULL, NULL, NULL, NULL); + ug_error("error_code: %d", error_code); + } + + if(!ugd->ug_ListPlay.playing_err_idler) { + ugd->ug_ListPlay.playing_err_idler = ecore_idler_add(__mf_play_control_error, ugd); + } +} + + +static bool __mf_ug_list_play_ready_new_file_play(void *data, bool drm_check_flag) +{ + + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ug_mf_retvm_if(itemData == NULL, false, "itemData is NULL"); + + ugData *ugd = (ugData *)itemData->ug_pData; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + char *path = strdup(itemData->ug_pItemName->str); + + /*check if file is exist */ + if (path != NULL) { + if (!ecore_file_exists(path)) { + ug_debug("Error file %s is not exist\n", path); + free(path); + path = NULL; + UG_TRACE_END; + return false; + } + /*/check if file is drm file */ + if (mf_ug_file_attr_is_drm_file(path) == 0) { + if (!__mf_ug_list_play_check_drm_left_ro(ugd, path)) { + free(path); + path = NULL; + UG_TRACE_END; + return false; + } + + if (!__mf_ug_list_play_check_drm_forward(ugd, path)) { + free(path); + path = NULL; + UG_TRACE_END; + return false; + } + + ugd->ug_ListPlay.ug_bDrmconsumption = true; + } else { + ugd->ug_ListPlay.ug_bDrmconsumption = true; + } + + if (!__mf_ug_list_play_create_player_mgr(ugd, path)) { + free(path); + path = NULL; + ug_error("ERROR HERE !!!!!!!"); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNABLE_TO_PLAY_ERROR_OCCURRED, NULL, NULL, NULL, NULL, NULL); + UG_TRACE_END; + return false; + } + + //mf_player_mgr_set_started_cb(__mf_ug_list_play_start_cb, itemData); + //mf_player_mgr_set_paused_cb(__mf_ug_list_play_pauset_cb, ugd); + mf_player_mgr_set_completed_cb(__mf_ug_list_play_complete_cb, ugd); + mf_player_mgr_set_interrupted_cb(__mf_ug_list_play_interrupt_cb, ugd); + mf_player_mgr_set_prepare_cb(__mf_list_play_control_prepare_cb, itemData); + mf_player_mgr_set_error_cb(__mf_play_control_error_cb, ugd); + //mf_player_mgr_set_buffering_cb(_mp_play_control_buffering_cb, ad); + + if (!__mf_ug_list_play_realize_player_mgr(ugd)) { + free(path); + path = NULL; + ug_error("ERROR HERE !!!!!!!"); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNABLE_TO_PLAY_ERROR_OCCURRED, NULL, NULL, NULL, NULL, NULL); + UG_TRACE_END; + return false; + } + free(path); + path = NULL; + UG_TRACE_END; + return true; + } else { + return false; + } + +} + + +/****************************** +** Prototype : _mp_player_mgr_play +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_play(void *data) +{ + + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ug_mf_retvm_if(itemData == NULL, false, "itemData is NULL"); + ugData *ugd = itemData->ug_pData; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + int err = 0; + int error_code = 0; + player_state_e state = PLAYER_STATE_NONE; + + if (ugd->ug_ListPlay.ug_Player != 0) { + error_code = player_get_state(ugd->ug_ListPlay.ug_Player, &state); + ug_debug("state is [%d]", state); + + if (0 == error_code && PLAYER_STATE_READY == state) { + err = player_start(ugd->ug_ListPlay.ug_Player); + if (err != PLAYER_ERROR_NONE) { + + if (err == PLAYER_ERROR_SOUND_POLICY) + { + ug_error("PLAYER_ERROR_SOUND_POLICY error"); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNABLE_TO_PLAY_DURING_CALL, NULL, + NULL, NULL, NULL, NULL); + } + else + { + ug_error("error is [%d]", err); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNABLE_TO_PLAY_ERROR_OCCURRED, NULL, + NULL, NULL, NULL, NULL); + } + ug_error("Error when _mp_player_mgr_play. err[%x]\n", err); + UG_TRACE_END; + return false; + } else { + __mf_ug_list_play_start(itemData); + mf_ug_list_disable_play_itc(ugd, false); + UG_TRACE_END; + return true; + } + } else { + UG_TRACE_END; + return false; + } + } else { + UG_TRACE_END; + return false; + } +} + +/****************************** +** Prototype : __mf_ug_list_play_stop +** Description : +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_stop(ugData *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + player_state_e state = PLAYER_STATE_NONE; + int error_code = 0; + + if (ugd->ug_ListPlay.ug_Player != 0) { + error_code = player_get_state(ugd->ug_ListPlay.ug_Player, &state); + ug_debug("state is [%d]", state); + + if (0 == error_code && (PLAYER_STATE_PLAYING == state || PLAYER_STATE_PAUSED == state)) { + if (player_stop(ugd->ug_ListPlay.ug_Player) != 0) { + ug_debug("Error when __mf_ug_list_play_stop\n"); + UG_TRACE_END; + return false; + } else { + + ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_STOP; + ugd->ug_ListPlay.ug_bDrmContentCanPlay = false; + UG_TRACE_END; + return true; + } + + } else { + UG_TRACE_END; + return false; + } + } + UG_TRACE_END; + return false; +} + +/****************************** +** Prototype : __mf_ug_list_play_unrealize +** Description : +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_unrealize(ugData *data) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + if (ugd->ug_ListPlay.ug_Player != 0) { + /*/unrealize can be invoked at any state */ + int ret = player_unprepare(ugd->ug_ListPlay.ug_Player); + if (ret != 0) { + ug_error("Error when __mf_ug_list_play_unrealize %d", ret); + UG_TRACE_END; + return false; + } else { + UG_TRACE_END; + return true; + } + } + UG_TRACE_END; + return false; +} + +/****************************** +** Prototype : __mf_ug_list_play_destory +** Description : +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_destory(ugData *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + if (ugd->ug_ListPlay.ug_Player != 0) { + /*/destroy can be invoked at any state */ + if (player_destroy(ugd->ug_ListPlay.ug_Player) != 0) { + ug_debug("Error when __mf_ug_list_play_destory\n"); + UG_TRACE_END; + return false; + } else { + ugd->ug_ListPlay.ug_Player = 0; + ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_INIT; + UG_TRACE_END; + return true; + } + } + + UG_SAFE_FREE_CHAR(g_player_cbs); + if (g_player_pipe) { + ecore_pipe_del(g_player_pipe); + g_player_pipe = NULL; + } + UG_TRACE_END; + return false; +} + +/****************************** +** Prototype : __mf_ug_list_play_play_current_file +** Description : Samsung +** Input : ugData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_play_current_file(void *data) +{ + + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ug_mf_retvm_if(itemData == NULL, false, "itemData is NULL"); + ugData *ugd = itemData->ug_pData; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + int error_code = 0; + + player_state_e state = PLAYER_STATE_NONE; + error_code = player_get_state(ugd->ug_ListPlay.ug_Player, &state); + ug_debug("state is [%d]", state); + if (state != PLAYER_STATE_READY) { + UG_TRACE_END; + return false; + } + if (!__mf_ug_list_play_play(itemData)) { + mf_ug_list_play_destory_playing_file(ugd); + mf_ug_list_disable_play_itc(ugd, true); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + UG_TRACE_END; + return false; + } + + return true; +} + + +/****************************** +** Prototype : __mf_ug_list_play_resume +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_resume(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + player_state_e state = PLAYER_STATE_NONE; + int error_code = 0; + int err = -1; + + if (ugd->ug_ListPlay.ug_Player != 0) { + error_code = player_get_state(ugd->ug_ListPlay.ug_Player, &state); + ug_debug("state is [%d]", state); + + if (0 == error_code && PLAYER_STATE_PAUSED == state) { + err = player_start(ugd->ug_ListPlay.ug_Player); + + if (err != PLAYER_ERROR_NONE) { + + if (err == PLAYER_ERROR_SOUND_POLICY) + { + ug_error("ERROR HERE !!!!!!!"); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNABLE_TO_PLAY_DURING_CALL, NULL, + NULL, NULL, NULL, NULL); + } + else + { + ug_error("ERROR HERE !!!!!!!"); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_UNABLE_TO_PLAY_ERROR_OCCURRED, NULL, + NULL, NULL, NULL, NULL); + } + ug_error("Error when _mp_player_mgr_play. err[%x]\n", err); + UG_TRACE_END; + return false; + } else { + __mf_ug_list_play_set_play_start_status(ugd, ugd->ug_ListPlay.ug_pPlayFilePath); + mf_ug_list_disable_play_itc(ugd, false); + UG_TRACE_END; + return true; + } + } else { + UG_TRACE_END; + return false; + } + } + UG_TRACE_END; + return false; + +} + + +/****************************** +** Prototype : __mf_ug_list_play_pause +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static bool __mf_ug_list_play_pause(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + int err = 0; + player_state_e state = PLAYER_STATE_NONE; + int error_code = 0; + + if (ugd->ug_ListPlay.ug_Player) { + error_code = player_get_state(ugd->ug_ListPlay.ug_Player, &state); + ug_debug("state is [%d]", state); + + if (0 == error_code && PLAYER_STATE_PLAYING == state) { + err = player_pause(ugd->ug_ListPlay.ug_Player); + if (err != 0) { + ug_debug("Error when _ug_player_mgr_pause. err[%x]\n", err); + UG_TRACE_END; + return false; + } else { + UG_TRACE_END; + return true; + } + } else { + UG_TRACE_END; + return false; + } + } + UG_TRACE_END; + return false; +} + + +/****************************** +** Prototype : mp_play_control_cb +** Description : +** Input : ugListItemData *data +** int state +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_list_play_pause(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + int state = ugd->ug_ListPlay.ug_iPlayState; + + if (state == PLAY_STATE_PLAYING) { + if(__mf_ug_list_play_pause(ugd)) { + __mf_ug_list_play_pauset(ugd); + mf_ug_list_disable_play_itc(ugd, false); + } + } +} +static void __mf_ug_list_play_control_cb(void *data) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + + ugData *ugd = (ugData *)itemData->ug_pData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + int state = ugd->ug_ListPlay.ug_iPlayState; + + if (state == PLAY_STATE_PLAYING) { + if(__mf_ug_list_play_pause(ugd)) { + __mf_ug_list_play_pauset(ugd); + mf_ug_list_disable_play_itc(ugd, false); + } + } else { + if(__mf_ug_list_play_resume(ugd)) { + __mf_ug_list_play_start(itemData); + } + + } + UG_TRACE_END; +} + +static bool __mf_ug_list_play_play_new_file(ugListItemData *data, bool drm_check_flag) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ug_mf_retvm_if(itemData == NULL, false, "itemData is NULL"); + + ugData *ugd = (ugData *)itemData->ug_pData; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + __mf_ug_list_play_init_data(ugd); + + if (!__mf_ug_list_play_ready_new_file_play(itemData, true)) { + UG_TRACE_END; + return false; + } + + if (!__mf_ug_list_play_play_current_file(itemData)) { + UG_TRACE_END; + return false; + } + UG_TRACE_END; + + return true; +} + + +/****************************** +** Prototype : _music_item_play +** Description : +** Input : ugListItemData *param +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_list_play_play_music_item(ugListItemData *data) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + ugData *ugd = itemData->ug_pData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + int key = 0; + int error_code = 0; + error_code = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &key); + + ug_debug("key is [%d]", key); + ug_debug("ugd->ug_ListPlay.ug_iPlayState is [%d]", ugd->ug_ListPlay.ug_iPlayState); + + if (error_code == 0 && key <= VCONFKEY_SYSMAN_BAT_POWER_OFF) { + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, ("Battery low, play failed!"), NULL, NULL, NULL, NULL, NULL); + } else if (error_code != 0) { + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, ("Unkown error, play failed!"), NULL, NULL, NULL, NULL, NULL); + } else { + if (ugd->ug_ListPlay.ug_pPlayFilePath != NULL) { + ug_debug(); + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, itemData->ug_pItemName->str) != 0) { + //mf_ug_list_play_destory_playing_file(ugd); + mf_ug_list_play_reset_playing_file(ugd); + mf_ug_list_disable_play_itc(ugd, true); + //mf_ug_list_play_update_item_icon(ugd); + __mf_ug_list_play_play_new_file(itemData, true); + } else { + ug_debug(); + /*/ playing the same file */ + __mf_ug_list_play_control_cb(itemData); + } + } else { + ug_debug(); + mf_ug_list_disable_play_itc(ugd, false); + __mf_ug_list_play_play_new_file(itemData, true); + } + } + UG_TRACE_END; + +} + +/****************************** +** Prototype : mf_ug_list_play_destory_playing_file +** Description : +** Input : ugListItemData *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_list_play_reset_playing_file(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + __mf_ug_list_play_unrealize(ugd); + +} +void mf_ug_list_play_destory_playing_file(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + __mf_ug_list_play_stop(ugd); + __mf_ug_list_play_unrealize(ugd); + __mf_ug_list_play_destory(ugd); + UG_TRACE_END; +} + + +static sound_type_e mf_ug_player_get_sound_type() +{ + UG_TRACE_BEGIN; + sound_type_e type = SOUND_TYPE_SYSTEM; + int ret = 0; + ret = sound_manager_get_current_sound_type(&type); + ug_error("ret is [%d]", ret); + UG_TRACE_END; + return type; +} + +static int mf_ug_player_get_volume(sound_type_e type) +{ + UG_TRACE_BEGIN; + int volume = 0; + int ret = 0; + ret = sound_manager_get_volume(SOUND_TYPE_MEDIA, &volume); + //ret = sound_manager_get_volume(type, &volume); + ug_error("ret is [%d]", ret); + UG_TRACE_END; + return volume; + +} + +static void mf_ug_player_set_volume(sound_type_e type, int volume) +{ + UG_TRACE_BEGIN; + int ret = 0; + ret = sound_manager_set_volume(type, volume); + ug_error("ret is [%d]", ret); + UG_TRACE_END; +} + + +static void mf_ug_player_vol_type_set(mf_player_volume_type type) +{ + UG_TRACE_BEGIN; + sound_type_e current_type; + int volume = 0; + current_type = mf_ug_player_get_sound_type(); + volume = mf_ug_player_get_volume(current_type); + ug_error("current type is [%d] volume is [%d] type is [%d]", current_type, volume, type); + sound_manager_set_volume_key_type(VOLUME_KEY_TYPE_MEDIA); + mf_ug_player_set_volume(SOUND_TYPE_MEDIA, volume); + UG_TRACE_END; + return; + switch (type) { + case MF_VOLUME_ALERT: + sound_manager_set_volume_key_type(VOLUME_KEY_TYPE_ALARM); + mf_ug_player_set_volume(SOUND_TYPE_ALARM, volume); + break; + case MF_VOLUME_NOTIFICATION: + sound_manager_set_volume_key_type(VOLUME_KEY_TYPE_NOTIFICATION); + mf_ug_player_set_volume(SOUND_TYPE_NOTIFICATION, volume); + break; + case MF_VOLUME_RINGTONE: + sound_manager_set_volume_key_type(VOLUME_KEY_TYPE_RINGTONE); + mf_ug_player_set_volume(SOUND_TYPE_RINGTONE, volume); + break; + default: + sound_manager_set_volume_key_type(VOLUME_KEY_TYPE_MEDIA); + mf_ug_player_set_volume(SOUND_TYPE_MEDIA, volume); + break; + } + UG_TRACE_END; +} + +void mf_ug_player_vol_set(const char *path) +{ + ug_mf_retm_if(path == NULL, "path is NULL"); + if (g_strcmp0(path, UG_SETTING_MSG_ALERTS_PATH) == 0) { + mf_ug_player_vol_type_set(MF_VOLUME_NOTIFICATION); + } else if (g_strcmp0(path, UG_SETTING_RINGTONE_PATH) == 0) { + mf_ug_player_vol_type_set(MF_VOLUME_RINGTONE); + } else if (g_strcmp0(path, UG_SETTING_ALERTS_PATH) == 0) { + mf_ug_player_vol_type_set(MF_VOLUME_ALERT); + } else { + mf_ug_player_vol_type_set(MF_VOLUME_NONE); + } +} + diff --git a/src/common/mf-ug-search-internal.c b/src/common/mf-ug-search-internal.c new file mode 100644 index 0000000..95e5c12 --- /dev/null +++ b/src/common/mf-ug-search-internal.c @@ -0,0 +1,882 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <glib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <dirent.h> +#include <pthread.h> +#include <Ecore.h> + +#include "mf-ug-main.h" +#include "mf-ug-search.h" +#include "mf-ug-search-internal.h" +#include "mf-ug-fs-util.h" + +#define APPEND_SIZE 2 /* for null and slash */ +#define MF_ERR_BUF 256 + +#define NORMALIZE_OPTION G_NORMALIZE_NFD + +#ifdef CHECK_RESTRICTED_PATH +/* TODO + * This code should be revised. + * How to get restricted path information? + * I think this module should not depend on other lib(except glib and stdlib). +*/ +#define ROOT_UMS "/opt/usr/media" +#define ROOT_MMC "/opt/storage/sdcard" +#endif /* CHECK_RESTRICTED_PATH */ + +int flagSearchMsg = 1; +pthread_mutex_t gLockSearchMsg; +pthread_cond_t gCondSearchMsg; + +static void __mf_ug_search_tx_wait(); +static void __mf_ug_search_result_publish_msg(mf_search_pipe_msg_type type, void *result, void *user_data); + +inline static void __mf_ug_search_cmd_lock(ms_handle_t *handle) +{ + if (handle && handle->cmd_lock) { + g_mutex_lock(handle->cmd_lock); + } + return; +} + +inline static void __mf_ug_search_cmd_unlock(ms_handle_t *handle) +{ + if (handle && handle->cmd_lock) { + g_mutex_unlock(handle->cmd_lock); + } + return; +} + +inline static void __mf_ug_search_thread_lock(ms_handle_t *handle) +{ + if (handle && handle->thread_mutex) { + g_mutex_lock(handle->thread_mutex); + } + return; +} + +inline static void __mf_ug_search_thread_unlock(ms_handle_t *handle) +{ + if (handle && handle->thread_mutex) { + g_mutex_unlock(handle->thread_mutex); + } + return; +} + +inline static void __mf_ug_search_args_free(ms_args_t *args) +{ + if (args) { + if (args->root_path) { + g_list_foreach(args->root_path, (GFunc) g_free, NULL); + g_list_free(args->root_path); + args->root_path = NULL; + } + + if (args->needle) + g_free(args->needle); + + g_free(args); + } + return; +} + +inline static void __mf_ug_search_result_free(mf_search_result_t *result) +{ + if (result) { + if (result->current_dir) { + g_free(result->current_dir); + result->current_dir = NULL; + } + if (result->dir_list) { + g_list_foreach(result->dir_list, (GFunc) g_free, NULL); + g_list_free(result->dir_list); + result->dir_list = NULL; + } + if (result->file_list) { + g_list_foreach(result->file_list, (GFunc) g_free, NULL); + g_list_free(result->file_list); + result->file_list = NULL; + } + g_free(result); + } + return; +} + +#ifdef CHECK_RESTRICTED_PATH +gboolean __mf_ug_search_check_licet_path(const char *path) +{ + return (gboolean) (strstr(path, ROOT_UMS) || strstr(path, ROOT_MMC)); +} +#endif /*CHECK_RESTRICTED_PATH*/ + + + /*This function is for testing and should be revised for performance before applying*/ +static inline gboolean __mf_ug_search_has_nonspacing_mark(const char *nstr) +{ + if (nstr) { + const char *p_str = nstr; + while (p_str && *p_str) { + gunichar uc; + uc = g_utf8_get_char(p_str); + if (g_unichar_type(uc) == G_UNICODE_NON_SPACING_MARK) { + return TRUE; + } else { + p_str = g_utf8_next_char(p_str); + } + } + } + return FALSE; +} + +static gboolean __mf_ug_search_NFD_ext(const char *str, const char *needle) +{ + int s_len = 0; + int n_len = 0; + if (!str) { + return FALSE; + } + s_len = strlen(str); + + if (!needle) { + return FALSE; + } else { + n_len = strlen(needle); + if (n_len == 0) { + return FALSE; + } + } + if (s_len < n_len) + return FALSE; + char *pdot = strrchr(str, '.'); + + if (!pdot) { + return FALSE; + } else if (pdot != str) { + char *ext = NULL;; + ext = g_strdup(pdot+1); + if (g_strcmp0(ext, needle)== 0) { + g_free(ext); + ext = NULL; + return TRUE; + } + else { + g_free(ext); + ext = NULL; + return FALSE; + } + } else { + return FALSE; + } + +} +static gboolean __mf_ug_search_NFD_strstr(const char *str, const char *needle) +{ + int s_len = 0; + int n_len = 0; + + if (!str) { + return FALSE; + } + s_len = strlen(str); + + if (!needle) { + return FALSE; + } else { + n_len = strlen(needle); + if (n_len == 0) { + return FALSE; + } + } + + if (s_len < n_len) + return FALSE; + + if (__mf_ug_search_has_nonspacing_mark(str)) { + const char *p_str = str; + const char *end = p_str + s_len - n_len; + + while (p_str && p_str <= end && *p_str) { + const char *s = p_str; + const char *n = needle; + while (n && *n) { + if (s && *s) { + gunichar sc, nc; + sc = g_utf8_get_char(s); + nc = g_utf8_get_char(n); + if (g_unichar_type(sc) == G_UNICODE_NON_SPACING_MARK) { + if (g_unichar_type(nc) == G_UNICODE_NON_SPACING_MARK) { + if (sc != nc) { + goto next; + } else { + s = g_utf8_next_char(s); + n = g_utf8_next_char(n); + } + } else { + s = g_utf8_next_char(s); + } + } else if (sc != nc) { + goto next; + } else { + s = g_utf8_next_char(s); + n = g_utf8_next_char(n); + } + } else { + return FALSE; + } + } + + return TRUE; +next: + p_str = g_utf8_next_char(p_str); + } + } else { + return (gboolean) (!(!strstr(str, needle))); + } + return FALSE; +} + +static GList *__mf_ug_search_do_find(const char *root, const char *needle, mf_search_option option, ms_handle_t *handle) +{ + DIR *directory = NULL; + GList *candidate = NULL; + + char *up_needle = NULL; + char *up_name = NULL; + + if (!handle) { + ms_error("handle is NULL"); + return NULL; + } + + if (!handle->result) { + ms_error("handle->result is NULL"); + return NULL; + } + + if (!root || !needle) { + ms_error("invaild args"); + return NULL; + } + + if (!g_file_test(root, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { + ms_error("invaild root_path : %s", root); + return NULL; + } + + directory = opendir(root); + if (directory) { + mf_search_result_t *result = NULL; + struct dirent *entry = NULL; + + result = handle->result; + __mf_ug_search_thread_lock(handle); + if (result->current_dir) { + g_free(result->current_dir); + } + result->current_dir = g_strdup(root); + __mf_ug_search_thread_unlock(handle); + while ((entry = readdir(directory)) != NULL) { + if (!(option & MF_SEARCH_OPT_HIDDEN) && (0 == strncmp(entry->d_name, ".", 1))) { + ms_debug("[%s] is hidden file. Skip it", entry->d_name); + continue; + } + + if (handle->is_stop == TRUE) { + ms_debug("break from do find"); + break; + } + + if (entry->d_type & DT_REG) { + if (option & MF_SEARCH_OPT_FILE) { + __mf_ug_search_thread_lock(handle); + result->total_count++; + __mf_ug_search_thread_unlock(handle); + + up_name = g_utf8_strup(entry->d_name, strlen(entry->d_name)); + up_needle = g_utf8_strup(needle, strlen(needle)); + + /*Todo:*/ + /* should we check the return value for further use? */ + gchar *nor_str = g_utf8_normalize(up_name, -1, NORMALIZE_OPTION); + if (__mf_ug_search_NFD_strstr(nor_str, up_needle)) + { + gchar *path = NULL; + gssize len = strlen(root) + strlen(entry->d_name) + APPEND_SIZE; /* for null and slash*/ + path = g_malloc(sizeof(gchar) * len); + if (path) { + g_snprintf(path, len, "%s/%s", root, entry->d_name); + + __mf_ug_search_thread_lock(handle); + result->file_list = g_list_append(result->file_list, (gpointer) path); + result->is_end = FALSE; + __mf_ug_search_thread_unlock(handle); + + __mf_ug_search_tx_wait(); + __mf_ug_search_result_publish_msg(MF_SEARCH_PIPE_MSG_RESULT_REPORT, result, + handle->args->user_data); + } + /*1 TODO: how can i handle else case?*/ + } + g_free(nor_str); + free(up_needle); + up_needle = NULL; + free(up_name); + up_name = NULL; + }else if (option & MF_SEARCH_OPT_EXT) { + __mf_ug_search_thread_lock(handle); + result->total_count++; + __mf_ug_search_thread_unlock(handle); + + up_name = g_utf8_strup(entry->d_name, strlen(entry->d_name)); + up_needle = g_utf8_strup(needle, strlen(needle)); + + /*Todo:*/ + /* should we check the return value for further use? */ + gchar *nor_str = g_utf8_normalize(up_name, -1, NORMALIZE_OPTION); + if (__mf_ug_search_NFD_ext(nor_str, up_needle)) + { + gchar *path = NULL; + gssize len = strlen(root) + strlen(entry->d_name) + APPEND_SIZE; /* for null and slash*/ + path = g_malloc(sizeof(gchar) * len); + if (path) { + g_snprintf(path, len, "%s/%s", root, entry->d_name); + + __mf_ug_search_thread_lock(handle); + result->file_list = g_list_append(result->file_list, (gpointer) path); + result->is_end = FALSE; + __mf_ug_search_thread_unlock(handle); + + __mf_ug_search_tx_wait(); + __mf_ug_search_result_publish_msg(MF_SEARCH_PIPE_MSG_RESULT_REPORT, result, + handle->args->user_data); + } + /*1 TODO: how can i handle else case?*/ + } + g_free(nor_str); + free(up_needle); + up_needle = NULL; + free(up_name); + up_name = NULL; + + } + } else if (entry->d_type & DT_DIR) { + gchar *path = NULL; + gssize len = 0; + + len = strlen(entry->d_name); + /*skip current and upper directory*/ + if (0 == strncmp(entry->d_name, ".", strlen(".")) || 0 == strncmp(entry->d_name, "..", strlen(".."))) { + continue; + } + /* we are not going to search /opt/media/SLP_Debug folder */ + if ((strlen(result->current_dir) == strlen(PHONE_FOLDER)) && (strcmp(result->current_dir, PHONE_FOLDER) == 0) + && (strlen(entry->d_name) == strlen(DEBUG_FOLDER)) && (strcmp(entry->d_name, DEBUG_FOLDER) == 0)) { + ms_debug("[%s] is hidden folder. Skip it", entry->d_name); + continue; + } + + len = strlen(root) + strlen(entry->d_name) + APPEND_SIZE; /* for null and slash */ + path = g_malloc(sizeof(gchar) * len); + if (path) { + g_snprintf(path, len, "%s/%s", root, entry->d_name); + candidate = g_list_append(candidate, (gpointer) path); + } + /*1 TODO: how can i handle else case?*/ + if (option & MF_SEARCH_OPT_DIR) { + __mf_ug_search_thread_lock(handle); + result->total_count++; + __mf_ug_search_thread_unlock(handle); + + up_name = g_utf8_strup(entry->d_name, strlen(entry->d_name)); + if (needle && strlen(needle)) { + up_needle = g_utf8_strup(needle, strlen(needle)); + gchar *nor_str = g_utf8_normalize(up_name, -1, NORMALIZE_OPTION); + if (__mf_ug_search_NFD_strstr(nor_str, up_needle)) + { + __mf_ug_search_thread_lock(handle); + result->dir_list = g_list_append(result->dir_list, (gpointer) g_strdup(path)); + result->is_end = FALSE; + __mf_ug_search_thread_unlock(handle); + __mf_ug_search_tx_wait(); + __mf_ug_search_result_publish_msg(MF_SEARCH_PIPE_MSG_RESULT_REPORT, result, handle->args->user_data); + } + g_free(nor_str); + free(up_name); + up_name = NULL; + + free(up_needle); + up_needle = NULL; + } else { + free(up_name); + up_name = NULL; + } + } + } + } + closedir(directory); + directory = NULL; + } + + return candidate; +} + +static gpointer __mf_ug_search_find_thread(gpointer data) +{ + ms_handle_t *handle = (ms_handle_t *) data; + if (handle) { + ms_args_t *args = NULL; + mf_search_result_t *result = NULL; + + result = handle->result; + args = handle->args; + + if (args && result) { + GList *root = NULL; + GList *candidate = NULL; /*use this list as stack*/ + root = args->root_path; + while (root) { + char *path = (char *)root->data; + if (path) { + /*push root paths to stack*/ + candidate = g_list_append(candidate, (gpointer) g_strdup(path)); + } + root = g_list_next(root); + } + + while (candidate) { + GList *new_list = NULL; + GList *list = NULL; + gchar *item = NULL; + + __mf_ug_search_thread_lock(handle); + if (handle->is_stop) { + __mf_ug_search_thread_unlock(handle); + result->is_end = TRUE; + goto MF_FIND_THREAD_EXIT; + } + __mf_ug_search_thread_unlock(handle); + + list = g_list_first(candidate); + /*pop one path from stack*/ + candidate = g_list_remove_link(candidate, list); + item = (gchar *) list->data; + if (item) { + ms_debug("current : %s", item); +#if 0 + __mf_ug_search_thread_lock(handle); + if (result->current_dir) { + g_free(result->current_dir); + } + result->current_dir = g_strdup(item); + __mf_ug_search_thread_unlock(handle); +#endif + /*publish root change message here*/ + __mf_ug_search_tx_wait(); + if (handle->is_stop) { + result->is_end = TRUE; + goto MF_FIND_THREAD_EXIT; + } + __mf_ug_search_result_publish_msg(MF_SEARCH_PIPE_MSG_ROOT_CHANGE, item, args->user_data); + new_list = __mf_ug_search_do_find(item, args->needle, args->option, handle); + g_free(item); + item = NULL; + g_list_free(list); + list = NULL; + } + /*push new paths to stack*/ + candidate = g_list_concat(new_list, candidate); + } + + __mf_ug_search_thread_lock(handle); + result->is_end = TRUE; + __mf_ug_search_thread_unlock(handle); + __mf_ug_search_tx_wait(); + __mf_ug_search_result_publish_msg(MF_SEARCH_PIPE_MSG_FINISHED, handle->result, args->user_data); +MF_FIND_THREAD_EXIT: + if (candidate) { + g_list_foreach(candidate, (GFunc) g_free, NULL); + g_list_free(candidate); + candidate = NULL; + } + } else { + ms_error("args : %p or result : %p is not allocated yet!!", handle->args, handle->result); + } + } + /*g_thread_exit(NULL);*/ + return NULL; +} + +int _mf_ug_search_init(ms_handle_t **handle) +{ + GMutex *lock = NULL; + ms_handle_t *ms_handle = NULL; + + ms_debug(""); + + if (!handle) { + return MF_SEARCH_ERROR_INVAL_P; + } + + ms_handle = g_malloc0(sizeof(ms_handle_t)); + if (ms_handle == NULL) { + ms_error("Fail to allocate memory for handle "); + *handle = NULL; + return MF_SEARCH_ERROR_ALLOC; + } + + ms_handle->state = MF_SEARCH_STATE_INIT; + ms_handle->is_stop = FALSE; + + lock = g_mutex_new(); + if (!lock) { + ms_error("Fail to create cmd_lock"); + g_free(ms_handle); + return MF_SEARCH_ERROR_ALLOC; + } + ms_handle->cmd_lock = lock; + + *handle = ms_handle; + + ms_info("Success to make search handle : %p", ms_handle); + return MF_SEARCH_ERROR_NONE; +} + +int _mf_ug_search_start(ms_handle_t *handle, const char **root_path, unsigned int path_num, const char *needle, mf_search_option option, void *user_data) +{ + ms_args_t *args = NULL; + mf_search_result_t *result = NULL; + mf_search_option l_opt = MF_SEARCH_OPT_NONE; + int ret = MF_SEARCH_ERROR_NONE; + int i = 0; + + if (!handle) { + ms_error("handle is NULL"); + return MF_SEARCH_ERROR_INVAL_P; + } + + if (handle->state != MF_SEARCH_STATE_INIT) { + ms_error("invaild state : %d", handle->state); + return MF_SEARCH_ERROR_INVAL_S; + } + + if (!root_path || !needle || path_num < 1) { + ms_error("invaild arguments - root[%p], path_num[%d], needle[%p]", root_path, path_num, needle); + return MF_SEARCH_ERROR_INVAL_P; + } + + __mf_ug_search_cmd_lock(handle); + + if (handle->args) { + __mf_ug_search_args_free(handle->args); + handle->args = NULL; + } + handle->args = args = g_malloc0(sizeof(ms_args_t)); + if (!args) { + ms_error("fail to alloc args"); + ret = MF_SEARCH_ERROR_ALLOC; + goto FAIL_FREE_MEM; + } + + if (option == MF_SEARCH_OPT_NONE) { + ms_warn("option is MF_SEARCH_OPT_NONE, set all option automatically "); + l_opt = MF_SEARCH_OPT_HIDDEN | MF_SEARCH_OPT_DIR | MF_SEARCH_OPT_FILE; + } else { + l_opt = option; + } + + for (i = 0; i < path_num; i++) { + const char *path = root_path[i]; + ms_debug("%d th root path is %s", i, path); +#ifdef CHECK_RESTRICTED_PATH + if (!__mf_ug_search_check_licet_path(path)) { + ms_error("%dth root path[%s] is invaild", i, path); + ret = MF_SEARCH_ERROR_INVAL_P; + goto FAIL_FREE_MEM; + } +#endif /*CHECK_RESTRICTED_PATH*/ + if (g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) + && ((l_opt & MF_SEARCH_OPT_HIDDEN) || strncmp(path, ".", 1)) + && TRUE) { + gchar *new_path = NULL; + gssize len = strlen(path); + + if (path[len - 1] == '/') { + new_path = g_strndup(path, len - 1); + } else { + new_path = g_strndup(path, len); + } + args->root_path = g_list_append(args->root_path, (gpointer) new_path); + } else { + ms_error("Fail to test %dthe root path[%s]", i, path); + ret = MF_SEARCH_ERROR_INVAL_P; + goto FAIL_FREE_MEM; + } + } + args->user_data = user_data; + + + args->needle = g_utf8_normalize(needle, -1, NORMALIZE_OPTION); + if (!args->needle) { + ms_error("fail to alloc args->needle"); + goto FAIL_FREE_MEM; + } + + args->option = l_opt; + + if (handle->result) { + __mf_ug_search_result_free(handle->result); + handle->result = NULL; + } + handle->result = result = g_malloc0(sizeof(ms_args_t)); + if (!result) { + ms_error("fail to alloc result"); + ret = MF_SEARCH_ERROR_ALLOC; + goto FAIL_FREE_MEM; + } + + handle->thread_mutex = g_mutex_new(); + if (!handle->thread_mutex) { + ms_error("fail to alloc handle->thread_mutex"); + ret = MF_SEARCH_ERROR_ALLOC; + goto FAIL_FREE_MEM; + } + + handle->is_stop = FALSE; + handle->result->is_end = FALSE; + + /*create thread for find item.*/ + handle->thread_h = g_thread_create(__mf_ug_search_find_thread, handle, TRUE, NULL); + if (!handle->thread_h) { + ms_error("fail to create __mf_ug_search_find_thread"); + ret = MF_SEARCH_ERROR_INTERNAL; + goto FAIL_FREE_MEM; + } + /*create idler for reporting find result.*/ + handle->state = MF_SEARCH_STATE_SEARCH; + __mf_ug_search_cmd_unlock(handle); + return MF_SEARCH_ERROR_NONE; + +FAIL_FREE_MEM: + if (args) { + __mf_ug_search_args_free(args); + handle->args = NULL; + } + + if (result) { + __mf_ug_search_result_free(result); + handle->result = NULL; + } + + if (handle->thread_mutex) { + g_mutex_free(handle->thread_mutex); + handle->thread_mutex = NULL; + } + + if (handle->thread_h) { + __mf_ug_search_thread_lock(handle); + handle->is_stop = TRUE; + __mf_ug_search_thread_unlock(handle); + g_thread_join(handle->thread_h); + handle->thread_h = NULL; + } + __mf_ug_search_cmd_unlock(handle); + + return ret; +} + +int _mf_ug_search_stop(ms_handle_t *handle) +{ + ms_debug(""); + + if (!handle) { + ms_error("handle is NULL"); + return MF_SEARCH_ERROR_INVAL_P; + } + + if (handle->state != MF_SEARCH_STATE_SEARCH) { + ms_error("invaild state : %d", handle->state); + return MF_SEARCH_ERROR_INVAL_S; + } + + __mf_ug_search_cmd_lock(handle); + + __mf_ug_search_thread_lock(handle); + handle->is_stop = TRUE; + __mf_ug_search_thread_unlock(handle); + + pthread_mutex_lock(&gLockSearchMsg); + if (flagSearchMsg == 0) { + flagSearchMsg = 1; + pthread_cond_signal(&gCondSearchMsg); + } + pthread_mutex_unlock(&gLockSearchMsg); + + if (handle->thread_h) { + g_thread_join(handle->thread_h); + handle->thread_h = NULL; + } + + if (handle->thread_mutex) { + g_mutex_free(handle->thread_mutex); + handle->thread_mutex = NULL; + } + + if (handle->args) { + __mf_ug_search_args_free(handle->args); + handle->args = NULL; + } + if (handle->result) { + __mf_ug_search_result_free(handle->result); + handle->result = NULL; + } + + handle->state = MF_SEARCH_STATE_INIT; + handle->is_stop = FALSE; + + __mf_ug_search_cmd_unlock(handle); + + return MF_SEARCH_ERROR_NONE; +} + +void _mf_ug_search_finalize(ms_handle_t **handle) +{ + ms_handle_t *ms_handle = *handle; + + ms_debug(""); + + if (!ms_handle) { + ms_warn("invaild handle"); + return; + } + + if (ms_handle->state == MF_SEARCH_STATE_SEARCH) { + mf_ug_search_stop(ms_handle); + } +/* __mf_ug_search_cmd_lock(ms_handle); */ +/* __mf_ug_search_cmd_unlock(ms_handle); */ + + if (ms_handle->cmd_lock) { + g_mutex_free(ms_handle->cmd_lock); + ms_handle->cmd_lock = NULL; + } + g_free(ms_handle); + *handle = NULL; + + return; +} + +/*+++++++++++++++++++++++++ UTIL APIs ++++++++++++++++++++++++++++++ */ +static void __mf_ug_search_tx_wait() +{ + pthread_mutex_lock(&gLockSearchMsg); + while (flagSearchMsg == 0) { + pthread_cond_wait(&gCondSearchMsg, &gLockSearchMsg); + } + flagSearchMsg = 0; + pthread_mutex_unlock(&gLockSearchMsg); +} + +static void __mf_ug_search_result_publish_msg(mf_search_pipe_msg_type type, void *result, void *user_data) +{ + ugData *ugd = (ugData *)user_data; + /*generate message block*/ + mf_search_pipe_msg msg; + memset(&msg, 0, sizeof(mf_search_pipe_msg)); + + msg.mf_sp_msg_type = type; + if (msg.mf_sp_msg_type == MF_SEARCH_PIPE_MSG_RESULT_REPORT) { + msg.report_result = g_strdup((gchar *) result); + msg.current_path = NULL; + } else if (msg.mf_sp_msg_type == MF_SEARCH_PIPE_MSG_ROOT_CHANGE) { + msg.report_result = NULL; + msg.current_path = g_strdup((gchar *) result); + ms_debug("current path is %s", msg.current_path); + } else if (msg.mf_sp_msg_type == MF_SEARCH_PIPE_MSG_FINISHED) { + msg.report_result = result; + msg.current_path = NULL; + } else { + msg.report_result = NULL; + msg.current_path = NULL; + } + + /*write message to pipe*/ + ecore_pipe_write(ugd->ug_UiGadget.ug_pSyncPipe, &msg, sizeof(msg)); +} + +gchar *_mf_ug_search_result_dir_get(mf_search_result_t * result) +{ + gchar *name = NULL; + if (result) { + GList *list = NULL; + list = result->dir_list; + if (list && list->data) { + gchar *item = (gchar *) list->data; + result->dir_list = g_list_remove(list, item); + name = item; + } + } + return name; +} + +gchar *_mf_ug_search_result_file_get(mf_search_result_t * result) +{ + gchar *name = NULL; + if (result) { + GList *list = NULL; + list = result->file_list; + if (list && list->data) { + gchar *item = (gchar *) list->data; + result->file_list = g_list_remove(list, item); + name = item; + } + } + return name; +} + +gboolean _mf_ug_search_result_is_end(mf_search_result_t *result) +{ + gboolean end = FALSE; + if (result) { + end = result->is_end; + } + return end; +} + +guint _mf_ug_search_result_total_count_get(mf_search_result_t *result) +{ + guint count = 0; + if (result) { + count = result->total_count; + } + return count; +} + +gchar *_mf_ug_search_result_current_dir_get(mf_search_result_t * result) +{ + gchar *c_dir = NULL; + if (result) { + if (result->current_dir) { + c_dir = result->current_dir; + result->current_dir = NULL; + } + } + return c_dir; +} diff --git a/src/common/mf-ug-search.c b/src/common/mf-ug-search.c new file mode 100644 index 0000000..db2ca6e --- /dev/null +++ b/src/common/mf-ug-search.c @@ -0,0 +1,125 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include <dirent.h> +#include <sys/types.h> +#include <string.h> +#include <glib.h> + +#include "mf-ug-dlog.h" +#include "mf-ug-search.h" +#include "mf-ug-search-internal.h" + + +/*+++++++++++++++++++++++ APIs +++++++++++++++++++++++*/ + +int mf_ug_search_init(mf_search_handle *handle) +{ + int ret = 0; + ms_handle_t *ms_handle = NULL; + + if (!handle) { + return -1; + } + if (!g_thread_supported()) { + g_thread_init(NULL); + } + ret = _mf_ug_search_init(&ms_handle); + if (ret < 0) { + ms_error("Fail to init search handle "); + *handle = (mf_search_handle) 0; + return ret; + } + + *handle = (mf_search_handle) ms_handle; + + return MF_SEARCH_ERROR_NONE; +} + +int mf_ug_search_start(mf_search_handle handle, + const char **root_path, unsigned int path_num, const char *needle, mf_search_option option, void *user_data) +{ + int ret = 0; + if (!handle) { + return MF_SEARCH_ERROR_INVAL_P; + } + + if (!root_path || !needle || path_num < 1) { + return MF_SEARCH_ERROR_INVAL_P; + } + + ret = _mf_ug_search_start((ms_handle_t *) handle, root_path, path_num, needle, option, user_data); + + if (ret < 0) { + ms_error("Fail to start search "); + } + return ret; +} + +int mf_ug_search_stop(mf_search_handle handle) +{ + int ret = 0; + + ret = _mf_ug_search_stop((ms_handle_t *) handle); + if (ret < 0) { + ms_error("Fail to stop search "); + } + return ret; +} + +void mf_ug_search_finalize(mf_search_handle *handle) +{ + _mf_ug_search_finalize((ms_handle_t **) handle); + return; +} + +/*+++++++++++++++++++++++ UTIL APIs +++++++++++++++++++++++*/ + +char *mf_ug_search_result_dir_get(mf_search_result_t *result) +{ + return _mf_ug_search_result_dir_get(result); +} + +char *mf_ug_search_result_file_get(mf_search_result_t *result) +{ + return _mf_ug_search_result_file_get(result); +} + +int mf_ug_search_result_is_end(mf_search_result_t *result, int *is_end) +{ + if (result) { + *is_end = _mf_ug_search_result_is_end(result); + } else { + return MF_SEARCH_ERROR_INVAL_P; + } + return MF_SEARCH_ERROR_NONE; +} + +int mf_ug_search_result_total_count_get(mf_search_result_t *result, unsigned int *count) +{ + if (result) { + *count = _mf_ug_search_result_total_count_get(result); + } else { + return MF_SEARCH_ERROR_INVAL_P; + } + return MF_SEARCH_ERROR_NONE; +} + +char *mf_ug_search_result_current_dir_get(mf_search_result_t *result) +{ + return _mf_ug_search_result_current_dir_get(result); +} diff --git a/src/common/mf-ug-util.c b/src/common/mf-ug-util.c new file mode 100644 index 0000000..a9ea7b7 --- /dev/null +++ b/src/common/mf-ug-util.c @@ -0,0 +1,858 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <pthread.h> +#include <vconf.h> + +#include "mf-ug-util.h" +#include "mf-ug-cb.h" +#include "mf-ug-winset.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-inotify-handle.h" +#include "mf-ug-resource.h" + +#define MF_UG_TIMER_INTERVAL_VIBRATION 0.5 +#define MF_UG_VIBRATION_DEVICE 0 +#define MF_UG_VIBRATION_DURATION 500 +#ifdef UG_OPERATION_SELECT_MODE +#define OPERATION_SEPERATOR ";" +#endif +#define NORMAL_SEPERATOR "?" + +/****************************** +** Prototype : ug_genlist_selected_state_get +** Description : +** Input : void *data +** Output : bool +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +bool mf_ug_util_is_genlist_selected(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL"); + + Elm_Object_Item *gli = NULL; + Elm_Object_Item *nli = NULL; + Evas_Object *genlist = NULL; + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retvm_if(pNavi_s == NULL, false, "get navigation bar in use failed"); + + if (ugd->ug_MainWindow.ug_pNaviGenlist) { + genlist = ugd->ug_MainWindow.ug_pNaviGenlist; + gli = elm_genlist_first_item_get(genlist); + + while (gli) { + ugListItemData *itemData = (ugListItemData *)elm_object_item_data_get(gli); + ug_mf_retvm_if(itemData == NULL, false, "itemData is NULL"); + if (itemData->ug_bChecked == true) { + UG_TRACE_END; + return true; + } + nli = elm_genlist_item_next_get(gli); + gli = nli; + } + } + UG_TRACE_END; + return false; +} + +/****************************** +** Prototype : ug_parase_path_get +** Description : +** Input : GList *dest_list +** char *path_list +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_util_get_params_path(Eina_List **dest_list, const char *path_list) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(dest_list == NULL, "dest_list is NULL"); + + gchar **result = NULL; + gchar **params = NULL; + result = g_strsplit(path_list, "?", 0); + + for (params = result; *params; params++) { + *dest_list = eina_list_append(*dest_list, strdup(*params)); + } + + g_strfreev(result); + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_util_free_eina_list_data +** Description : Samsung +** Input : Eina_List **list +** mf_ug_eina_list_node_type node_type +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_util_free_eina_list_data(Eina_List **list, mf_ug_eina_list_node_type node_type) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(list == NULL, "list is NULL"); + ug_mf_retm_if(*list == NULL, "*list is NULL"); + + Eina_List *l = NULL; + void *pNode = NULL; + switch (node_type) { + case NODE_TYPE_CHAR: + case NODE_TYPE_PNODE: + EINA_LIST_FOREACH(*list, l, pNode) { + free(pNode); + pNode = NULL; + } + break; + case NODE_TYPE_GSTRING: + EINA_LIST_FOREACH(*list, l, pNode) { + if (pNode != NULL) { + g_string_free(pNode, TRUE); + pNode = NULL; + } + } + break; + default: + break; + } + + eina_list_free(*list); + *list = NULL; + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_util_get_marked_selected_items +** Description : +** Input : GList *list +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_util_get_marked_selected_items(Eina_List *list, Eina_List **select_list) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(select_list == NULL, "select_list is NULL"); + ug_mf_retm_if(list == NULL, "list is NULL"); + + Eina_List *l = NULL; + void *pNode = NULL; + + EINA_LIST_FOREACH(list, l, pNode) { + if (pNode != NULL) { + *select_list = eina_list_append(*select_list, strdup(pNode)); + } + } + UG_TRACE_END; + +} + +/****************************** +** Prototype : __mf_ug_util_get_marked_off_selected_items +** Description : +** Input : void *data +** Evas_Object* content +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_util_get_marked_off_selected_items(void *data, Eina_List **select_list) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + ug_mf_retm_if(select_list == NULL, "selected_list is NULL"); + ug_mf_retm_if(ugd->ug_MainWindow.ug_pNaviGenlist == NULL, "ugd->ug_MainWindow.ug_pNaviGenlist is NULL"); + + + Evas_Object *content = ugd->ug_MainWindow.ug_pNaviGenlist; + Elm_Object_Item *gli = elm_genlist_first_item_get(content); + int radio_id = 1; + Elm_Object_Item *nli = NULL; + + + while (gli) { + + ugListItemData *params = (ugListItemData *)elm_object_item_data_get(gli); + ug_mf_retm_if(params == NULL, "params is NULL"); + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + if (params->ug_pRadioBox) { + if (elm_radio_value_get(ugd->ug_MainWindow.ug_pRadioGroup) == radio_id) { + *select_list = eina_list_append(*select_list, strdup(params->ug_pItemName->str)); + break; + } + radio_id++; + } + } else if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE || + ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + if (params->ug_pCheckBox) { + if (params->ug_bChecked == true) { + *select_list = eina_list_append(*select_list, strdup(params->ug_pItemName->str)); + } + } + } + nli = elm_genlist_item_next_get(gli); + gli = nli; + } + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_util_get_send_result +** Description : +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +char *mf_ug_util_get_send_result(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugData is NULL"); + + char *file_selected = NULL; + Eina_List *selected_list = NULL; + Eina_List *l = NULL; + char *pNode = NULL; + + if (ugd->ug_UiGadget.ug_iMarkedMode == MARKED_ON + && (ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE || ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE)) { + __mf_ug_util_get_marked_selected_items(ugd->ug_UiGadget.ug_pMultiSelectFileList, &selected_list); + } else { + __mf_ug_util_get_marked_off_selected_items(ugd, &selected_list); + } + + EINA_LIST_FOREACH(selected_list, l, pNode) { + if (pNode != NULL) { + if (file_selected == NULL) { + file_selected = g_strconcat(pNode, NULL); + } else { + char *temp = file_selected; +#ifdef UG_OPERATION_SELECT_MODE + if (ugd->ug_UiGadget.ug_bOperationSelectFlag) { + file_selected = g_strconcat(file_selected, OPERATION_SEPERATOR, pNode, NULL); + } else +#endif + file_selected = g_strconcat(file_selected, NORMAL_SEPERATOR, pNode, NULL); + free(temp); + } + } + } + mf_ug_util_free_eina_list_data(&selected_list, NODE_TYPE_CHAR); + UG_TRACE_END; + return file_selected; +} + + +/****************************** +** Prototype : _ug_mf_set_state_as +** Description : +** Input : struct ugmyfiledata* data +** int state +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_util_set_current_state(void *data, int state) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugd->ug_Status.ug_iState = state; + UG_TRACE_END; +} + + +/****************************** +** Prototype : mf_ug_util_get_mmc_state +** Description : +** Input : int* mmc_card +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +int mf_ug_util_get_mmc_state(int *mmc_card) +{ + UG_TRACE_BEGIN; + int data = UG_ERROR_RETURN; + int error_code = MYFILE_ERR_NONE; + + ug_mf_retvm_if(mmc_card == NULL, MYFILE_ERR_SRC_ARG_INVALID, "mmc_card is NULL"); + + *mmc_card = 0; + error_code = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &data); + + if (error_code) { + UG_TRACE_END; + return MYFILE_ERR_GET_VCONF_FAIL; + } + + if (data != VCONFKEY_SYSMAN_MMC_MOUNTED) { + *mmc_card = MMC_OFF; + } else { + *mmc_card = MMC_ON; + } + UG_TRACE_END; + return error_code; +} + +/****************************** +** Prototype : mf_ug_util_create_dir_monitor +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +int mf_ug_util_create_dir_monitor(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugData is NULL"); + + if (ugd->ug_UiGadget.ug_pInotifyPipe) { + ecore_pipe_del(ugd->ug_UiGadget.ug_pInotifyPipe); + ugd->ug_UiGadget.ug_pInotifyPipe = NULL; + } + ugd->ug_UiGadget.ug_pInotifyPipe = ecore_pipe_add(mf_ug_cb_dir_pipe_cb, (const void *)ugd); + UG_TRACE_END; + + return mf_ug_inotify_handle_init_inotify(); +} + + +/****************************** +** Prototype : mf_ug_util_add_dir_watch +** Description : Samsung +** Input : const char *path +** void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +int mf_ug_util_add_dir_watch(const char *path, void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugd is NULL"); + UG_SAFE_FREE_CHAR(ugd->ug_Status.monitor_path); + ugd->ug_Status.monitor_path = g_strdup(path); + return mf_ug_inotify_handle_add_inotify_watch(path, mf_ug_cb_dir_update_cb, data); +} + +int mf_ug_util_remove_dir_watch(void) +{ + return mf_ug_inotify_handle_rm_inotify_watch(); +} + +/****************************** +** Prototype : mf_ug_util_set_mmc_state_cb +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +int mf_ug_util_set_mmc_state_cb(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugd is NULL"); + + int mmc_state = MMC_OFF; + mf_ug_util_get_mmc_state(&mmc_state); + ugd->ug_Status.ug_iMmcFlag = mmc_state; + + UG_TRACE_END; + return vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, mf_ug_cb_mmc_changed_cb, ugd); +} + +/****************************** +** Prototype : mf_ug_util_destory_mmc_state_cb +** Description : Samsung +** Input : None +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_util_destory_mmc_state_cb() +{ + UG_TRACE_BEGIN; + vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, mf_ug_cb_mmc_changed_cb); + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_util_destory_dir_monitor +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_util_destory_dir_monitor(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + if (ugd->ug_UiGadget.ug_pInotifyPipe) { + ecore_pipe_del(ugd->ug_UiGadget.ug_pInotifyPipe); + ugd->ug_UiGadget.ug_pInotifyPipe = NULL; + } + + mf_ug_inotify_handle_finalize_inotify(); + UG_TRACE_END; + + return; +} + + +/****************************** +** Prototype : mf_ug_util_storage_insert_action +** Description : Samsung +** Input : void *data +** char* pItemLabel +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_util_storage_insert_action(void *data, char *pItemLabel) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Elm_Object_Item *pItemPhone = NULL; + ugFsNodeInfo *pNode = NULL; + + if (ugd->ug_Status.ug_iMmcFlag) { + pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo)); + memset(pNode, 0, sizeof(ugFsNodeInfo)); + /*set path */ + snprintf(pNode->path, sizeof(pNode->path), "%s", STORAGE_PARENT); + snprintf(pNode->name, sizeof(pNode->name), "%s", MMC_NAME); + pNode->type = UG_FILE_TYPE_DIR; + ugd->ug_UiGadget.ug_pDirList = eina_list_append(ugd->ug_UiGadget.ug_pDirList, pNode); + mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, pNode, ugd, 0, &ugd->ug_Status.ug_normalitc); + } + + UG_TRACE_END; +} + + + +/****************************** +** Prototype : mf_ug_util_get_file_launch_type +** Description : +** Input : char * path +** Output : UG_MYFILE_LAUNCH_TYPE +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +mf_ug_launch_type mf_ug_util_get_file_launch_type(char *path) +{ + if (path == NULL) { + UG_TRACE_END; + return LAUNCH_TYPE_UNSUPPORT; + } + if (ecore_file_file_get(path) == NULL) { + UG_TRACE_END; + return LAUNCH_TYPE_UNSUPPORT; + } + if (ecore_file_is_dir(path) == 1) { + UG_TRACE_END; + return LAUNCH_TYPE_UNSUPPORT; + } + if (mf_ug_file_attr_is_drm_file(path) == 0) { + mf_ug_drm_file_mime_type drm_file_type = mf_ug_fs_oper_get_drm_type(path); + + if (drm_file_type == MF_UG_DRM_RINGTONE_FILE) { + UG_TRACE_END; + return LAUNCH_TYPE_MUSIC; + } else if (drm_file_type == MF_UG_DRM_IMAGE_FILE) { + UG_TRACE_END; + return LAUNCH_TYPE_IMAGE; + } else if (drm_file_type == MF_UG_DRM_VIDEO_FILE) { + UG_TRACE_END; + return LAUNCH_TYPE_VIDEO; + } else { + UG_TRACE_END; + return LAUNCH_TYPE_UNSUPPORT; + } + } else { + mf_ug_fs_file_type category_t = 0; + mf_ug_file_attr_get_file_category(path, &category_t); + if (category_t == UG_FILE_TYPE_MUSIC || category_t == UG_FILE_TYPE_SOUND || category_t == UG_FILE_TYPE_VOICE) { + UG_TRACE_END; + return LAUNCH_TYPE_MUSIC; + } else if (category_t == UG_FILE_TYPE_IMAGE) { + UG_TRACE_END; + return LAUNCH_TYPE_IMAGE; + } else { + UG_TRACE_END; + return LAUNCH_TYPE_UNSUPPORT; + } + } + UG_TRACE_END; +} + +mf_ug_theme_type mf_ug_util_get_theme(void) +{ + mf_ug_theme_type theme = UG_THEME_INVALID; + char *name; + + char *theme_name = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR); + ug_debug("theme is [%s]", theme_name); + ug_mf_retvm_if(theme_name == NULL, UG_THEME_ERROR, "Failed to get vconf value"); /* file system exceptional handle */ + + name = strrchr(theme_name, '/'); + + if (!name) + name = theme_name; + else + ++name; + + ug_debug("name is [%s]", name); + //SETTING_TRACE("name:%s", name); + /* special theme process.. */ + if (0 == g_strcmp0("tizen-black.edj", name) || 0 == g_strcmp0("tizen-black-hd.edj", name)) { + theme = UG_THEME_NBEAT_BLACK; + } else if (0 == g_strcmp0("tizen.edj", name) || 0 == g_strcmp0("tizen-hd.edj", name) + || 0 == g_strcmp0("blue-hd.edj", name)) { + theme = UG_THEME_NBEAT; + } else { + theme = UG_THEME_ERROR; + } + free(theme_name); + theme_name = NULL; + ug_debug("theme is [%d]", theme); + return theme; +} + + +char *mf_ug_util_upper_folder_name_get(void *data, GString *fullpath) +{ + ug_mf_retvm_if(data == NULL, NULL, "data is NULL"); + ug_mf_retvm_if(fullpath == NULL, NULL, "fullpath is NULL"); + ug_mf_retvm_if(fullpath->str == NULL, NULL, "fullpath is NULL"); + + GString *parent_path = NULL; + GString *gName = NULL; + char *upper_name = NULL; + + parent_path = mf_ug_fm_svc_wrapper_get_file_parent_path(fullpath); + + ug_mf_retvm_if(parent_path == NULL, NULL, "fullpath is NULL"); + ug_mf_retvm_if(parent_path->str == NULL, NULL, "fullpath is NULL"); + + + if (!g_strcmp0(parent_path->str, PHONE_FOLDER)) { + upper_name = g_strdup(MF_UG_LABEL_PHONE); + } else if (!g_strcmp0(parent_path->str, MEMORY_FOLDER)) { + upper_name = g_strdup(MF_UG_LABEL_MMC); + } else { + gName = mf_ug_fm_svc_wapper_get_file_name(parent_path); + UG_GSTRING_CHECK_NULL_GOTO(gName, FAILED_EXIT); + upper_name = g_strdup(gName->str); + } + + UG_CHAR_CHECK_NULL_GOTO(upper_name, FAILED_EXIT); + UG_SAFE_FREE_GSTRING(parent_path); + UG_SAFE_FREE_GSTRING(gName); + return upper_name; + +FAILED_EXIT: + UG_SAFE_FREE_GSTRING(parent_path); + UG_SAFE_FREE_GSTRING(gName); + return NULL; + +} + +void mf_ug_util_sort_the_file_list(void *data) +{ + + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is null"); + ugData *ugd = (ugData *)data; + + int iSortTypeValue = 0; + + iSortTypeValue = ugd->ug_Status.ug_iSortType; + + mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pFilterList, MF_UG_SORT_BY_NAME_A2Z); + mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pDirList, MF_UG_SORT_BY_NAME_A2Z); + +} + +int mf_ug_util_check_disk_space(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(data == NULL, MYFILE_ERR_SRC_ARG_INVALID, "data is null"); + ugData *ugd = (ugData *)data; + + mf_ug_storage_type state = MF_UG_NONE; + unsigned long free_space = 0; + + if (ugd->ug_Status.ug_iMore == UG_MORE_CREATE_FOLDER) { + state = mf_ug_fm_svc_wapper_get_location(ugd->ug_Status.ug_pPath->str); + free_space = mf_ug_fm_svc_wrapper_get_free_space(state); + ug_debug("free size is %lu\n", free_space); + /* + ** in vfat fs type, sector size is 16K. + ** it is to say that the limited size of the free space should be 16K + ** or it will report space used up. + ** check free_space == 0 can make sure at least 16K is free on the disk + ** while every dir takes 4K + */ + if (free_space == 0) { + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, + MF_UG_LABEL_NOT_ENOUGH_SPACE, MF_UG_LABEL_OK, + NULL, NULL, mf_ug_cb_warning_popup_cb, ugd); + return MYFILE_ERR_NO_FREE_SPACE; + } + } + + return MYFILE_ERR_NONE; +} + +void mf_ug_util_operation_alloc_failed(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is null"); + ugData *ugd = (ugData *)data; + + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_MEMORY_NOT_ENOUGH, + NULL, NULL, NULL, (Evas_Smart_Cb) elm_exit, NULL); +} + +long mf_ug_util_character_count_get(const char *original) +{ + ug_mf_retvm_if(original == NULL, 0, "input string is NULL"); + long count = 0; + char *utf8_form = g_locale_to_utf8(original, -1, NULL, NULL, NULL); + if (utf8_form == NULL) + return count; + else { + count = g_utf8_strlen(utf8_form, -1); + free(utf8_form); + ug_debug("utf8 count is %ld", count); + return count; + } +} + +ugFsNodeInfo *mf_ug_util_generate_pnode(const char *path, int file_type) +{ + ug_mf_retvm_if(path == NULL, NULL, "path is NULL"); + ugFsNodeInfo *pNode = NULL; + int error = MYFILE_ERR_NONE; + + pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo)); + if (pNode == NULL) { + return NULL; + } + memset(pNode, 0, sizeof(ugFsNodeInfo)); + char *parent = NULL; + error = mf_ug_file_attr_get_parent_path(path, &parent); + if (error == MYFILE_ERR_NONE) { + snprintf(pNode->path, sizeof(pNode->path), "%s", parent); + snprintf(pNode->name, sizeof(pNode->name), "%s", ecore_file_file_get(path)); + mf_ug_file_attr_get_file_stat(path, &pNode); + if (file_type == UG_FILE_TYPE_DIR) { + pNode->type = file_type; + } else { + mf_ug_file_attr_get_file_category(path, &(pNode->type)); + } + } else { + UG_SAFE_FREE_CHAR(pNode); + } + return pNode; +} + +void mf_util_generate_list(Eina_List **list, const char *path, int file_type) +{ + ug_mf_retm_if(list == NULL, "list is NULL"); + ug_mf_retm_if(path == NULL, "path is NULL"); + + ugFsNodeInfo *pNode = mf_ug_util_generate_pnode(path, file_type); + + if (pNode) + *list = eina_list_append(*list, pNode); +} + +void mf_util_remove_item_from_list_by_location(Eina_List **list, int location) +{ + ug_mf_retm_if(list == NULL, "list is NULL"); + + Eina_List *l = NULL; + ugFsNodeInfo *node = NULL; + + EINA_LIST_FOREACH(*list, l, node) { + if ((ugFsNodeInfo *)node != NULL && strlen(((ugFsNodeInfo *)node)->path) != 0) { + if (mf_ug_fm_svc_wapper_get_location(node->path) == location){ + UG_SAFE_FREE_CHAR(node->ext); + UG_SAFE_FREE_CHAR(node); + *list = eina_list_remove_list(*list, l); + } + } + } +} + +int mf_ug_util_generate_root_view_file_list(Eina_List **list, int storage_state) +{ + UG_TRACE_BEGIN; + + ugFsNodeInfo *pNode = NULL; + pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo)); + memset(pNode, 0, sizeof(ugFsNodeInfo)); + /*set path */ + snprintf(pNode->path, sizeof(pNode->path), "%s", PHONE_PARENT); + snprintf(pNode->name, sizeof(pNode->name), "%s", PHONE_NAME); + pNode->type = UG_FILE_TYPE_DIR; + *list = eina_list_append(*list, pNode); + + if (storage_state == MMC_ON) { + pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo)); + memset(pNode, 0, sizeof(ugFsNodeInfo)); + /*set path */ + snprintf(pNode->path, sizeof(pNode->path), "%s", STORAGE_PARENT); + snprintf(pNode->name, sizeof(pNode->name), "%s", MMC_NAME); + pNode->type = UG_FILE_TYPE_DIR; + *list = eina_list_append(*list, pNode); + } + + return 0; +} + + diff --git a/src/include/mf-ug-cb.h b/src/include/mf-ug-cb.h new file mode 100644 index 0000000..4ea12e2 --- /dev/null +++ b/src/include/mf-ug-cb.h @@ -0,0 +1,65 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_CB_H_ +#define __DEF_MF_UG_CB_H_ + +#include <Elementary.h> +#include <vconf.h> +#include <power.h> +#include "mf-ug-main.h" +#include "mf-ug-util.h" +#include "mf-ug-inotify-handle.h" + +void mf_ug_cb_back_button_cb(void *data, Evas_Object *obj, void *event_info); +void mf_ug_cb_add_button_cb(void *data, Evas_Object *obj, void *event_info); +void mf_ug_cb_goto_myfile_button_cb(void *data, Evas_Object *obj, void *event_info); +void mf_ug_cb_mass_storage_popup_cb(void *data); +void mf_ug_cb_tab_bar_cb(void *data, const char *path); +void mf_ug_cb_ctrl_bar_button_cb(void *data, Evas_Object *obj, void *event_info); +void mf_ug_cb_list_play_cb(ugListItemData *data, Evas_Object *obj, void *event_info); +void mf_ug_cb_select_info_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +void mf_ug_cb_select_info_hide_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +void mf_ug_cb_select_info_timeout_cb(void *data, Evas_Object *obj, void *event_info); +void mf_ug_cb_mmc_changed_cb(keynode_t *key, void *data); +void mf_ug_cb_dir_update_cb(mf_ug_inotify_event event, char *name, void *data); +void mf_ug_cb_dir_pipe_cb(void *data, void *buffer, unsigned int nbyte); +Eina_Bool mf_ug_cb_thumb_timer_cb(void *data); +int mf_ug_cb_set_mass_storage_state_cb(void *data); +void mf_ug_cb_mass_storage_changed_cb(keynode_t *key, void *data); +void mf_ug_cb_upper_button_pressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_upper_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_upper_click_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_home_button_pressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_home_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_home_button_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_sort_by_cb(void *data, Evas_Object *obj, void *event_info); +void mf_ug_search_view_enter_search_routine(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_warning_popup_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_reach_max_len_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source); +void mf_ug_cb_save_cb(void *data, Evas_Object *obj, void *event_info); +void mf_ug_cb_cancel_new_folder_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_create_new_folder(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_lcd_state_changed_cb(power_state_e state, void *user_data); +Eina_Bool mf_ug_cb_popup_del_idler_cb(void *data); +void mf_ug_cb_entry_button_pressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_entry_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_play_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_play_button_pressed_cb(void *data, Evas_Object * obj, void *event_info); +void mf_ug_cb_more_cb(void *data, Evas_Object * obj, void *event_info); + +#endif diff --git a/src/include/mf-ug-conf.h b/src/include/mf-ug-conf.h new file mode 100644 index 0000000..37c7c2d --- /dev/null +++ b/src/include/mf-ug-conf.h @@ -0,0 +1,80 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_CONF_H_ +#define __DEF_MF_UG_CONF_H_ + +#include <Elementary.h> + +#define UGPACKAGE "ug-myfile-efl" +#define UGPKGNAME_MYFILE "org.tizen.myfile" +#define UGLOCALEDIR "/usr/ug/res/locale" + +#ifdef UG_OPERATION_SELECT_MODE +#define UG_OPTION_COUNT 6 +#else +#define UG_OPTION_COUNT 5 +#endif +#define UG_ERROR_RETURN (-1) + +#define UG_SELECT_MODE_MULTI_ALL "MULTI_ALL" +#define UG_SELECT_MODE_SINGLE_ALL "SINGLE_ALL" +#define UG_SELECT_MODE_MULTI_FILE "MULTI_FILE" +#define UG_SELECT_MODE_SINGLE_FILE "SINGLE_FILE" +#define UG_SELECT_MODE_IMPORT "IMPORT" +#define UG_SELECT_MODE_IMPORT_PATH_SELECT "IMPORT_PATH_SELECT" +#define UG_SELECT_MODE_IMPORT_SINGLE "IMPORT_SINGLE" +#define UG_SELECT_MODE_EXPORT "EXPORT" +#define UG_SELECT_MODE_SHORTCUT "SHORTCUT" +#define UG_SELECT_MODE_SAVE "SAVE" + +#define UG_FILE_FILTER_IMAGE "IMAGE" +#define UG_FILE_FILTER_SOUND "SOUND" +#define UG_FILE_FILTER_VIDEO "VIDEO" +#define UG_FILE_FILTER_FLASH "FLASH" +#define UG_FILE_FILTER_FOLDER "FOLDER" +#define UG_FILE_FILTER_IV "IV" +#define UG_FILE_FILTER_IS "IS" +#define UG_FILE_FILTER_VS "VS" +#define UG_FILE_FILTER_ALL "ALL" + +#define UG_DRM_FILTER_ALL "DRM_ALL" +#define UG_DRM_FILTER_NONE "DRM_NONE" +#define UG_DRM_FILTER_WITHOUT_FL "DRM_WITHOUT_FL" + +#define UG_MUSIC_PATH "/opt/usr/media/Sounds and music/Music" +#define UG_RINGTION_PATH "/opt/usr/media/Sounds and music/Ringtones" +#define UG_SETTING_RINGTONE_PATH "/opt/share/settings/Ringtones" +#define UG_SETTING_MSG_ALERTS_PATH "/opt/share/settings/Alerts" +#define UG_SETTING_ALERTS_PATH "/opt/share/settings/Alarms" + +#define MAX_MESSAGE_LEN 1024 +#define ACCUMULATED_DATE 86400 /* 24*60*60 */ + +#define DRM_MESSAGE_LEN 256 +#define UG_LABEL_STRING_LENGTH 128 + +#define UG_TIME_FORMAT "02u:%02u:%02u" +#define UG_TIME_ARGS(t) \ + (t) / (3600), \ + ((t) / 60) % 60, \ + (t) % 60 + +#define _EDJ(o) elm_layout_edje_get(o) + +#define INTERVAL_THUMB_UPDATE 0.5 + +#endif /* __DEF_MYFILE_CONF_H_ */ diff --git a/src/include/mf-ug-dlog.h b/src/include/mf-ug-dlog.h new file mode 100644 index 0000000..50bf513 --- /dev/null +++ b/src/include/mf-ug-dlog.h @@ -0,0 +1,86 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_DLOG_H_ +#define __DEF_MF_UG_DLOG_H_ + +#include <stdio.h> +#include <string.h> + +#define DLOG_ON 1 + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "MYFILE-UG" +#include <dlog.h> + + +#if DLOG_ON +#define LOG_COLOR_RED "\033[31m" +#define LOG_COLOR_RESET "\033[0m" + +#define ug_debug(fmt , args...) LOGD("[%s][%d]debug message from ug-myfile-efl is : "fmt"\n", __func__, __LINE__, ##args) +#define ug_myfile_dlog(fmt , args...) LOGD("[%s][%d]debug message from myfile is : "fmt"\n", __func__, __LINE__, ##args) +#define UG_TRACE_BEGIN do {\ + {\ + LOGD("\n\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \ + __FUNCTION__, (char *)(strrchr(__FILE__, '/') + 1), __LINE__);\ + } \ + } while (0); + +#define UG_TRACE_END do {\ + {\ + LOGD("\n\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \ + __FUNCTION__, (char *)(strrchr(__FILE__, '/') + 1), __LINE__);\ + } \ + } while (0); +#define ug_error(fmt, arg...) LOGE(LOG_COLOR_RED"[ %s : %d] "fmt""LOG_COLOR_RESET, __FUNCTION__, __LINE__,##arg) + + +#else +#define ug_myfile_dlog(fmt , args...) printf("[MYFILE][%40s:%4d] "fmt"\n", __func__, __LINE__, ##args) +#endif +#define ug_mf_debug(fmt , args...) do { (void)0; } while (0) +#define ug_mf_warnig(fmt , args...) do { (void)0; } while (0) +#define ug_mf_error(fmt , args...) do { (void)0; } while (0) +#define UG_MYFILE_TRACE_ERROR(fmt, arg...) do { LOGE("[%s][%d] "fmt"\n", strrchr(__FILE__, '/') + 1, __LINE__, ##arg); } while (0) + +#define ug_mf_retvm_if(expr, val, fmt, arg...) do { \ + if (expr) { \ + UG_MYFILE_TRACE_ERROR(fmt, ##arg); \ + return (val); \ + } \ + } while (0) + +#define ug_mf_retv_if(expr, val) do { \ + if (expr) { \ + return (val); \ + } \ + } while (0) + + +#define ug_mf_retm_if(expr, fmt, arg...) do { \ + if (expr) { \ + UG_MYFILE_TRACE_ERROR(fmt, ##arg); \ + return; \ + } \ + } while (0) + +#define MF_CHECK(expr) ug_mf_retm_if(!(expr),"INVALID PARAM RETURN") + +#endif diff --git a/src/include/mf-ug-fm-svc-wrapper.h b/src/include/mf-ug-fm-svc-wrapper.h new file mode 100644 index 0000000..75d657b --- /dev/null +++ b/src/include/mf-ug-fm-svc-wrapper.h @@ -0,0 +1,45 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_FM_SVC_WRAPPER_H_ +#define __DEF_MF_UG_FM_SVC_WRAPPER_H_ + +#include <glib.h> +#include "mf-ug-main.h" + +#define MF_UG_PATH_INFO_MAX_LENGTH_PORTRAIT 35 + + +/* file information get/set */ +unsigned long mf_ug_fm_svc_wapper_get_file_filter(int file_filter_mode); +int mf_ug_fm_svc_wapper_get_drm_filter(int drm_filter_mode, unsigned long file_filter); +int mf_ug_fm_svc_wapper_get_file_list_by_filter(ugData *data, GString *fullpath, Eina_List **dir_list, Eina_List **filter_list); +bool mf_ug_fm_svc_wapper_is_root_path(void *data); +GString *mf_ug_fm_svc_wapper_get_file_name(GString *path); +char *mf_ug_fm_svc_wapper_get_root_path_by_tab_label(const char *label); +int mf_ug_fm_svc_wapper_get_location(char *fullpath); +gint mf_ug_fm_svc_wapper_get_folder_foldersystem(GString *path, bool *result); +GString *mf_ug_fm_svc_wrapper_get_file_parent_path(GString *fullpath); +char *mf_ug_fm_svc_wapper_path_info_get(char *original_path); +char *mf_ug_fm_svc_path_info_translate(char *path_info, int path_info_max_len); +unsigned long mf_ug_fm_svc_wrapper_get_free_space(int state); +int mf_ug_fm_svc_wrapper_file_auto_rename(void *data, GString *fullpath, int file_name_type, GString **filename); +int mf_ug_fm_svc_wrapper_create_service(void *data, GString *fullpath); +bool mf_ug_fm_svc_wrapper_detect_duplication(GString *to); +int mf_ug_fm_svc_wrapper_create_p(const char *fullpath); +char *mf_ug_fm_svc_wrapper_translate_path(char *original_path); + +#endif diff --git a/src/include/mf-ug-fs-util.h b/src/include/mf-ug-fs-util.h new file mode 100644 index 0000000..0027151 --- /dev/null +++ b/src/include/mf-ug-fs-util.h @@ -0,0 +1,332 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_FS_UTIL_H_ +#define __DEF_MF_UG_FS_UTIL_H_ + +#include <stdio.h> +#include <stdbool.h> +#include <string.h> +#include <stdlib.h> +#include <dirent.h> +#include <sys/stat.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <linux/fs.h> +#include <Eina.h> + +#include <Elementary.h> +#include <drm_client.h> +#include <drm_client_types.h> +#include <media_content.h> + +#include "mf-ug-dlog.h" + + +/* File system related value definition */ +#define FILE_EXT_LEN_MAX 8 +#define MYFILE_DIR_PATH_LEN_MAX 4096 +#define MYFILE_FILE_NAME_LEN_MAX 255 +#define MYFILE_FILE_PATH_LEN_MAX MYFILE_DIR_PATH_LEN_MAX + MYFILE_FILE_NAME_LEN_MAX + + +/* File system related String definition */ +#define PHONE_FOLDER "/opt/usr/media" +#define MEMORY_FOLDER "/opt/storage/sdcard" +#define PHONE_PARENT "/opt/usr" +#define PHONE_NAME "media" +#define STORAGE_PARENT "/opt/storage" +#define MMC_NAME "sdcard" + +#define SOUNDS_FOLDER "/opt/usr/media/Sounds" +#define DEBUG_FOLDER "SLP_debug" + +#define MYFILE_NAME_PATTERN "[\\:;*\"<>|?/]" + +#define IMAGE_AND_VIDEO "Images and videos" +#define SOUND_AND_MUSIC "Sounds and music" +#define DOWNLOADS "Downloads" +#define CAMERA_SHOTS "Camera shots" + + +#define WALLPAPER "Wallpapers" +#define MY_PHOTO_CLIPS "My photo clips" +#define MY_ALBUM "My album" /*/_("IDS_MF_BODY_ACCESS_MORE_MY_ALBUM") */ +#define MY_VIDEO_CLIPS "My video clips" /*/_("IDS_MF_BODY_MY_VIDEO_CLIPS") */ + +#define FM_RADIO "FM Radio" /*/dgettext("sys_string", "IDS_COM_HEADER_FMRADIO") */ +#define MUSIC "Music" /*/_("IDS_MF_BODY_MUSIC") */ +#define RINGTONES "Ringtones" +#define VOICE_RECORDER "Voice recorder" /*/dgettext("sys_string", "IDS_COM_BODY_VOICE_RECORDER") */ +#define ALERTS "Alerts" +#define OTHERS "Others" /*/dgettext("sys_string","IDS_COM_BODY_OTHERS") */ + +/* File system define default folder */ + +/* compile option */ +#define UG_DEBUG_FOLDER_OPTION + +#ifndef UG_ICON_PATH +#define UG_ICON_PATH "/usr/ug/res/images/ug-myfile-efl" +#endif + +#ifndef UG_DEFAULT_ICON +#define UG_DEFAULT_ICON UG_ICON_PATH"/myfile_icon_etc.png" +#endif + +#define UG_ICON_FOLDER UG_ICON_PATH"/myfile_icon_folder.png" +#define UG_ICON_FOLDER_OPEN UG_ICON_PATH"/myfile_icon_folder_open.png" + +#define UG_ICON_IMAGE UG_ICON_PATH"/myfile_icon_images.png" +#define UG_ICON_VIDEO UG_ICON_PATH"/myfile_icon_video.png" +#define UG_ICON_MUSIC UG_ICON_PATH"/myfile_icon_music.png" +#define UG_ICON_SOUND UG_ICON_PATH"/myfile_icon_music.png" +#define UG_ICON_PDF UG_ICON_PATH"/myfile_icon_pdf.png" +#define UG_ICON_DOC UG_ICON_PATH"/myfile_icon_word.png" +#define UG_ICON_PPT UG_ICON_PATH"/myfile_icon_ppt.png" +#define UG_ICON_EXCEL UG_ICON_PATH"/myfile_icon_excel.png" +#define UG_ICON_VOICE UG_ICON_PATH"/myfile_icon_music.png" +#define UG_ICON_HTML UG_ICON_PATH"/myfile_icon_html.png" +#define UG_ICON_FLASH UG_ICON_PATH"/myfile_icon_swf.png" +#define UG_ICON_TXT UG_ICON_PATH"/myfile_icon_text.png" +#define UG_ICON_VCONTACT UG_ICON_PATH"/myfile_icon_svg.png" +#define UG_ICON_VCALENDAR UG_ICON_PATH"/myfile_icon_svg.png" +#define UG_ICON_VNOTE UG_ICON_PATH"/myfile_icon_text.png" +#define UG_ICON_RSS UG_ICON_PATH"/myfile_icon_rss.png" +#define UG_ICON_JAVA UG_ICON_PATH"/myfile_icon_java.png" +#define UG_ICON_MEMORY_SUB UG_ICON_PATH"/myfile_icon_mmc_sub.png" +#define UG_ICON_MUSIC_PLAY_WHITE UG_ICON_PATH"/myfile_icon_control_play.png" +#define UG_ICON_MUSIC_PAUSE_WHITE UG_ICON_PATH"/myfile_icon_control_pause.png" +#define UG_ICON_MUSIC_PLAY_WHITE_PRESS UG_ICON_PATH"/myfile_icon_control_play_press.png" +#define UG_ICON_MUSIC_PAUSE_WHITE_PRESS UG_ICON_PATH"/myfile_icon_control_pause_press.png" +#define UG_ICON_ENTRY_FOLDER UG_ICON_PATH"/myfile_icon_entry_folder.png" +#define UG_ICON_ENTRY_FOLDER_PRESS UG_ICON_PATH"/myfile_icon_entry_folder_press.png" + +#define UG_ICON_BLACK_THEME_UPPER UG_ICON_PATH"/myfile_icon_upper_folder_black_theme.png" +#define UG_ICON_WHITE_THEME_UPPER UG_ICON_PATH"/myfile_icon_upper_folder_white_theme.png" + +#define UG_ICON_PHONE UG_ICON_PATH"/myfile_icon_phone.png" +#define UG_ICON_MEMORY UG_ICON_PATH"/myfile_icon_mmc.png" +#define UG_ICON_VIDEO_PLAY UG_ICON_PATH"/myfile_icon_video_play.png" + +#define UG_ICON_ITEM_PHONE UG_ICON_PATH"/U01_1st_icon_phone.png" +#define UG_ICON_ITEM_MMC UG_ICON_PATH"/U01_1st_icon_memory_card.png" +typedef enum _mf_ug_fs_file_type mf_ug_fs_file_type; + +enum _mf_ug_fs_file_type { + UG_FILE_TYPE_NONE = 0, + UG_FILE_TYPE_DIR, /**< Folder category */ + UG_FILE_TYPE_FILE, /**< File category */ + UG_FILE_TYPE_IMAGE, /**< Image category */ + UG_FILE_TYPE_VIDEO, /**< Video category */ + UG_FILE_TYPE_MUSIC, /**< Music category */ + UG_FILE_TYPE_SOUND, /**< Sound category */ + UG_FILE_TYPE_PDF, /**< Pdf category */ + UG_FILE_TYPE_DOC, /**< Word category */ + UG_FILE_TYPE_PPT, /**< Powerpoint category */ + UG_FILE_TYPE_EXCEL, /**< Excel category */ + UG_FILE_TYPE_VOICE, /**< Voice category */ + UG_FILE_TYPE_HTML, /**< Html category */ + UG_FILE_TYPE_FLASH, /**< Flash category */ + UG_FILE_TYPE_GAME, /**< Game category */ + UG_FILE_TYPE_APP, /**< Application category */ + UG_FILE_TYPE_THEME, /**< Theme category */ + UG_FILE_TYPE_TXT, /**< Txt category */ + UG_FILE_TYPE_VCONTACT, /**< Vcontact category */ + UG_FILE_TYPE_VCALENDAR, /**< Vcalendar category */ + UG_FILE_TYPE_VNOTE, /**< Vnote category */ + UG_FILE_TYPE_VBOOKMARK, /**< Vbookmark category */ + UG_FILE_TYPE_VIDEO_PROJECT, /**< Video editor project category */ + UG_FILE_TYPE_RADIO_RECORDED, /**< radio recorded clips category */ + UG_FILE_TYPE_MOVIE_MAKER, /**< Movie maker project category */ + UG_FILE_TYPE_SVG, /**< Svg category */ + UG_FILE_TYPE_RSS, /**< Rss reader file, *.opml */ + UG_FILE_TYPE_CERTIFICATION, /**< certification file, *.pem */ + UG_FILE_TYPE_JAVA, /**< java file, *.jad, *.jar */ + UG_FILE_TYPE_WGT, /**< wrt , *.wgt, *.wgt */ + UG_FILE_TYPE_DRM, /**< drm file , *.dcf */ + UG_FILE_TYPE_ETC, /**< Other files category */ + UG_FILE_TYPE_MAX +}; + +typedef enum _mf_ug_iter_category_filter_t mf_ug_iter_category_filter_t; +enum _mf_ug_iter_category_filter_t { + UG_FILTER_CATEGORY_NONE = 0x00000000, /**< Default */ + UG_FILTER_CATEGORY_IMAGE = 0x00000001, /**< Image category */ + UG_FILTER_CATEGORY_VIDEO = 0x00000002, /**< Video category */ + UG_FILTER_CATEGORY_SOUND = 0x00000004, /**< Sound category */ + UG_FILTER_CATEGORY_VOICE = 0x00000008, /**< Voice category */ + UG_FILTER_CATEGORY_MUSIC = 0x00000010, /**< Music category */ + UG_FILTER_CATEGORY_HTML = 0x00000020, /**< Html category */ + UG_FILTER_CATEGORY_FLASH = 0x00000040, /**< Flash category */ + UG_FILTER_CATEGORY_GAME = 0x00000080, /**< Game category */ + UG_FILTER_CATEGORY_APP = 0x00000100, /**< Application category */ + UG_FILTER_CATEGORY_THEME = 0x00000200, /**< Theme category */ + UG_FILTER_CATEGORY_DOC = 0x00000400, /**< Word category */ + UG_FILTER_CATEGORY_EXCEL = 0x00000800, /**< Excel category */ + UG_FILTER_CATEGORY_PPT = 0x00001000, /**< Powerpoint category */ + UG_FILTER_CATEGORY_PDF = 0x00002000, /**< Pdf category */ + UG_FILTER_CATEGORY_TXT = 0x00004000, /**< Txt category */ + UG_FILTER_CATEGORY_VCONTACT = 0x00008000, /**< Vcontact category */ + UG_FILTER_CATEGORY_VCALENDAR = 0x00010000, /**< Vcalendar category */ + UG_FILTER_CATEGORY_VNOTE = 0x00020000, /**< Vnote category */ + UG_FILTER_CATEGORY_VBOOKMARK = 0x00040000, /**< Vbookmark category */ + UG_FILTER_CATEGORY_VIDEO_PROJECT = 0x00080000, /**< Video editor project category */ + UG_FILTER_CATEGORY_SVG = 0x00100000, /**< SVG category */ + UG_FILTER_CATEGORY_RSS = 0x00200000, /**< RSS category */ + UG_FILTER_CATEGORY_ETC = 0x00400000, /**< Other files category */ + +}; + +typedef enum _mf_ug_drm_filter mf_ug_drm_filter; +enum _mf_ug_drm_filter { + MF_UG_FILTER_DRM_NONE = 0x00000000, /**< Default */ + MF_UG_FILTER_DRM_ALL = 0x00000001, + MF_UG_FILTER_DRM_WITHOUT_FL = 0x00000002, + MF_UG_FILTER_DRM_IMAGE = 0x00000004, + MF_UG_FILTER_DRM_RINGTONE = 0x00000008, +}; + +typedef enum _mf_ug_storage_type mf_ug_storage_type; +enum _mf_ug_storage_type { + MF_UG_NONE, + MF_UG_PHONE, + MF_UG_MMC, + MF_UG_MAX +}; + + + +typedef enum _mf_ug_drm_file_mime_type mf_ug_drm_file_mime_type; +enum _mf_ug_drm_file_mime_type { + MF_UG_DRM_UNKNOW_FILE = 0, + MF_UG_DRM_IMAGE_FILE, + MF_UG_DRM_RINGTONE_FILE, + MF_UG_DRM_VIDEO_FILE, + MF_UG_DRM_FILE_MAX +}; + +typedef enum _mf_ug_sort_option mf_ug_sort_option; + +enum _mf_ug_sort_option { + MF_UG_SORT_BY_NONE = 0, /**< Sort by default */ + MF_UG_SORT_BY_NAME_A2Z, /**< Sort by file name ascending */ + MF_UG_SORT_BY_SIZE_S2L, /**< Sort by file size ascending */ + MF_UG_SORT_BY_DATE_O2R, /**< Sort by file date ascending */ + MF_UG_SORT_BY_TYPE_A2Z, /**< Sort by file type ascending */ + MF_UG_SORT_BY_NAME_Z2A, /**< Sort by file name descending */ + MF_UG_SORT_BY_SIZE_L2S, /**< Sort by file size descending */ + MF_UG_SORT_BY_DATE_R2O, /**< Sort by file date descending */ + MF_UG_SORT_BY_TYPE_Z2A, /**< Sort by file type descending */ + MF_UG_SORT_BY_MAX +} ; + +typedef enum __MF_UG_SORT_BY_PRIORITY_SEQUENCE MF_UG_SORT_BY_PRIORITY_SEQUENCE; +enum __MF_UG_SORT_BY_PRIORITY_SEQUENCE { + MF_UG_SORT_BY_PRIORITY_TYPE_A2Z, + MF_UG_SORT_BY_PRIORITY_TYPE_Z2A, + MF_UG_SORT_BY_PRIORITY_DATE_O2R, + MF_UG_SORT_BY_PRIORITY_DATE_R2O, + MF_UG_SORT_BY_PRIORITY_SIZE_S2L, + MF_UG_SORT_BY_PRIORITY_SIZE_L2S, +}; + +/* File operation error check options definition */ +#define MF_ERROR_CHECK_SRC_ARG_VALID 0x0001 +#define MF_ERROR_CHECK_SRC_EXIST 0x0002 +#define MF_ERROR_CHECK_SRC_PATH_VALID 0x0004 +#define MF_ERROR_CHECK_DUPLICATED 0x0008 + +/* File system error definition */ +#define MF_ERROR_MASKL16 0xFFFF + +#define MF_ERROR_SET(X) (X & MF_ERROR_MASKL16) + +#define MID_CONTENTS_MGR_ERROR 0 + +#define MYFILE_ERR_NONE (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x00)) /**< No error */ + +/*/1-10*/ +#define MYFILE_ERR_SRC_ARG_INVALID (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x01)) /**< invalid src argument */ +#define MYFILE_ERR_DST_ARG_INVALID (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x02)) /**< invalid dst argument */ +#define MYFILE_ERR_DIR_OPEN_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x03)) /**< exception of dir open*/ +#define MYFILE_ERR_INVALID_DIR_PATH (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x04)) /**< exception of invalid dir path */ +#define MYFILE_ERR_INVALID_FILE_NAME (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x05)) /**< exception of invalid file name */ +#define MYFILE_ERR_INVALID_FILE_PATH (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x06)) /**< exception of invalid file path */ +#define MYFILE_ERR_DRM_PERMISSION_DENY (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x07)) /**< can't copy/move drm file because of permission */ +#define MYFILE_ERR_SRC_NOT_EXIST (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x08)) /**< source not found */ +#define MYFILE_ERR_STORAGE_TYPE_ERROR (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x09)) /**< storage type error */ +#define MYFILE_ERR_EXT_GET_ERROR (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x0a)) /**< get ext type failed */ +#define MYFILE_ERR_GET_STAT_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x0b)) /**< get stat failed */ +#define MYFILE_ERR_GET_CATEGORY_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x0c)) /**< get file category failed */ +#define MYFILE_ERR_GET_VCONF_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x0d)) /**< get vconf value failed */ +#define MYFILE_ERR_INVALID_ARG (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x0e)) /**< argument of function is not valid */ +#define MYFILE_ERR_ALLOCATE_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x0f)) +#define MYFILE_ERR_LIST_PLAY_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x10)) +#define MYFILE_ERR_INVALID_PATH (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x11)) /**< invalid path string */ +#define MYFILE_ERR_GET_THUMBNAIL_FAILED (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x12)) /**<get thumbnail failed */ +#define MYFILE_ERR_UNKNOW_ERROR (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x13)) /**<unknow error */ +#define MYFILE_ERR_NO_FREE_SPACE (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x14)) /**< get free space failed */ +#define MYFILE_ERR_DUPLICATED_NAME (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x15)) /**< exception of duplicated dir name*/ +#define MYFILE_ERR_ALLOCATE_MEMORY_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x16)) /**< exception of memory allocation */ +#define MYFILE_ERR_GET_LOGIC_PATH_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x17)) /**< get logical path failed */ +#define MYFILE_ERR_GENERATE_NAME_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x18)) /**< generate name failed */ +#define MYFILE_ERR_DIR_CREATE_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x19)) /**< exception of create dir */ +#define MYFILE_ERR_GET_PARENT_PATH_FAIL (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x1a)) /**< get parent path failed */ +#define MYFILE_ERR_EXCEED_MAX_LENGTH (MID_CONTENTS_MGR_ERROR - MF_ERROR_SET(0x1b)) /**< length of file/dir path exceeds maximum length*/ + +/* File system related callback definition */ + +typedef struct _ugFsNodeInfo ugFsNodeInfo; +struct _ugFsNodeInfo { + char path[MYFILE_DIR_PATH_LEN_MAX]; + char name[MYFILE_FILE_NAME_LEN_MAX]; + time_t date; + mf_ug_fs_file_type type; + char *ext; + unsigned int size; +}; + + +/********** File Attribute Related **********/ +int mf_ug_file_attr_get_file_stat(const char *filename, ugFsNodeInfo ** node); + +int mf_ug_file_attr_get_file_category(const char *filepath, mf_ug_fs_file_type * category); +int mf_ug_file_attr_is_dir(const char *filepath); +int mf_ug_file_attr_get_store_type_by_full(const char *filepath, mf_ug_storage_type * store_type); +int mf_ug_file_attr_is_drm_file(const char *file_fullpath); +int mf_ug_file_attr_get_file_ext(const char *filepath, char **file_ext); +int mf_ug_file_attr_is_right_dir_path(const char *dir_path); +int mf_ug_file_attr_is_right_file_path(const char *file_path); +int mf_ug_file_attr_is_duplicated_name(const char *dir, const char *name); +int mf_ug_file_attr_get_logical_path_by_full(const char *full_path, char **path); +int mf_ug_file_attr_is_valid_name(const char *filename); + +/********** File Operation Related **********/ +int mf_ug_fs_oper_read_dir(const char *path, Eina_List **dir_list, Eina_List **file_list); +int mf_ug_fs_oper_list_filter(Eina_List *in_list, Eina_List **out_list, int option, int drm_opt); +int mf_ug_fs_oper_list_filter_by_extension(Eina_List *in_list, Eina_List **out_list, char *ext); +int mf_ug_file_attr_get_file_icon(const char *file_path, int *error_code, char **thumbnail); +mf_ug_drm_file_mime_type mf_ug_fs_oper_get_drm_type(char *path); +int mf_ug_file_attr_is_system_dir(char *fullpath, bool * result); +mf_ug_fs_file_type mf_ug_file_attr_get_file_type_by_mime(const char *file_path); +int mf_ug_fs_oper_create_dir(const char *dir); +void mf_ug_fs_oper_sort_list(Eina_List **list, int sort_opt); +int mf_ug_fs_oper_drm_is_action_allowed(const char *path, drm_action_type_e action, drm_setas_category_e category); +bool mf_ug_fs_oper_drm_is_valid(const char *path, drm_permission_type_e perm_type); + +#endif diff --git a/src/include/mf-ug-inotify-handle.h b/src/include/mf-ug-inotify-handle.h new file mode 100644 index 0000000..8c85604 --- /dev/null +++ b/src/include/mf-ug-inotify-handle.h @@ -0,0 +1,40 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_INOTIFY_HANDLE_H +#define __DEF_MF_UG_INOTIFY_HANDLE_H + +typedef enum _mf_ug_inotify_event mf_ug_inotify_event; +enum _mf_ug_inotify_event { + UG_MF_INOTI_NONE = 0, + UG_MF_INOTI_CREATE, + UG_MF_INOTI_DELETE, + UG_MF_INOTI_MODIFY, + UG_MF_INOTI_MOVE_OUT, + UG_MF_INOTI_MOVE_IN, + UG_MF_INOTI_DELETE_SELF, + UG_MF_INOTI_MOVE_SELF, + UG_MF_INOTI_MAX, +}; + +typedef void (*mf_ug_inotify_cb) (mf_ug_inotify_event event, char *name, void *data); + +int mf_ug_inotify_handle_init_inotify(void); +int mf_ug_inotify_handle_add_inotify_watch(const char *path, mf_ug_inotify_cb callback, void *user_data); +int mf_ug_inotify_handle_rm_inotify_watch(void); +void mf_ug_inotify_handle_finalize_inotify(void); + +#endif diff --git a/src/include/mf-ug-list-play.h b/src/include/mf-ug-list-play.h new file mode 100644 index 0000000..493785d --- /dev/null +++ b/src/include/mf-ug-list-play.h @@ -0,0 +1,73 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MF_UG_LIST_PLAY_H +#define __MF_UG_LIST_PLAY_H + +#include <player.h> +#include <sound_manager.h> + +typedef enum { + MF_PLAYER_CB_TYPE_STARTED, + MF_PLAYER_CB_TYPE_PAUSED, + MF_PLAYER_CB_TYPE_COMPLETED, + MF_PLAYER_CB_TYPE_INTURRUPTED, + MF_PLAYER_CB_TYPE_ERROR, + MF_PLAYER_CB_TYPE_BUFFERING, + MF_PLAYER_CB_TYPE_PREPARE, + MF_PLAYER_CB_TYPE_NUM, +} mf_player_cb_type; + +typedef enum { + MF_VOLUME_NONE, + MF_VOLUME_ALERT, + MF_VOLUME_NOTIFICATION, + MF_VOLUME_RINGTONE, + MF_VOLUME_NUM +} mf_player_volume_type; + + +typedef struct __mf_player_cbs mf_player_cbs; +struct __mf_player_cbs{ + /* player callbacks */ + /*note: start callback and paused callback for player have been removed*/ + /*player_started_cb started_cb;*/ + /*player_paused_cb paused_cb;*/ + player_completed_cb completed_cb; + player_interrupted_cb interrupted_cb; + player_error_cb error_cb; + player_buffering_cb buffering_cb; + player_prepared_cb prepare_cb; + + /* callback user data */ + void *user_data[MF_PLAYER_CB_TYPE_NUM]; +}; + + +typedef struct { + mf_player_cb_type cb_type; + + union { + player_interrupted_code_e interrupted_code; + int error_code; + int percent; + } param; +} mf_player_cb_extra_data; + +void mf_ug_player_vol_set(const char *path); +void mf_ug_list_play_pause(void *data); + +#endif diff --git a/src/include/mf-ug-main.h b/src/include/mf-ug-main.h new file mode 100644 index 0000000..4414940 --- /dev/null +++ b/src/include/mf-ug-main.h @@ -0,0 +1,203 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_MAIN_H_ +#define __DEF_MF_UG_MAIN_H_ + +#define __ARM__ + +#include <Elementary.h> +#include <Ethumb.h> +#include <glib.h> +#include <Ecore.h> +#include <glib-object.h> +#include <ui-gadget-module.h> +#include <ui-gadget.h> +#include <app.h> +#include <stdbool.h> +#include <drm_client.h> +#include <drm_client_types.h> +#include <media_content.h> +#include <player.h> + + + +#include "mf-ug-dlog.h" +#include "../../data/ug_edc_common.h" +#include "mf-ug-conf.h" +#include "mf-ug-search.h" +/*********** Global Definitions ***********/ +#ifndef UG_MODULE_API +#define UG_MODULE_API __attribute__ ((visibility("default"))) +#endif + +typedef void (*ugCallBack) (void *, Evas_Object *, void *); + +typedef struct _ugNaviBar ugNaviBar; + +struct _ugNaviBar { + char *ug_pNaviLabel; + char *ug_pNaviTitle; + char *ug_pCurrentPath; + bool ug_bNaviFlagInUse; +}; + + +typedef struct _ugMainWindow ugMainWindow; +struct _ugMainWindow { + Evas_Object *ug_pWindow; + Evas_Object *ug_pBackGround; + Evas_Object *ug_pTabBackGround; + Evas_Object *ug_pMainLayout; + Evas_Object *ug_pNormalPopup; + Evas_Object *ug_pSearchLabel; + Evas_Object *ug_pSelectInfoLayout; + Evas_Object *ug_pRadioGroup; + Evas_Object *ug_pTabBar; + + Evas_Object *ug_pNaviBar; + Evas_Object *ug_pNaviLayout; + Evas_Object *ug_pNaviGenlist; + Evas_Object *ug_pNaviCtrlBar; + Evas_Object *ug_pNaviBox; + + Evas_Object *ug_pEditField; + Evas_Object *ug_pEntry; + Evas_Object *ug_pSelectAllLayout; + Evas_Object *ug_pSelectAllCheckBox; + Evas_Object *ug_pSearchPopup; + Evas_Object *ug_pContextPopup; + Evas_Object *ug_pNewFolderPopup; + + Elm_Object_Item *ug_pPreNaviItem; + Elm_Object_Item *ug_pNaviItem; + Eina_List *ug_pNaviBarList; + Evas_Object *ug_ctrlBar; + +}; + + +typedef struct _ugStatus ugStatus; +struct _ugStatus { + GString *ug_pPath; + int ug_iState; + int ug_iSortType; + int ug_iRadioOn; + int ug_iMmcFlag; + int ug_iCtrlBarType; + int ug_iRadioValue; /** current the radio box selected item value **/ + int ug_iSelectedSortType; + int ug_iMore; + int ug_iCheckedCount; + int ug_iTotalCount; + int ug_iViewType; + + bool ug_bAudioPlayFlag; + bool ug_bInstallFlag; + bool ug_bSettingEntry; + bool ug_bInSettingView; + bool ug_bNoContentFlag; + bool ug_bCancelDisableFlag; + bool ug_b_NaviPushFlag; + bool ug_bRingtoneSet; + Eina_Bool ug_bSelectAllChecked; + int ug_iThemeType; + char *ug_pUpper_folder; + char *ug_pEntryPath; + char *monitor_path; + bool ug_bUpperFlag; + Elm_Genlist_Item_Class ug_itc; + Elm_Genlist_Item_Class ug_topitc; + Elm_Genlist_Item_Class ug_separtor_no_bottom_line_itc; + Elm_Genlist_Item_Class ug_separtor_with_bottom_line_itc; + Elm_Genlist_Item_Class ug_normalitc; + Elm_Genlist_Item_Class ug_editfileditc; + Elm_Genlist_Item_Class ug_editfiledUpperSeperatoritc; + Elm_Genlist_Item_Class ug_editfiledBottomSeperatoritc; + Elm_Genlist_Item_Class ug_newfolderitec; + Elm_Genlist_Item_Class ug_pathinfoitec; +#ifdef UG_THUMB_REAL_TIME_UPDATE + Ecore_Timer *ug_pThumbUpdateTimer; +#endif + Evas_Object *ug_pRadioGroup; + mf_search_handle search_handler; + + Eina_List *search_result_list; + Ecore_Idler *search_idler; + Ecore_Idler *popup_del_idler; + Ecore_Idler *popup_create_idler; + Ecore_Idler *msg_finish_idler; + Ecore_Timer *pPopupTimer; + Ecore_Timer *play_timer; +}; + + +typedef struct _ugUiGadget ugUiGadget; +struct _ugUiGadget { + int ug_iFilterMode; + int ug_iSelectMode; + int ug_iMarkedMode; + int ug_iDrmFilterMode; + int ug_iImportMode; +#ifdef UG_OPERATION_SELECT_MODE + int ug_bOperationSelectFlag; +#endif + unsigned long ug_iFileFilter; + int ug_iDrmFilter; + char *ug_pExtension; + Eina_List *ug_pDirList; + Eina_List *ug_pFilterList; + Eina_List *ug_pMultiSelectFileList; + Ecore_Pipe *ug_pInotifyPipe; + Ecore_Pipe *ug_pSyncPipe; +}; + +typedef struct _ugDrmInfo ugDrmInfo; +struct _ugDrmInfo { + int version; + int constraint_type; + char validity[DRM_MESSAGE_LEN]; + char description[DRM_MESSAGE_LEN]; + bool forward; +}; + + +typedef struct _ugListPlay ugListPlay; +struct _ugListPlay { + char *ug_pPlayFilePath; + player_h ug_Player; + int ug_iPlayState; + bool ug_bDrmContentCanPlay; + bool ug_bDrmconsumption; + ugDrmInfo ug_DrmInfo; + Ecore_Idler *playing_err_idler; +}; + + +typedef struct _ugData ugData; +struct _ugData { + ugMainWindow ug_MainWindow; + ugStatus ug_Status; + ugUiGadget ug_UiGadget; + ugListPlay ug_ListPlay; + ui_gadget_h ug; + Ecore_Event_Handler *key_event_handler; +}; +Evas_Object *mf_ug_main_tab_layout_create(Evas_Object *parent); +Evas_Object *mf_ug_main_create_bg(Evas_Object *win); + + +#endif /* __DEF_MYFILE_H_ */ diff --git a/src/include/mf-ug-resource.h b/src/include/mf-ug-resource.h new file mode 100644 index 0000000..2b39fe9 --- /dev/null +++ b/src/include/mf-ug-resource.h @@ -0,0 +1,84 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_RESOURCE_H_ +#define __DEF_MF_UG_RESOURCE_H_ + +#include "../../data/ug_edc_common.h" +#include "mf-ug-conf.h" + +/************* system strings ************/ +#define MF_UG_LABEL_UNSUPPORT_FILE_TYPE dgettext("sys_string", "IDS_COM_BODY_UNSUPPORTED_FILE_TYPE") +#define MF_UG_LABEL_CONNECT_FAILED dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED") +#define MF_UG_LABEL_PHONE dgettext("sys_string", "IDS_COM_BODY_PHONE") +#define MF_UG_LABEL_SELECTED dgettext("sys_string", "IDS_COM_BODY_SELECTED") +#define MF_UG_LABEL_MMC dgettext("sys_string", "IDS_COM_BODY_MEMORY_CARD") +#define MF_UG_LABEL_UNKNOWN dgettext("sys_string", "IDS_COM_BODY_UNKNOWN") +#define MF_UG_LABEL_SET dgettext("sys_string", "IDS_COM_SK_SET") +#define MF_UG_LABEL_ATTACH dgettext("sys_string", "IDS_COM_POP_ATTACH") +#define MF_UG_LABEL_CANCEL dgettext("sys_string", "IDS_COM_SK_CANCEL") +#define MF_UG_LABEL_NO_FILES dgettext("sys_string", "IDS_COM_BODY_NO_FILES") +#define MF_UG_LABEL_MYFILES dgettext("sys_string", "IDS_COM_BODY_MY_FILES") +#define MF_UG_LABEL_OK dgettext("sys_string", "IDS_COM_SK_OK") +#define MF_UG_LABEL_DATE dgettext("sys_string", "IDS_COM_POP_DATE") +#define MF_UG_LABEL_SIZE dgettext("sys_string", "IDS_COM_POP_SIZE") +#define MF_UG_LABEL_TYPE dgettext("sys_string", "IDS_COM_POP_TYPE") +#define MF_UG_LABEL_NAME dgettext("sys_string", "IDS_COM_POP_NAME") +#define MF_UG_LABEL_SEARCH dgettext("sys_string", "IDS_COM_BODY_SEARCH") +#define MF_UG_LABEL_CANCEL dgettext("sys_string", "IDS_COM_SK_CANCEL") +#define MF_UG_LABEL_NO_RESULT dgettext("sys_string", "IDS_COM_BODY_NO_SEARCH_RESULTS") +#define MF_UG_LABEL_IMPORT dgettext("sys_string", "IDS_COM_OPT_IMPORT") +#define MF_UG_LABEL_CREATE dgettext("sys_string", "IDS_COM_BODY_CREATE_FOLDER") +#define MF_UG_LABEL_NOT_ENOUGH_SPACE dgettext("sys_string", "IDS_COM_POP_NOT_ENOUGH_MEMORY") +#define MF_UG_LABEL_FOLDER dgettext("sys_string", "IDS_COM_POP_FOLDER") +#define MF_UG_LABEL_SAVE dgettext("sys_string", "IDS_COM_SK_SAVE") +#define MF_UG_LABEL_YES dgettext("sys_string", "IDS_COM_SK_YES") +#define MF_UG_LABEL_NO dgettext("sys_string", "IDS_COM_SK_NO") +#define MF_UG_LABEL_SELECT_ALL dgettext("sys_string", "IDS_COM_BODY_SELECT_ALL") +#define MF_UG_LABEL_MAX_CHARACTER_REACHED dgettext("sys_string", "IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED") +#define MF_UG_LABEL_ALARM dgettext("sys_string", "IDS_COM_BODY_ALARM") +#define MF_UG_LABEL_DONE dgettext("sys_string", "IDS_COM_POP_DONE") + +/************ myfile strings *************/ +#define MF_UG_LABEL_MEMORY_NOT_ENOUGH dgettext(UGPACKAGE, "IDS_MF_POP_NOT_ENOUGH_HEAP_MEMORY") +#define MF_UG_LABEL_ASCENDING dgettext(UGPACKAGE, "IDS_MF_POP_ASCENDING") +#define MF_UG_LABEL_DESCENDING dgettext(UGPACKAGE, "IDS_MF_POP_DESCENDING") +#define MF_UG_LABEL_EXPORT dgettext(UGPACKAGE, "IDS_MF_BUTTON_EXPORT_HERE") +#define MF_UG_LABEL_HOME dgettext(UGPACKAGE, "IDS_MF_BUTTON_HOME") +#define MF_UG_LABEL_UPPER dgettext(UGPACKAGE, "IDS_MF_TAB_UP") +#define MF_UG_LABEL_LIST_BY dgettext(UGPACKAGE, "IDS_MF_OPT_LIST_BY") +#define MF_UG_LABEL_GO_TO_MYFILES dgettext(UGPACKAGE, "IDS_MF_BUTTON_GO_TO_MY_FILES") +#define MF_UG_LABEL_RINGTONES dgettext(UGPACKAGE, "IDS_MF_BODY_RINGTONES") +#define MF_UG_LABEL_DRM_UNABLE_SET dgettext(UGPACKAGE, "IDS_MF_POP_UNABLE_TO_SET_DRM_PROTECTED_CONTENT_AS_RINGTONE_OR_NOTIFICATION_ALERT") + +/************no design id **************/ +#define MF_UG_LABEL_OTHER_MUSIC "Other music" +#define MF_UG_LABEL_UNABLE_TO_PLAY_DURING_CALL "Unable to play during call" +#define MF_UG_LABEL_UNABLE_TO_PLAY_ERROR_OCCURRED "Unable to play. Error occurred" +#define MF_UG_LABEL_SAVE_HERE "Set here" +#define MF_UG_LABEL_GET_NAME_FAILED "Get name failed. try again!" +#define MF_UG_LABEL_NAME_INVALID ("Invalid name, retry!") +#define MF_UG_LABEL_ILLEGAL_CHAR "Name contains illegal character, Retry!" +#define MF_UG_LABEL_PATH_REACH_MAX_LEN "Full path length should be less than 4096,Retry!" +#define MF_UG_LABEL_DUP_NAME "Duplicated name, retry!" +#define MF_UG_LABEL_OPER_READ_ONLY "Operation failed: Read Only Area" +#define MF_UG_LABEL_CREATE_DIR_FAILED "Create Directory failed" +#define MF_UG_LABEL_EMPTY_FOLDER_NAME "Folder name can't be empty, Retry!" +#define MF_UG_LABEL_NO_MEM_CARD "No memory card inserted" + + +#endif + diff --git a/src/include/mf-ug-search-internal.h b/src/include/mf-ug-search-internal.h new file mode 100644 index 0000000..c3a6aa3 --- /dev/null +++ b/src/include/mf-ug-search-internal.h @@ -0,0 +1,68 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MF_SEARCH_INTERNAL_H_ +#define _MF_SEARCH_INTERNAL_H_ + +#include "mf-ug-search.h" + +#ifdef MS_USE_DEF_LOG + +#include "mf-ug-dlog.h" + +#define ms_debug(fmt , args...) ug_debug +#define ms_info(fmt , args...) ug_debug +#define ms_warn(fmt , args...) ug_debug +#define ms_error(fmt , args...) ug_debug +#define ms_assert(fmt , args...) ug_debug + +#else + + +#ifdef DEBUG_ON +#define ms_debug(fmt , args...) do { printf("[%10s:%4d][D] "fmt"\n", __func__, __LINE__, ##args); } while (0) +#define ms_info(fmt , args...) do { printf("[%10s:%4d][I] "fmt"\n", __func__, __LINE__, ##args); } while (0) +#define ms_warn(fmt , args...) do { printf("[%10s:%4d][W] "fmt"\n", __func__, __LINE__, ##args); } while (0) +#define ms_error(fmt , args...) do { printf("[%10s:%4d][E] "fmt"\n", __func__, __LINE__, ##args); } while (0) +#define ms_assert(fmt , args...) do { printf("[%10s:%4d][A] "fmt"\n", __func__, __LINE__, ##args); } while (0) +#else +#define ms_debug(fmt , args...) do { (void)0; } while (0) +#define ms_info(fmt , args...) do { (void)0; } while (0) +#define ms_warn(fmt , args...) do { (void)0; } while (0) +#define ms_error(fmt , args...) do { (void)0; } while (0) +#define ms_assert(fmt , args...) do { (void)0; } while (0) +#endif +#endif + +/** + * Enumerations of search state + **/ + +int _mf_ug_search_init(ms_handle_t **handle); +int _mf_ug_search_start(ms_handle_t *handle, const char **root_path, unsigned int path_num, const char *needle, mf_search_option option, + void *user_data); +int _mf_ug_search_stop(ms_handle_t *handle); +void _mf_ug_search_finalize(ms_handle_t **handle); + +/*+++++++++++++++++++++++++ UTIL APIs ++++++++++++++++++++++++++++++ */ + +gchar *_mf_ug_search_result_dir_get(mf_search_result_t *result); +gchar *_mf_ug_search_result_file_get(mf_search_result_t *result); +gboolean _mf_ug_search_result_is_end(mf_search_result_t *result); +gchar *_mf_ug_search_result_current_dir_get(mf_search_result_t *result); +guint _mf_ug_search_result_total_count_get(mf_search_result_t *result); + +#endif diff --git a/src/include/mf-ug-search.h b/src/include/mf-ug-search.h new file mode 100644 index 0000000..037fef9 --- /dev/null +++ b/src/include/mf-ug-search.h @@ -0,0 +1,211 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MF_SEARCH_H_ +#define _MF_SEARCH_H_ + +/*+++++++++++++++++++++++ Definitions and Types +++++++++++++++++++++++*/ + +/** + * Handle type for mf_search + **/ +typedef unsigned int mf_search_handle; + +/** + * Handle type for search result + **/ +typedef unsigned int mf_search_result; + +/** + * Enumerations of search option + **/ + +typedef enum _mf_search_option mf_search_option; + +enum _mf_search_option { + MF_SEARCH_OPT_NONE = (1 << 0), + MF_SEARCH_OPT_HIDDEN = (1 << 1), + MF_SEARCH_OPT_DIR = (1 << 2), + MF_SEARCH_OPT_FILE = (1 << 3), + MF_SEARCH_OPT_EXT = (1 << 4), +}; + +typedef enum _mf_search_pipe_msg_type mf_search_pipe_msg_type; +enum _mf_search_pipe_msg_type { + MF_SEARCH_PIPE_MSG_NONE = 0, + MF_SEARCH_PIPE_MSG_ROOT_CHANGE, + MF_SEARCH_PIPE_MSG_RESULT_REPORT, + MF_SEARCH_PIPE_MSG_FINISHED, + MF_SEARCH_PIPE_MSG_MAX, +}; + +typedef enum _mf_search_state mf_search_state; +enum _mf_search_state { + MF_SEARCH_STATE_NONE = 0, + MF_SEARCH_STATE_INIT, + MF_SEARCH_STATE_SEARCH, + MF_SEARCH_STATE_MAX, +}; + +typedef struct _mf_search_result_t mf_search_result_t; +struct _mf_search_result_t { + GList *dir_list; + GList *file_list; + gchar *current_dir; + guint total_count; + gboolean is_end; +}; + +typedef struct _ms_args_t ms_args_t; +struct _ms_args_t { + GList *root_path; + gchar *needle; + mf_search_option option; + void *user_data; +} ; + +typedef struct _ms_handle_t ms_handle_t; +struct _ms_handle_t { + mf_search_state state; + GMutex *cmd_lock; + ms_args_t *args; + + GThread *thread_h; + GMutex *thread_mutex; + /* critical section */ + gboolean is_stop; + mf_search_result_t *result; + /* critical section */ +}; + +typedef struct _mf_search_pipe_msg mf_search_pipe_msg; +struct _mf_search_pipe_msg { + mf_search_pipe_msg_type mf_sp_msg_type; + void *report_result; + gchar *current_path; +}; + +/** + * mf_Search_Cb: + * @result: the handle of result, use util APIs to get detail result with this handle. + * @user_data: user data specified when installing the function, in mf_ug_search_start() + **/ +typedef void (*mf_Search_Cb) (mf_search_pipe_msg_type type, mf_search_result result, void *user_data); + +/** + * Definition of error code + **/ +#define MF_SEARCH_ERROR_NONE (0) +#define MF_SEARCH_ERROR_INTERNAL (-(1)) /* Internal error */ +#define MF_SEARCH_ERROR_INVAL_P (-(2)) /* Invalid params */ +#define MF_SEARCH_ERROR_INVAL_S (-(3)) /* Invalid status */ +#define MF_SEARCH_ERROR_ALLOC (-(4)) /* Memory allocation failed */ +#define MF_SEARCH_ERROR_FS (-(5)) /* File system error */ + +/*+++++++++++++++++++++++ APIs +++++++++++++++++++++++*/ + +/** + * mf_ug_search_init: + * @handle: the handle of mf_search + * Creates a new @handle for search. If success, + * #mf_search state is changed from MF_SEARCH_STATE_NONE to MF_SEARCH_STATE_INIT + * Return value: This function returns zero on success, or negative value. + **/ +int mf_ug_search_init(mf_search_handle *handle); + +/** + * mf_ug_search_start: + * @handle: the handle of mf_search + * @root_path: array of the root path for search + * @path_num: the number of the root path for search + * @needle: the key string for search + * @option : bitfield of mf_search_option flags + * @user_data: user data + * Start searching in given @root_path with @needle, + * every each idle time, @callback will be called with #mf_search_result_t and @user_data. + * If success, #mf_search state is changed from MF_SEARCH_STATE_INIT to MF_SEARCH_STATE_SEARCH + * Return value: This function returns zero on success, or negative value. + **/ +int mf_ug_search_start(mf_search_handle handle, const char **root_path, unsigned int path_num, const char *needle, mf_search_option option, + void *user_data); +/** + * mf_ug_search_stop: + * @handle: the handle of mf_search + * Stops search + * If success, #mf_search state is changed from MF_SEARCH_STATE_SEARCH to MF_SEARCH_STATE_INIT + * Return value: This function returns zero on success, or negative value. + **/ +int mf_ug_search_stop(mf_search_handle handle); + +/** + * mf_ug_search_stop: + * @handle: the handle of mf_search + * Finalizes search @handle + * #mf_search state is changed from MF_SEARCH_STATE_INIT to MF_SEARCH_STATE_NONE + **/ +void mf_ug_search_finalize(mf_search_handle *handle); + + +/*+++++++++++++++++++++++ UTIL APIs +++++++++++++++++++++++*/ + +/** + * mf_ug_search_result_dir_get: + * @result: the handle of search result + * Gets one of directory name in given search @result + * Return value: a directory name which is a newly-allocated string that must be freed after use + * or NULL if no more result for directory. + **/ +char *mf_ug_search_result_dir_get(mf_search_result_t *result); + +/** + * mf_ug_search_result_file_get: + * @result: the handle of search result + * Gets one of file name given search @result + * Return value: a file name which is a newly-allocated string that must be freed after use + * or NULL if no more result for directory. + **/ +char *mf_ug_search_result_file_get(mf_search_result_t *result); + +/** + * mf_ug_search_result_current_dir_get: + * @result: the handle of search result + * Gets current searching directory name in given search @result + * Return value: current searching directory name which is a newly-allocated string that must be freed after use + * or NULL if fail to get current searching directory name. + **/ +char *mf_ug_search_result_current_dir_get(mf_search_result_t *result); + +/** + * mf_ug_search_result_is_end: + * @result: the handle of search result + * @is_end : If @result is last result handle, set it to a non-zero value, if not set it to zero. + * Tests if given search @result is the last one or not + * Return value: This function returns zero on success, or negative value. + **/ +int mf_ug_search_result_is_end(mf_search_result_t *result, int *is_end); + +/** + * mf_ug_search_result_total_count_get: + * @result: the handle of search result + * @count: the items(which is explored directories and files) count. + * Gets current explored items(this is not result count) + * Return value: This function returns zero on success, or negative value. + **/ +int mf_ug_search_result_total_count_get(mf_search_result_t *result, unsigned int *count); + +void mf_ug_search_view_item_append(void *data, void *user_data); + +#endif diff --git a/src/include/mf-ug-util.h b/src/include/mf-ug-util.h new file mode 100644 index 0000000..91d258a --- /dev/null +++ b/src/include/mf-ug-util.h @@ -0,0 +1,283 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_UTIL_H_ +#define __DEF_MF_UG_UTIL_H_ + +#include <Elementary.h> +#include <stdbool.h> +#include <glib.h> + +#include "mf-ug-main.h" + +#define UG_SAFE_FREE_CHAR(x) do {\ + if ((x) != NULL) {\ + free(x); \ + x = NULL;\ + } \ + } while (0) + +#define UG_SAFE_FREE_GSTRING(x) do {\ + if ((x) != NULL) {\ + g_string_free(x, TRUE); \ + x = NULL;\ + } \ + } while (0) + +#define UG_CHAR_CHECK_NULL_GOTO(arg, dest) do {\ + if ((arg) == NULL) {\ + goto dest;\ + } \ + } while (0) + +#define UG_GSTRING_CHECK_NULL_GOTO(arg, dest) do {\ + if ((arg) == NULL || (arg->str) == NULL) {\ + goto dest;\ + } \ + } while (0) + + +#define UG_SAFE_DEL_NAVI_ITEM(x) do {\ + if ((x) != NULL) {\ + elm_object_item_del(x); \ + x = NULL;\ + } \ + } while (0) + + +#define UG_SAFE_FREE_OBJ(x) do {\ + if ((x) != NULL) {\ + evas_object_del(x); \ + x = NULL;\ + } \ + } while (0) + +#define UG_SAFE_STRCPY(dest, src) \ + do{if(!dest||!src)break;\ + strncpy (dest , src, sizeof(dest)-1);\ + dest[sizeof(dest)-1] = 0; }while(0) + +#define UG_SAFE_DEL_ECORE_TIMER(timer) do { \ + if (timer) { \ + ecore_timer_del(timer);\ + timer = NULL; \ + } \ + } while (0) + +#define goto_if(x, dest) do { \ + if (x) {\ + goto dest;\ + }\ + } while (0) + +#define ug_ecore_idler_del(idler) do { \ + if(idler) { \ + ecore_idler_del(idler);\ + idler = NULL; \ + } \ + } while (0) + +typedef enum _mf_ug_list_play_state mf_ug_list_play_state; + +enum _mf_ug_list_play_state { + PLAY_STATE_INIT = 0, + PLAY_STATE_READY, + PLAY_STATE_PLAYING, + PLAY_STATE_PAUSED, + PLAY_STATE_STOP, + PLAY_STATE_MAX +}; + + +typedef enum _mf_ug_select_mode mf_ug_select_mode; +enum _mf_ug_select_mode { + SELECT_MODE = 0, + SINGLE_FILE_MODE, + SINGLE_ALL_MODE, + MULTI_FILE_MODE, + MULTI_ALL_MODE, + EXPORT_MODE, + IMPORT_MODE, + IMPORT_SINGLE, + IMPORT_PATH_SELECT_MODE, + SAVE_MODE, + SELECT_MODE_MAX +}; + +typedef enum _mf_ug_drm_mode mf_ug_drm_mode; +enum _mf_ug_drm_mode { + DRM_FILTER_NONE = 0, + DRM_FILTER_ALL, + DRM_FILTER_WITHOUT_FL, + DRM_FILTER_IMAGE, + DRM_FILTER_RINGTONE, + DRM_FILTER_MAX +}; + +typedef enum _mf_ug_marked_switch mf_ug_marked_switch; +enum _mf_ug_marked_switch { + MARKED_OFF = 0, + MARKED_ON, +}; + +typedef enum _mf_ug_file_filter_type mf_ug_file_filter_type; +enum _mf_ug_file_filter_type { + SHOW_ALL_LIST = 0, + SHOW_IMAGE_LIST, + SHOW_SOUND_LIST, + SHOW_VIDEO_LIST, + SHOW_FLASH_LIST, + SHOW_FOLDER_LIST, + SHOW_IMAGE_VIDEO_LIST, + SHOW_IMAGE_SOUND_LIST, + SHOW_VIDEO_SOUND_LIST, + SHOW_BY_EXTENSION +}; + + + +typedef enum _mf_ug_state_mode mf_ug_state_mode; +enum _mf_ug_state_mode { + STATE_PHONE = 0, + STATE_MEMORY, + STATE_MODE_MAX +}; + +typedef enum _mf_ug_mmc_insert_state mf_ug_mmc_insert_state; +enum _mf_ug_mmc_insert_state { + MMC_OFF = 0, + MMC_ON +}; + +typedef enum _mf_ug_launch_type mf_ug_launch_type; +enum _mf_ug_launch_type { + LAUNCH_TYPE_FORK = 0, + LAUNCH_TYPE_FAIL, + LAUNCH_TYPE_DIR, + LAUNCH_TYPE_IMAGE, + LAUNCH_TYPE_MUSIC, + LAUNCH_TYPE_VIDEO, + LAUNCH_TYPE_UNSUPPORT, + LAUNCH_TYPE_MAX +}; + +typedef enum _mf_ug_eina_list_node_type mf_ug_eina_list_node_type; +enum _mf_ug_eina_list_node_type { + NODE_TYPE_NONE = 0, + NODE_TYPE_CHAR, + NODE_TYPE_PNODE, + NODE_TYPE_GSTRING, + NODE_TYPE_MAX +}; + +typedef enum _mf_ug_ctrl_bar_type mf_ug_ctrl_bar_type; +enum _mf_ug_ctrl_bar_type { + CTRL_BAR_NORMAL = 0, + CTRL_BAR_MUSIC, + CTRL_BAR_RINGTONE, + CTRL_BAR_MULTI, + CTR_BAR_MAX +}; + +typedef enum _mf_ug_view_type mf_ug_view_type; +enum _mf_ug_view_type { + mf_ug_view_root = 0, + mf_ug_view_normal, + mf_ug_view_max +}; + +typedef struct _ugListItemData ugListItemData; +struct _ugListItemData { + Evas_Object *ug_pCheckBox; + Evas_Object *ug_pRadioBox; + Evas_Object *ug_pPlaybtn; + Elm_Object_Item *ug_pItem; + char *ug_pThumbPath; + GString *ug_pItemName; + ugData *ug_pData; + bool ug_bChecked; + int ug_iGroupValue; + bool ug_bRealThumbFlag; +}; + +typedef struct _ug_dir_event_t ug_dir_event_t; +struct _ug_dir_event_t { + int event; + char *name; +}; + +typedef enum _mf_ug_theme_type mf_ug_theme_type; +enum _mf_ug_theme_type { + UG_THEME_INVALID = -1, + UG_THEME_NBEAT = 0, + UG_THEME_NBEAT_BLACK = 1, + UG_THEME_ERROR +}; + +typedef enum _mf_ug_more_type_e mf_ug_more_type_e; + +enum _mf_ug_more_type_e{ /* softkey / contextual popup */ + UG_MORE_DEFAULT = 0, + UG_MORE_CREATE_FOLDER, + UG_MORE_SEARCH, + UG_MORE_TYPE_MAX +}; + +typedef enum _mf_ug_file_name_type_e mf_ug_file_name_type_e; +enum _mf_ug_file_name_type_e { + FILE_NAME_WITH_BRACKETS, + FILE_NAME_WITH_UNDERLINE, + FILE_NAME_NONE, +}; + +typedef enum __mf_ug_thumbnail_type_e mf_ug_thumbnail_type_e; +enum __mf_ug_thumbnail_type_e { + MF_UG_THUMBNAIL_TYPE_DEFAULT, + MF_UG_THUMBNAIL_TYPE_THUMBNAIL, + MF_UG_THUMBNAIL_TYPE_MAX +}; + +bool mf_ug_util_is_mass_storage_on(); +int mf_ug_util_create_dir_monitor(void *data); +int mf_ug_util_set_mmc_state_cb(void *data); +int mf_ug_util_get_mmc_state(int *mmc_card); +char *mf_ug_util_get_send_result(void *data); +bool mf_ug_util_is_genlist_selected(void *data); + +void mf_ug_list_play_play_music_item(ugListItemData *data); +void mf_ug_list_play_destory_playing_file(void *data); +void mf_ug_list_play_update_item_icon(void *data); + +void mf_ug_util_storage_insert_action(void *data, char *pItemLabel); +void mf_ug_util_destory_mmc_state_cb(); +void mf_ug_util_destory_dir_monitor(void *data); +void mf_ug_util_get_params_path(Eina_List **dest_list, const char *path_list); +void mf_ug_util_free_eina_list_data(Eina_List **list, mf_ug_eina_list_node_type node_type); +void mf_ug_util_set_current_state(void *data, int state); +int mf_ug_util_add_dir_watch(const char *path, void *data); +mf_ug_launch_type mf_ug_util_get_file_launch_type(char *path); + +void mf_ug_util_destory_mass_storage_callback(); +mf_ug_theme_type mf_ug_util_get_theme(void); +int mf_ug_file_attr_get_parent_path(const char *path, char **parent_path); +char *mf_ug_util_upper_folder_name_get(void *data, GString *fullpath); +void mf_ug_util_operation_alloc_failed(void *data); +int mf_ug_util_remove_dir_watch(void); +void mf_ug_util_sort_the_file_list(void *data); +int mf_ug_util_check_disk_space(void *data); +long mf_ug_util_character_count_get(const char *original); + +#endif /* __DEF_MYFILE_UTIL_H_ */ diff --git a/src/include/mf-ug-winset.h b/src/include/mf-ug-winset.h new file mode 100644 index 0000000..a18e85c --- /dev/null +++ b/src/include/mf-ug-winset.h @@ -0,0 +1,164 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DEF_MF_UG_WINSET_H_ +#define __DEF_MF_UG_WINSET_H_ + +#include <stdio.h> +#include <assert.h> +#include <Elementary.h> +#include <glib.h> +#include <vconf.h> +#include <vconf-keys.h> + + +#include "mf-ug-main.h" +#include "../../data/ug_edc_common.h" +#include "mf-ug-conf.h" +#include "mf-ug-fs-util.h" + + +/******************Navigation Bar Definition ***********/ +#define NAVI_MORE_BUTTON_PART "toolbar_more_btn" +#define NAVI_BOTTOM_BUTTON_1_PART "toolbar_button1" +#define NAVI_BOTTOM_BUTTON_2_PART "toolbar_button2" +#define NAVI_BUTTON_STYLE "naviframe/toolbar/default" +#define NAVI_BUTTON_EDIT "naviframe/more/default" + +#define TITLE_BTN_STYLE "elm/button/base/naviframe/title_icon" +#define TITLE_LEFT_BTN "title_left_btn" +#define TITLE_RIGHT_BTN "title_right_btn" + +#define MF_UG_NAVI_STYLE_ENABLE "basic" +#define MF_UG_UPPER_HEIGHT (113*elm_config_scale_get()) +#define MF_UG_UPPER_WIDTH (480*elm_config_scale_get()) + +Evas_Object *mf_ug_navi_bar_create_navi_bar(Evas_Object *parent); +void mf_ug_navi_bar_set_new_content(Evas_Object *pLayout, Evas_Object *NaviContent); +void mf_ug_navi_bar_create_default_view(void *data); +ugNaviBar *mf_ug_navi_bar_get_in_use_navi(void *data); +void mf_ug_navi_bar_reset_navi_object(ugNaviBar *pNavi_s); +void mf_ug_navi_bar_refresh_navibar_recovered_view(void *data, ugNaviBar *pNaviStruct); +void mf_ug_navi_bar_remove_navi_list_item_by_label(void *data, const char *pNaviLabel); +void mf_ug_navi_bar_set_blocking(void *data, bool bblock_during_transition); +void mf_ug_navi_bar_remove_previous_contents(void *data); +void mf_ug_navi_bar_del_item_directly(void *data); +void mf_ug_navi_bar_create_new_folder_view(void *data); +ugNaviBar *ug_mf_navi_bar_get_navi_from_navilist(Eina_List *navilist, const char *label); +ugNaviBar *mf_ug_navi_bar_get_navi_struct_by_label(void *data, const char *pNaviLabel); +void mf_ug_navi_bar_title_set(void *data); +Evas_Object *mf_ug_navibar_create_notify_popup(void *data, + Evas_Object *parent, + char *label, + bool time_out, + void func(void *data, Evas_Object *obj, void *event_info)); + +/********** Control Bar Definition ********/ + +#define UG_CTRL_ICON_CANCEL UG_ICON_PATH"/myfile_icon_cancel.png" +#define UG_CTRL_ICON_SAVE UG_ICON_PATH"/myfile_icon_done.png" +#define UG_TITLE_ICON_HOME UG_ICON_PATH"/Controlbar/U01_controlbar_cion_home.png" +#define UG_TITLE_ICON_HOME_PRESS UG_ICON_PATH"/Controlbar/U01_controlbar_cion_home_press.png" +#define UG_TITLE_ICON_UPPER UG_ICON_PATH"/Controlbar/U01_controlbar_cion_up_folder.png" +#define UG_TITLE_ICON_UPPER_PRESS UG_ICON_PATH"/Controlbar/U01_controlbar_cion_up_folder_press.png" + +typedef enum _eCtrlBarButtonType eCtrlBarButtonType; + +enum _eCtrlBarButtonType { + CTRL_BUTTON_CANCEL = 0, + CTRL_BUTTON_DONE, + CTRL_BUTTON_ADD, + CTRL_BUTTON_OTHER_RIONTONGS, + CTRL_BUTTON_MUSIC, + CTRL_BUTTON_MAX +}; + +void mf_ug_ctrl_bar_set(void *data, ugNaviBar *pNavi_s); +void mf_ug_ctrl_bar_set_item_disable(void *data); + + +/**********Tab Bar Definition *************/ +Evas_Object *mf_ug_tab_bar_create(Evas_Object *parent); +Elm_Object_Item *mf_ug_tab_bar_append_item(Evas_Object *pTabBar, char *pTabIconPath, char *pTabBarLabel, void *user_data); +void mf_ug_tab_bar_set_item_view(Evas_Object *tab_layout, Evas_Object *view); +void mf_ug_tab_bar_remove_item_by_label(Evas_Object *pTabBar, char *pTabLabel); +void mf_ug_tab_bar_remove_all_items(Evas_Object *pTabBar); +void mf_ug_tab_bar_set_selected_item(Elm_Object_Item *pItem); +void mf_ug_tab_bar_set_item_disable(Evas_Object *pTabBar, Eina_Bool disable); +void mf_ug_ctrl_bar_recover(void *data); +Elm_Object_Item *mf_ug_tab_bar_get_item_by_label(Evas_Object *pTabBar, char *pTabLabel); +int mf_ug_tab_bar_items_count_get(Evas_Object *pTabBar); +void mf_ug_navi_bar_button_set_disable(void *data, bool disable); + + +/*********** Popup Definition ************/ +typedef enum _mf_ug_popup_mode mf_ug_popup_mode; +enum _mf_ug_popup_mode { + UG_POPMODE_MIN = 0, + UG_POPMODE_TEXT, + UG_POPMODE_TITLE_TEXT, + UG_POPMODE_TEXT_TWO_BTN, + UG_POPMODE_TITLE_TEXT_TWO_BTN, + UG_POPMODE_TEXT_BTN, + UG_POPMODE_TITLE_TEXT_BTN, + UG_POPMODE_TITLE_TEXT_THREE_BTN, + UG_POPMODE_PROGRESSBAR, + UG_POPMODE_SEARCH, + UG_POPMODE_LIST_BY, + UG_POPMPDE_MAX +}; + +typedef enum _mf_ug_popup_event_type mf_ug_popup_event_type; +enum _mf_ug_popup_event_type { + UG_ELM_POPUP_NONE, + UG_ELM_POPUP_YES, + UG_ELM_POPUP_NO, + UG_ELM_POPUP_OK, + UG_ELM_POPUP_CANCLE, + UG_ELM_POPUP_AUTO_RENAME, + UG_ELM_POPUP_REPLACE, + UG_ELM_POPUP_PHONE, + UG_ELM_POPUP_MEMORY, + UG_ELM_POPUP_MAX +}; + +/*********** Popup API ************/ +Evas_Object *mf_ug_popup_create(void *data, mf_ug_popup_mode 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); +void mf_ug_popup_indicator_popup(const char *text); +void mf_ug_context_popup_create_more(void *data, Evas_Object *parent); + + +/******************* Genlist API *********************/ + +void mf_ug_upper_genlist_item_append(Evas_Object *pGenlist, void *data); +void mf_ug_genlist_goto_myfile_item_append(Evas_Object *pGenlist, void *data); +Evas_Object *mf_navi_bar_upper_create(Evas_Object *parent); +void mf_ug_genlist_goto_myfile_style_set(void *data); +void mf_ug_genlist_upper_style_set(void *data); +Evas_Object *mf_ug_genlist_create_no_content(void *data); +Evas_Object *mf_ug_genlist_create_content_list_view(void *data); +Evas_Object *__mf_ug_genlist_create_gl(void *data); +Evas_Object *mf_ug_genlist_create_list_new_folder_style(void *data); +Evas_Object *mf_ug_genlist_create_path_info(Evas_Object *parent, Elm_Genlist_Item_Class *itc, char *info); +Elm_Object_Item *mf_ug_genlist_item_append(Evas_Object *parent, + ugFsNodeInfo *pNode, + void *data, + int groudValue, + Elm_Genlist_Item_Class *itc); +void mf_ug_genlist_selected_gl(void *data, Evas_Object *obj, void *event_info); + +#endif diff --git a/src/mf-ug-main.c b/src/mf-ug-main.c new file mode 100644 index 0000000..0430646 --- /dev/null +++ b/src/mf-ug-main.c @@ -0,0 +1,1375 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <sys/time.h> +#include <Elementary.h> +#include <Ecore_X.h> +#include <vconf.h> +#include <media_content.h> +#include <utilX.h> +#include <assert.h> + +#include "mf-ug-main.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-util.h" +#include "../data/ug_edc_common.h" +#include "mf-ug-conf.h" +#include "mf-ug-dlog.h" +#include "mf-ug-winset.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-resource.h" +#include "mf-ug-cb.h" +#include "mf-ug-list-play.h" + +#ifdef UG_OPERATION_SELECT_MODE + +#define MF_BUNDLE_SELECTION_MODE "http://tizen.org/appcontrol/data/selection_mode" +#define MF_BUNDLE_SELECTION_MODE_SINGLE "single" +#define MF_BUNDLE_SELECTION_MODE_MULTI "multiple" +#endif + +/****************************** +** Prototype : __mf_ug_main_init_data +** Description : +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_main_init_data(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + if (ugd->ug_Status.ug_pPath != NULL) + { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + ugd->ug_Status.ug_pPath = g_string_new(PHONE_FOLDER); + ugd->ug_Status.ug_iState = STATE_PHONE; + ugd->ug_Status.ug_iRadioOn = 0; + ugd->ug_Status.ug_iMmcFlag = false; + ugd->ug_Status.ug_bAudioPlayFlag = false; + ugd->ug_Status.ug_bInstallFlag = true; + ugd->ug_Status.ug_bInSettingView = false; + ugd->ug_Status.ug_bSettingEntry = false; + ugd->ug_Status.ug_iMore = UG_MORE_DEFAULT; + + ugd->ug_UiGadget.ug_iSelectMode = SINGLE_FILE_MODE; + ugd->ug_UiGadget.ug_iFilterMode = SHOW_ALL_LIST; + ugd->ug_UiGadget.ug_pExtension = NULL; + ugd->ug_UiGadget.ug_iDrmFilter = DRM_FILTER_NONE; + ugd->ug_UiGadget.ug_iMarkedMode = MARKED_OFF; + ugd->ug_UiGadget.ug_pMultiSelectFileList = NULL; + + ugd->ug_ListPlay.ug_pPlayFilePath = NULL; + ugd->ug_ListPlay.ug_iPlayState = PLAY_STATE_INIT; +#ifdef UG_OPERATION_SELECT_MODE + ugd->ug_UiGadget.ug_bOperationSelectFlag = false; +#endif + + + mf_ug_util_create_dir_monitor(ugd); + mf_ug_util_set_mmc_state_cb(ugd); + UG_TRACE_END; +} + +/****************************** +** Prototype : __mf_ug_main_free_data +** Description : +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_main_free_data(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + if (ugd->ug_Status.ug_pPath) + { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + if (ugd->ug_UiGadget.ug_pMultiSelectFileList) + { + mf_ug_util_free_eina_list_data(&ugd->ug_UiGadget.ug_pMultiSelectFileList, NODE_TYPE_CHAR); + ugd->ug_UiGadget.ug_pMultiSelectFileList = NULL; + } + if (ugd->ug_UiGadget.ug_pDirList) + { + mf_ug_util_free_eina_list_data(&ugd->ug_UiGadget.ug_pDirList, NODE_TYPE_PNODE); + ugd->ug_UiGadget.ug_pDirList = NULL; + } + if (ugd->ug_UiGadget.ug_pFilterList) + { + mf_ug_util_free_eina_list_data(&ugd->ug_UiGadget.ug_pFilterList, NODE_TYPE_PNODE); + ugd->ug_UiGadget.ug_pFilterList = NULL; + } + + if (ugd->ug_Status.ug_pUpper_folder) + { + free(ugd->ug_Status.ug_pUpper_folder); + ugd->ug_Status.ug_pUpper_folder = NULL; + } + if (ugd->ug_Status.ug_pEntryPath) + { + free(ugd->ug_Status.ug_pEntryPath); + ugd->ug_Status.ug_pEntryPath = NULL; + } + + UG_TRACE_END; + +} + + +/****************************** +** Prototype : __mf_ug_main_free_evas_object +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_main_free_evas_object(void *data) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugData is NULL"); + + int iNaviListLen = 0; + int index = 0; + + if (ugd->ug_MainWindow.ug_pNormalPopup != NULL) + { + + evas_object_del(ugd->ug_MainWindow.ug_pNormalPopup); + ugd->ug_MainWindow.ug_pNormalPopup = NULL; + } + if (ugd->ug_MainWindow.ug_pRadioGroup != NULL) + { + + evas_object_del(ugd->ug_MainWindow.ug_pRadioGroup); + ugd->ug_MainWindow.ug_pRadioGroup = NULL; + } + + iNaviListLen = eina_list_count(ugd->ug_MainWindow.ug_pNaviBarList); + for (index = 0; index < iNaviListLen; index++) + { + ugNaviBar *pNavi_s = NULL; + pNavi_s = (ugNaviBar *)eina_list_nth(ugd->ug_MainWindow.ug_pNaviBarList, index); + if (pNavi_s->ug_pNaviLabel != NULL) + { + free(pNavi_s->ug_pNaviLabel); + pNavi_s->ug_pNaviLabel = NULL; + } + if (pNavi_s->ug_pNaviTitle != NULL) + { + free(pNavi_s->ug_pNaviTitle); + pNavi_s->ug_pNaviTitle = NULL; + } + } + + if (ugd->ug_MainWindow.ug_pTabBar != NULL) + { + evas_object_del(ugd->ug_MainWindow.ug_pTabBar); + ugd->ug_MainWindow.ug_pTabBar = NULL; + } + + + if (ugd->ug_MainWindow.ug_pBackGround != NULL) + { + evas_object_del(ugd->ug_MainWindow.ug_pBackGround); + ugd->ug_MainWindow.ug_pBackGround = NULL; + } + + if (ugd->ug_MainWindow.ug_pMainLayout != NULL) + { + evas_object_del(ugd->ug_MainWindow.ug_pMainLayout); + ugd->ug_MainWindow.ug_pMainLayout = NULL; + } + UG_TRACE_END; +} + +Evas_Object *mf_ug_main_create_bg(Evas_Object *win) +{ + ug_mf_retv_if(win == NULL, NULL); + Evas_Object *bg = elm_bg_add(win); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(bg); + + return bg; +} + +/****************************** +** Prototype : _ug_mf_create_layout_main +** Description : +** Input : Evas_Object* parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_main_create_main_layout(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + Evas_Object *layout = NULL; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + layout = elm_layout_add(parent); + ug_mf_retvm_if(layout == NULL, NULL, "Failed elm_layout_add.\n"); + + elm_layout_theme_set(layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(layout); + UG_TRACE_END; + + return layout; +} + +Evas_Object *mf_ug_main_tab_layout_create(Evas_Object *parent) +{ + Evas_Object *layout; + + ug_mf_retv_if(parent == NULL, NULL); + + layout = elm_layout_add(parent); + ug_mf_retvm_if(layout == NULL, NULL, "Failed elm_layout_add.\n"); + elm_object_focus_set(layout, EINA_FALSE); + + elm_layout_theme_set(layout, "layout", "tabbar", "default"); + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + evas_object_hide(layout); + return layout; +} + +/****************************** +** Prototype : __mf_ug_main_set_path_option +** Description : Samsung +** Input : void *data +** char *path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static int __mf_ug_main_set_path_option(void *data, const char *path) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, MYFILE_ERR_SRC_ARG_INVALID, "ugd is NULL"); + ug_mf_retvm_if(path == NULL, MYFILE_ERR_SRC_ARG_INVALID, "path is NULL"); + + int error_code = MYFILE_ERR_NONE; + char *entry_path = NULL; + + if (strncmp(path, PHONE_FOLDER, strlen(PHONE_FOLDER)) == 0 || strncmp(path, MEMORY_FOLDER, strlen(MEMORY_FOLDER)) == 0) + { + + /**check whether is /opt/media or /mnt/mmc */ + entry_path = strdup(path); + if (entry_path == NULL) + { + return MYFILE_ERR_ALLOCATE_FAIL; + } + } + else if (strncmp(path, UG_SETTING_RINGTONE_PATH, strlen(UG_SETTING_RINGTONE_PATH)) == 0 + || strncmp(path, UG_SETTING_ALERTS_PATH, strlen(UG_SETTING_ALERTS_PATH)) == 0 + || strncmp(path, UG_SETTING_MSG_ALERTS_PATH, strlen(UG_SETTING_MSG_ALERTS_PATH)) == 0) + { + + /**check whether is setting ringtone or alerts path */ + entry_path = strdup(path); + if (entry_path == NULL) + { + return MYFILE_ERR_ALLOCATE_FAIL; + } + ugd->ug_Status.ug_bInSettingView = true; + ugd->ug_Status.ug_bSettingEntry = true; + ugd->ug_Status.ug_bRingtoneSet = true; + } + else if (strlen(path) == 1 && strncmp(path, "/", 1)) + { + /**chech the path whether is "/" */ + entry_path = strdup(PHONE_FOLDER); + if (entry_path == NULL) + { + return MYFILE_ERR_ALLOCATE_FAIL; + } + } + else + { + /**not begin with /mnt/mmc and /opt/media , so append it to /opt/media*/ + char *temp = strdup(PHONE_FOLDER); + if (temp == NULL) + { + return MYFILE_ERR_ALLOCATE_FAIL; + } + entry_path = g_strconcat(temp, path, NULL); + free(temp); + } + + if (entry_path != NULL) + { + /** if there is a '/' at the end of the path, can't be recognized */ + if (entry_path[strlen(entry_path) - 1] == '/') + { + entry_path[strlen(entry_path) - 1] = '\0'; + } + + if (ecore_file_exists(entry_path) == false) + { + + if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) + { + error_code = mf_ug_fm_svc_wrapper_create_p(entry_path); + if (error_code != MYFILE_ERR_NONE) + { + free(entry_path); + return MYFILE_ERR_INVALID_FILE_PATH; + } + } + else + { + free(entry_path); + return MYFILE_ERR_INVALID_FILE_PATH; + } + } + if (ecore_file_is_dir(entry_path) == false) + { + ug_mf_debug("path is not a directory"); + free(entry_path); + return MYFILE_ERR_INVALID_DIR_PATH; + } + + if (ugd->ug_Status.ug_pPath) + { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + ugd->ug_Status.ug_pEntryPath = g_strdup(entry_path); + ugd->ug_Status.ug_pPath = g_string_new(entry_path); + ugd->ug_Status.ug_iViewType = mf_ug_view_normal; + free(entry_path); + } + else + { + return MYFILE_ERR_ALLOCATE_FAIL; + } + UG_TRACE_END; + return error_code; +} + + +/****************************** +** Prototype : __mf_ug_main_set_select_mode +** Description : Samsung +** Input : void *data +** char *select_mode +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void __mf_ug_main_set_select_mode(void *data, const char *select_mode) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + if (select_mode != NULL) + { + if (!strncmp(select_mode, UG_SELECT_MODE_SINGLE_FILE, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = SINGLE_FILE_MODE; + } + else if (!strncmp(select_mode, UG_SELECT_MODE_MULTI_FILE, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = MULTI_FILE_MODE; + } + else if (!strncmp(select_mode, UG_SELECT_MODE_SINGLE_ALL, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = SINGLE_ALL_MODE; + } + else if (!strncmp(select_mode, UG_SELECT_MODE_MULTI_ALL, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = MULTI_ALL_MODE; + } + else if(!strncmp(select_mode, UG_SELECT_MODE_IMPORT, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = IMPORT_MODE; + } + else if(!strncmp(select_mode, UG_SELECT_MODE_IMPORT_PATH_SELECT, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = IMPORT_PATH_SELECT_MODE; + } + else if(!strncmp(select_mode, UG_SELECT_MODE_EXPORT, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = EXPORT_MODE; + } + else if (!strncmp(select_mode, UG_SELECT_MODE_IMPORT_SINGLE, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = IMPORT_SINGLE; + ugd->ug_Status.ug_iViewType = mf_ug_view_normal; + } + else if (!strncmp(select_mode, UG_SELECT_MODE_SAVE, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = SAVE_MODE; + } + else + { + ugd->ug_UiGadget.ug_iSelectMode = SINGLE_FILE_MODE; + } + } + else + { + ugd->ug_UiGadget.ug_iSelectMode = SINGLE_FILE_MODE; + } + UG_TRACE_END; + +} + + + +/****************************** +** Prototype : __mf_ug_main_set_filter_mode +** Description : Samsung +** Input : void *data +** char *file_filter +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void __mf_ug_main_set_filter_mode(void *data, const char *file_filter) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + if (file_filter != NULL) + { + if (!strncmp(file_filter, UG_FILE_FILTER_ALL, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_ALL_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_IMAGE, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_IMAGE_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_SOUND, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_SOUND_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_VIDEO, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_VIDEO_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_FLASH, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_FLASH_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_FOLDER, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_FOLDER_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_IV, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_IMAGE_VIDEO_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_IS, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_IMAGE_SOUND_LIST; + } + else if (!strncmp(file_filter, UG_FILE_FILTER_VS, strlen(file_filter))) + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_VIDEO_SOUND_LIST; + } + else + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_BY_EXTENSION; + ugd->ug_UiGadget.ug_pExtension = strdup(file_filter); + if (g_strcmp0(file_filter, "opml") == 0) + { + ugd->ug_UiGadget.ug_iImportMode = 1; + } + } + } + else + { + ugd->ug_UiGadget.ug_iFilterMode = SHOW_ALL_LIST; + ugd->ug_UiGadget.ug_pExtension = NULL; + } + + if (ugd->ug_UiGadget.ug_iFilterMode != SHOW_BY_EXTENSION) + { + ugd->ug_UiGadget.ug_iFileFilter = mf_ug_fm_svc_wapper_get_file_filter(ugd->ug_UiGadget.ug_iFilterMode); + } + + + if (ugd->ug_UiGadget.ug_iFilterMode == SHOW_SOUND_LIST && ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) + { + ugd->ug_Status.ug_iCtrlBarType = CTRL_BAR_MUSIC; + } + else + { + ugd->ug_Status.ug_iCtrlBarType = CTRL_BAR_MULTI; + } + UG_TRACE_END; +} + + + +/****************************** +** Prototype : __mf_ug_main_set_marked_mode +** Description : Samsung +** Input : void *data +** char *marked_mode +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void __mf_ug_main_set_marked_mode(void *data, const char *marked_mode) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + if (marked_mode != NULL) + { + ugd->ug_UiGadget.ug_iMarkedMode = MARKED_ON; + mf_ug_util_get_params_path(&ugd->ug_UiGadget.ug_pMultiSelectFileList, marked_mode); + } + else + { + ugd->ug_UiGadget.ug_iMarkedMode = MARKED_OFF; + } + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_main_set_drm_filter_mode +** Description : Samsung +** Input : void *data +** char *drm_filter +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void __mf_ug_main_set_drm_filter_mode(void *data, const char *drm_filter) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + if (drm_filter != NULL) + { + if (!strncmp(drm_filter, UG_DRM_FILTER_NONE, strlen(drm_filter))) + { + ugd->ug_UiGadget.ug_iDrmFilterMode = DRM_FILTER_NONE; + } + else if (!strncmp(drm_filter, UG_DRM_FILTER_ALL, strlen(drm_filter))) + { + ugd->ug_UiGadget.ug_iDrmFilterMode = DRM_FILTER_ALL; + } + else if (!strncmp(drm_filter, UG_DRM_FILTER_WITHOUT_FL, strlen(drm_filter))) + { + ugd->ug_UiGadget.ug_iDrmFilterMode = DRM_FILTER_WITHOUT_FL; + } + else + { + ugd->ug_UiGadget.ug_iDrmFilterMode = DRM_FILTER_ALL; + } + } + else + { + ugd->ug_UiGadget.ug_iDrmFilterMode = DRM_FILTER_ALL; + } + + ugd->ug_UiGadget.ug_iDrmFilter = mf_ug_fm_svc_wapper_get_drm_filter(ugd->ug_UiGadget.ug_iDrmFilterMode, ugd->ug_UiGadget.ug_iFileFilter); + UG_TRACE_END; +} + +#ifdef UG_OPERATION_SELECT_MODE +static void __mf_ug_main_set_operation_select_mode(void *data, const char *select_mode) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + if (select_mode != NULL) + { + if (!strncmp(select_mode, MF_BUNDLE_SELECTION_MODE_SINGLE, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = SINGLE_FILE_MODE; + } + else if (!strncmp(select_mode, MF_BUNDLE_SELECTION_MODE_MULTI, strlen(select_mode))) + { + ugd->ug_UiGadget.ug_iSelectMode = MULTI_FILE_MODE; + } + else + { + ugd->ug_UiGadget.ug_iSelectMode = SINGLE_FILE_MODE; + } + ugd->ug_UiGadget.ug_bOperationSelectFlag = true; + } + UG_TRACE_END; + +} +#endif +/****************************** +** Prototype : __mf_ug_main_set_option_status +** Description : Samsung +** Input : void *data +** service_h service +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void __mf_ug_main_set_option_status(void *data, service_h service) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + char *path = NULL; + char *select_mode = NULL; + char *filter_mode = NULL; + char *marked_mode = NULL; + char *drm_filter_mode = NULL; +#ifdef UG_OPERATION_SELECT_MODE + char *key[UG_OPTION_COUNT] = { "path", "select_type", "file_type", "marked_mode", "drm_type", MF_BUNDLE_SELECTION_MODE}; + char *operation_select_mode = NULL; +#else + char *key[UG_OPTION_COUNT] = { "path", "select_type", "file_type", "marked_mode", "drm_type"}; +#endif + + service_get_extra_data(service, key[0], &path); + service_get_extra_data(service, key[1], &select_mode); + service_get_extra_data(service, key[2], &filter_mode); + service_get_extra_data(service, key[3], &marked_mode); + service_get_extra_data(service, key[4], &drm_filter_mode); + + __mf_ug_main_set_select_mode(ugd, select_mode); + __mf_ug_main_set_path_option(ugd, path); + __mf_ug_main_set_filter_mode(ugd, filter_mode); + __mf_ug_main_set_marked_mode(ugd, marked_mode); + __mf_ug_main_set_drm_filter_mode(ugd, drm_filter_mode); +#ifdef UG_OPERATION_SELECT_MODE + service_get_extra_data(service, key[5], &operation_select_mode); + __mf_ug_main_set_operation_select_mode(ugd, operation_select_mode); +#endif + UG_TRACE_END; +} + +/****************************** +** Prototype : __mf_ug_main_create_default_layout +** Description : Samsung +** Input : Evas_Object* parent +** void* data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_main_create_default_layout(Evas_Object *parent, void *data) +{ + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + Evas_Object *pContent = NULL; + int tab_item_count = 1; + + int mmc_card = 0; + int error_code = 0; + /*/check if mmc mounted */ + error_code = mf_ug_util_get_mmc_state(&mmc_card); + if (error_code == 0 && mmc_card == 1) + { + tab_item_count++; + } + /*/check if usb otg mounted + { + Todo: we need to add something to record what should on + } + create phone navi */ + ugNaviBar *pNavi_phone = calloc(1, sizeof(ugNaviBar)); + ug_mf_retvm_if(pNavi_phone == NULL, NULL, "pNavi_phone is NULL"); + + ugd->ug_MainWindow.ug_pNaviBar = mf_ug_navi_bar_create_navi_bar(parent); + if (ugd->ug_MainWindow.ug_pNaviBar == NULL) + { + ug_debug("ugd->ug_MainWindow.ug_pNaviBar is NULL"); + free(pNavi_phone); + pNavi_phone = NULL; + UG_TRACE_END; + return NULL; + } + + pNavi_phone->ug_bNaviFlagInUse = TRUE; + + UG_SAFE_FREE_CHAR(pNavi_phone->ug_pCurrentPath); + pNavi_phone->ug_pCurrentPath = g_strdup(ugd->ug_Status.ug_pPath->str); + + UG_SAFE_FREE_CHAR(pNavi_phone->ug_pNaviLabel); + pNavi_phone->ug_pNaviLabel = strdup(MF_UG_LABEL_PHONE); + /*/insert phone navi into the navi_list */ + /** Todo: if we need to check ap->mf_MainWindow.plistNaviBar?*/ + ugd->ug_MainWindow.ug_pNaviBarList = eina_list_append(ugd->ug_MainWindow.ug_pNaviBarList, pNavi_phone); + + UG_TRACE_END; + return ugd->ug_MainWindow.ug_pNaviBar; +} + +/****************************** +** Prototype : __mf_ug_main_start +** Description : +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void __mf_ug_main_start(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + Evas_Object *pContent = NULL; + int error_code = 0; + int mmc_card = 0; + + pContent = __mf_ug_main_create_default_layout(ugd->ug_MainWindow.ug_pMainLayout, ugd); + + if (pContent != NULL) + { + elm_object_part_content_set(ugd->ug_MainWindow.ug_pMainLayout, "elm.swallow.content", pContent); + mf_ug_navi_bar_create_default_view(ugd); + mf_ug_ctrl_bar_set_item_disable(ugd); + mf_ug_navi_bar_set_blocking(data, false); + } + else + { + return; + } + ug_debug("done"); + UG_TRACE_END; + + return; +} + + + +static Eina_Bool ug_callback_hw_key_down( void *data, int type __attribute__((unused)), void *event ) +{ + assert(data != NULL); + assert(event != NULL); + + if(data == NULL) + { + return ECORE_CALLBACK_DONE; + } + if(event == NULL) + { + return ECORE_CALLBACK_DONE; + } + + ugData *ugd = data; + Ecore_Event_Key *key_event = event; + + if (strcmp(key_event->keyname, KEY_BACK) == 0) + { + if (mf_ug_fm_svc_wapper_is_root_path(ugd->ug_Status.ug_pPath)) + { + ug_destroy_me(ugd->ug); + } + else + { + mf_ug_cb_upper_click_cb(ugd, NULL, NULL); + } + } + else if (strcmp(key_event->keyname, KEY_MENU) == 0) + { + //TODO: Add menu handler here. + return ECORE_CALLBACK_DONE; + } + + return ECORE_CALLBACK_DONE; +} + + +/****************************** +** Prototype : on_create +** Description : Samsung +** Input : ui_gadget_h ug +** enum ug_mode mode +** service_h service +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) +{ + UG_TRACE_BEGIN; + + ug_mf_retv_if(NULL == priv, NULL); + + ugData *ugd = priv; + + ugd->ug = ug; + + bindtextdomain(UGPACKAGE, UGLOCALEDIR); + + Evas_Object *win = ug_get_window(); + ug_mf_retv_if(NULL == win, NULL); + + if (elm_win_wm_rotation_supported_get(win)) + { + int rotations[] = + { + APP_DEVICE_ORIENTATION_0, + APP_DEVICE_ORIENTATION_180, + }; + + elm_win_wm_rotation_available_rotations_set(win, rotations, sizeof(rotations) / sizeof(rotations[0])); + } + + ugd->ug_MainWindow.ug_pWindow = win; + ugd->ug_Status.ug_bInstallFlag = false; + ugd->ug_Status.ug_bCancelDisableFlag = false; + ugd->ug_UiGadget.ug_iImportMode = 0; + ugd->ug_MainWindow.ug_pMainLayout = __mf_ug_main_create_main_layout(ugd->ug_MainWindow.ug_pWindow); + ugd->ug_MainWindow.ug_pBackGround = mf_ug_main_create_bg(ugd->ug_MainWindow.ug_pWindow); + elm_object_part_content_set(ugd->ug_MainWindow.ug_pMainLayout, "elm.swallow.bg", ugd->ug_MainWindow.ug_pBackGround); + + __mf_ug_main_init_data(ugd); + __mf_ug_main_set_option_status(ugd, service); + int err = media_content_connect(); + if (err != MEDIA_CONTENT_ERROR_NONE) + { + ug_debug("media_content_connect failed!"); + } + + ugd->key_event_handler = ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, ug_callback_hw_key_down, ugd ); + power_set_changed_cb(mf_ug_cb_lcd_state_changed_cb, ugd); + + __mf_ug_main_start(ugd); + + UG_TRACE_END; + return ugd->ug_MainWindow.ug_pMainLayout; +} + +/****************************** +** Prototype : on_start +** Description : +** Input : ui_gadget_h ug +** service_h service +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void on_start(ui_gadget_h ug, service_h service, void *priv) +{ +} + + +/****************************** +** Prototype : on_pause +** Description : +** Input : ui_gadget_h ug +** service_h service +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void on_pause(ui_gadget_h ug, service_h service, void *priv) +{ + UG_TRACE_BEGIN; + if (!priv) + return; + ugData *ugd = (ugData *)priv; + + if (0 != ugd->ug_ListPlay.ug_Player) + { + mf_ug_list_play_pause(ugd); + } +} + +/****************************** +** Prototype : on_resume +** Description : +** Input : ui_gadget_h ug +** bundle *data +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +inline bool __mf_ug_main_check_exist(const char *path) +{ + if (path && (access(path, F_OK) == 0)) + { + return true; + } + return false; +} + +static void on_resume(ui_gadget_h ug, service_h service, void *priv) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(NULL == priv, "priv is NULL"); + ugData *ugd = priv; + + if (!__mf_ug_main_check_exist(ugd->ug_Status.ug_pPath->str)) + { + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + GString *parent_path = mf_ug_fm_svc_wrapper_get_file_parent_path(ugd->ug_Status.ug_pPath); + int storage = mf_ug_fm_svc_wapper_get_location(ugd->ug_Status.ug_pPath->str); + + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + + if (parent_path && parent_path->str) + { + if (__mf_ug_main_check_exist(parent_path->str)) + { + ug_debug("paretn is [%s] exit", parent_path->str); + ugd->ug_Status.ug_pPath = g_string_new(parent_path->str); + pNavi_s->ug_pCurrentPath = g_strdup(parent_path->str); + } + else + { + ug_debug("paretn is [%s] not exit", parent_path->str); + if (storage == MF_UG_PHONE) + { + ugd->ug_Status.ug_pPath = g_string_new(PHONE_FOLDER); + pNavi_s->ug_pCurrentPath = strdup(PHONE_FOLDER); + } + else + { + ugd->ug_Status.ug_pPath = g_string_new(MEMORY_FOLDER); + pNavi_s->ug_pCurrentPath = strdup(MEMORY_FOLDER); + } + } + } + else + { + ug_debug("get parent failed"); + if (storage == MF_UG_PHONE) + { + ugd->ug_Status.ug_pPath = g_string_new(PHONE_FOLDER); + pNavi_s->ug_pCurrentPath = strdup(PHONE_FOLDER); + } + else + { + ugd->ug_Status.ug_pPath = g_string_new(MEMORY_FOLDER); + pNavi_s->ug_pCurrentPath = strdup(MEMORY_FOLDER); + } + } + + mf_ug_navi_bar_create_default_view(ugd); + mf_ug_ctrl_bar_set_item_disable(ugd); + g_string_free(parent_path, TRUE); + parent_path = NULL; + } + + UG_TRACE_END; +} + +/****************************** +** Prototype : on_message +** Description : +** Input : ui_gadget_h ug +** bundle *msg +** bundle *data +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv) +{ +} + +/****************************** +** Prototype : on_event +** Description : +** Input : ui_gadget_h ug +** enum ug_event event +** service_h service +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv) +{ + UG_TRACE_BEGIN; + + switch (event) + { + case UG_EVENT_LOW_MEMORY: + break; + + case UG_EVENT_LOW_BATTERY: + break; + + case UG_EVENT_LANG_CHANGE: + break; + + case UG_EVENT_ROTATE_PORTRAIT: + case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: + case UG_EVENT_ROTATE_LANDSCAPE: + case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: + break; + + default: + break; + } + + UG_TRACE_END; +} + + + +/****************************** +** Prototype : on_key_event +** Description : Samsung +** Input : ui_gadget_h ug +** enum ug_key_event event +** service_h service +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)priv; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + switch (event) + { + case UG_KEY_EVENT_END: + if (ugd->ug_MainWindow.ug_pNormalPopup) + { + evas_object_del(ugd->ug_MainWindow.ug_pNormalPopup); + ugd->ug_MainWindow.ug_pNormalPopup = NULL; + } + if (0 != ugd->ug_ListPlay.ug_Player) + { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + ug_destroy_me(ug); + break; + default: + break; + } + UG_TRACE_END; +} + +/****************************** +** Prototype : on_destroy +** Description : +** Input : ui_gadget_h ug +** service_h service +** void *priv +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void on_destroy(ui_gadget_h ug, service_h service, void *priv) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)priv; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + __mf_ug_main_free_data(ugd); + + if (ugd->ug_Status.ug_bInstallFlag == true) + { + mf_ug_util_destory_dir_monitor(ugd); + mf_ug_util_destory_mmc_state_cb(); + media_content_disconnect(); + power_unset_changed_cb(); + } + + ug_ecore_idler_del(ugd->ug_Status.search_idler); + ug_ecore_idler_del(ugd->ug_Status.popup_del_idler); + ug_ecore_idler_del(ugd->ug_Status.popup_create_idler); + ug_ecore_idler_del(ugd->ug_Status.msg_finish_idler); + UG_SAFE_DEL_ECORE_TIMER(ugd->ug_Status.pPopupTimer); + + if (0 != ugd->ug_ListPlay.ug_Player) + { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + + UG_SAFE_DEL_ECORE_TIMER(ugd->ug_Status.ug_pThumbUpdateTimer); + UG_SAFE_DEL_ECORE_TIMER(ugd->ug_Status.play_timer); + __mf_ug_main_free_evas_object(ugd); + if(ugd->key_event_handler) + { + ecore_event_handler_del(ugd->key_event_handler); + } + UG_TRACE_END; +} + + +/****************************** +** Prototype : UG_MODULE_INIT +** Description : +** Input : struct ug_module_ops *ops +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops) +{ + UG_TRACE_BEGIN; + ugData *ugd; + + if (!ops) + { + return -1; + } + + ugd = calloc(1, sizeof(ugData)); + if (!ugd) + { + return -1; + } + + ops->create = on_create; + ops->start = on_start; + ops->pause = on_pause; + ops->resume = on_resume; + ops->destroy = on_destroy; + ops->message = on_message; + ops->event = on_event; + ops->key_event = on_key_event; + ops->priv = ugd; + ops->opt = UG_OPT_INDICATOR_ENABLE; + UG_TRACE_END; + return 0; +} + + + +/****************************** +** Prototype : UG_MODULE_EXIT +** Description : +** Input : struct ug_module_ops *ops +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops) +{ + UG_TRACE_BEGIN; + ugData *ugd; + + if (!ops) + { + return; + } + ugd = ops->priv; + + if (ugd) + { + free(ugd); + } + UG_TRACE_END; +} diff --git a/src/widget/mf-ug-ctrl-bar.c b/src/widget/mf-ug-ctrl-bar.c new file mode 100644 index 0000000..6153099 --- /dev/null +++ b/src/widget/mf-ug-ctrl-bar.c @@ -0,0 +1,249 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Eina.h> +#include <Elementary.h> + +#include "mf-ug-winset.h" +#include "mf-ug-cb.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-util.h" +#include "mf-ug-resource.h" + +#define UG_CTRL_STYLE_TYPE "controlbar" + + +/****************************** +** Prototype : __mf_ug_ctrl_bar_create +** Description : Samsung +** Input : Evas_Object *parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_ctrl_bar_create(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *pCtrlBar = NULL; + + pCtrlBar = elm_toolbar_add(parent); + elm_toolbar_shrink_mode_set(pCtrlBar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_object_style_set(pCtrlBar, "naviframe"); + elm_object_focus_set(pCtrlBar, EINA_FALSE); + evas_object_show(pCtrlBar); + UG_TRACE_END; + return pCtrlBar; +} + + +/****************************** +** Prototype : __mf_ug_ctrl_bar_append_item +** Description : Samsung +** Input : void *data +** Evas_Object *ctrl_bar +** int type +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_ctrl_bar_append_item(void *data, Evas_Object *ctrl_bar, int type) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + Evas_Object *pCtrlBar = ctrl_bar; + ug_mf_retm_if(pCtrlBar == NULL, "pCtrlBar is NULL"); + Elm_Object_Item *item = NULL; + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + item = elm_toolbar_item_append(pCtrlBar, NULL, NULL, NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + item = elm_toolbar_item_append(pCtrlBar, NULL, NULL, NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + item = elm_toolbar_item_append(pCtrlBar, NULL, NULL, NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + //elm_toolbar_item_append(pCtrlBar, NULL, MF_UG_LABEL_SET, (Evas_Smart_Cb) mf_ug_cb_add_button_cb, ugd); + } else { + if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + elm_toolbar_item_append(pCtrlBar, NULL, MF_UG_LABEL_IMPORT, (Evas_Smart_Cb) mf_ug_cb_add_button_cb, ugd); + item = elm_toolbar_item_append(pCtrlBar, NULL, NULL, NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + //elm_toolbar_item_append(pCtrlBar, NULL, MF_UG_LABEL_SEARCH, (Evas_Smart_Cb) mf_ug_search_view_enter_search_routine, ugd); + } else if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE) { + elm_toolbar_item_append(pCtrlBar, NULL, MF_UG_LABEL_EXPORT, (Evas_Smart_Cb) mf_ug_cb_add_button_cb, ugd); + elm_toolbar_item_append(pCtrlBar, NULL, MF_UG_LABEL_CREATE, (Evas_Smart_Cb) mf_ug_cb_create_new_folder, ugd); + } else { + elm_toolbar_item_append(pCtrlBar, NULL, MF_UG_LABEL_ATTACH, (Evas_Smart_Cb) mf_ug_cb_add_button_cb, ugd); + } + } + + elm_toolbar_item_append(pCtrlBar, NULL, MF_UG_LABEL_CANCEL, (Evas_Smart_Cb) mf_ug_cb_back_button_cb, ugd); + + + UG_TRACE_END; +} + + +/****************************** +** Prototype : mf_ug_ctrl_bar_set +** Description : Samsung +** Input : void* data +** ugNaviBar *pNavi_s +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_ctrl_bar_set(void *data, ugNaviBar *pNavi_s) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Evas_Object *pNaviBar = ugd->ug_MainWindow.ug_pNaviBar; + Evas_Object *pCtrlBar = NULL; + + int type = ugd->ug_Status.ug_iCtrlBarType; + pCtrlBar = __mf_ug_ctrl_bar_create(pNaviBar); + ugd->ug_MainWindow.ug_pNaviCtrlBar = pCtrlBar; + type = CTRL_BAR_NORMAL; + __mf_ug_ctrl_bar_append_item(ugd, pCtrlBar, type); + evas_object_show(pCtrlBar); + elm_object_item_part_content_set(ugd->ug_MainWindow.ug_pNaviItem, UG_CTRL_STYLE_TYPE, pCtrlBar); + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_ctrl_bar_disable_item +** Description : Samsung +** Input : void *data +** bool disable +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_ctrl_bar_disable_item(void *data, bool disable) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Evas_Object *pCtrlBar = NULL; + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navigation bar in use failed"); + + pCtrlBar = ugd->ug_MainWindow.ug_pNaviCtrlBar; + + Elm_Object_Item *it = NULL; + it = elm_toolbar_first_item_get(pCtrlBar); + + while(it) { + const char *button_label = elm_object_item_text_get(it); + const char *disable_labe = NULL; + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + disable_labe = MF_UG_LABEL_SET; + } else if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + disable_labe = MF_UG_LABEL_IMPORT; + } else { + disable_labe = MF_UG_LABEL_ATTACH; + } + if (g_strcmp0(button_label, disable_labe) == 0) { + elm_object_item_disabled_set(it, !disable); + } + it = elm_toolbar_item_next_get(it); + } +} + +/****************************** +** Prototype : mf_ug_ctrl_bar_set_item_disable +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_ctrl_bar_set_item_disable(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + bool disable = false; + + if (ugd->ug_Status.ug_bNoContentFlag == true) { + mf_ug_navi_bar_button_set_disable(ugd, true); + } else { + disable = mf_ug_util_is_genlist_selected(ugd); + mf_ug_navi_bar_button_set_disable(ugd, !disable); + } + UG_TRACE_END; +} + +void mf_ug_ctrl_bar_recover(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navi failed"); + + Evas_Object *naviBar = ugd->ug_MainWindow.ug_pNaviBar; + Evas_Object *ctrl_bar = NULL; + + ug_mf_retm_if(naviBar == NULL, "navi is NULL"); + ctrl_bar = elm_object_item_part_content_get(ugd->ug_MainWindow.ug_pNaviItem, UG_CTRL_STYLE_TYPE); + ugd->ug_MainWindow.ug_pNaviCtrlBar = ctrl_bar; +} diff --git a/src/widget/mf-ug-genlist.c b/src/widget/mf-ug-genlist.c new file mode 100644 index 0000000..86b8f52 --- /dev/null +++ b/src/widget/mf-ug-genlist.c @@ -0,0 +1,1649 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Eina.h> +#include "mf-ug-winset.h" +#include "mf-ug-util.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-resource.h" +#include "mf-ug-cb.h" + + +#define MF_UG_SELECTED_ITEM_BRING_UP_COUNT 7 +#define MF_UG_SELECTED_ITEM_BRING_UP_COUNT_MAX 8 + +#define MF_UG_LIST_PLAY_TIME_OUT 0.5 +/****************************** +** Prototype : __mf_ug_genlist_is_file_marked +** Description : Samsung +** Input : Eina_List *source +** GString *path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static gboolean __mf_ug_genlist_is_file_marked(Eina_List *source, GString *path) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(source == NULL, false, "source is NULL"); + ug_mf_retvm_if(path == NULL, false, "path is NULL"); + + bool flag = false; + Eina_List *l = NULL; + void *data = NULL; + + EINA_LIST_FOREACH(source, l, data) { + char *source_path = strdup(data); + if (source_path != NULL) { + if (strcmp(source_path, path->str) == 0) { + flag = true; + free(source_path); + source_path = NULL; + break; + } else { + free(source_path); + source_path = NULL; + } + } + } + UG_TRACE_END; + return flag; +} + + +/****************************** +** Prototype : __mf_ug_genlist_set_marked_path +** Description : Samsung +** Input : Eina_List **source +** GString *path +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_genlist_set_marked_path(Eina_List **source, GString *path) +{ + UG_TRACE_BEGIN; + bool file_exist_flag = false; + char *source_path; + Eina_List *l = NULL; + void *data = NULL; + + ug_mf_retm_if(source == NULL, "source is NULL"); + ug_mf_retm_if(path == NULL, "path is NULL"); + + if (NULL == *source || eina_list_count(*source) == 0) { + *source = eina_list_append(*source, strdup(path->str)); + } else { + + EINA_LIST_FOREACH(*source, l, data) { + source_path = (char *)data; + if (source_path != NULL) { + if (strcmp(source_path, path->str) == 0) { + file_exist_flag = true; + break; + } + } + } + if (file_exist_flag == true) { + *source = eina_list_remove(*source, source_path); + } else { + *source = eina_list_append(*source, strdup(path->str)); + } + } + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_genlist_create_checkbox +** Description : Samsung +** Input : Evas_Object *parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_genlist_create_checkbox(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + Evas_Object *ck_box = NULL; + + ck_box = elm_check_add(parent); + evas_object_size_hint_weight_set(ck_box, 1.0, 1.0); + evas_object_size_hint_align_set(ck_box, -1.0, 0.5); + elm_check_state_set(ck_box, 0); + evas_object_show(ck_box); + evas_object_repeat_events_set(ck_box, 0); + UG_TRACE_END; + return ck_box; +} + +static void __mf_ug_genlist_show_select_info(void *data) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + + ugData *ugd = itemData->ug_pData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + int iDirCount = 0, iFileCount = 0; + Elm_Object_Item *it = NULL; + + Evas_Object *pGenlist = ugd->ug_MainWindow.ug_pNaviGenlist; + + it = elm_genlist_first_item_get(pGenlist); + while (it) { + itemData = elm_object_item_data_get(it); + if (itemData->ug_bChecked) { + if (ecore_file_is_dir(itemData->ug_pItemName->str)) { + iDirCount++; + } else { + iFileCount++; + } + } + + it = elm_genlist_item_next_get(it); + } + int count = 0; + count = iDirCount + iFileCount; + if (count > 0) { + Evas_Object *notify_popup = NULL; + char lable_file[UG_LABEL_STRING_LENGTH] = { '\0', }; + char *label = NULL; + /*1 TODO: need to update for multi-language */ + + snprintf(lable_file, sizeof(lable_file), "%d", count); + label = g_strconcat(MF_UG_LABEL_SELECTED, "(", lable_file, ")", NULL); + notify_popup = mf_ug_navibar_create_notify_popup(itemData->ug_pData, ugd->ug_MainWindow.ug_pNaviLayout, label, false, NULL); + ugd->ug_MainWindow.ug_pSelectInfoLayout = notify_popup; + UG_SAFE_FREE_CHAR(label); + + } else { + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pSelectInfoLayout); + } + UG_TRACE_END; + +} + +/****************************** +** Prototype : __mf_ug_genlist_checkbox_cb +** Description : Samsung +** Input : void *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_genlist_checkbox_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + ugData *ugd = (ugData *)itemData->ug_pData; + + if (itemData->ug_bChecked == false) { + itemData->ug_bChecked = true; + } else { + itemData->ug_bChecked = false; + } + + if (itemData->ug_pData->ug_UiGadget.ug_iMarkedMode == MARKED_ON) { + __mf_ug_genlist_set_marked_path(&itemData->ug_pData->ug_UiGadget.ug_pMultiSelectFileList, itemData->ug_pItemName); + } + if (itemData->ug_bChecked) { + ugd->ug_Status.ug_iCheckedCount++; + } else { + ugd->ug_Status.ug_iCheckedCount--; + } + if (ugd->ug_MainWindow.ug_pSelectAllCheckBox) { + if (ugd->ug_Status.ug_iTotalCount == ugd->ug_Status.ug_iCheckedCount) { + ugd->ug_Status.ug_bSelectAllChecked = EINA_TRUE; + } else { + ugd->ug_Status.ug_bSelectAllChecked = EINA_FALSE; + } + elm_check_state_pointer_set(ugd->ug_MainWindow.ug_pSelectAllCheckBox, &ugd->ug_Status.ug_bSelectAllChecked); + } + + __mf_ug_genlist_show_select_info(itemData); + mf_ug_ctrl_bar_set_item_disable(itemData->ug_pData); + + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_genlist_create_radio_box +** Description : Samsung +** Input : Evas_Object *parent +** ugListItemData *params +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_genlist_create_radio_box(Evas_Object *parent, ugListItemData *params) +{ + UG_TRACE_BEGIN; + + ugListItemData *itemData = (ugListItemData *)params; + ug_mf_retvm_if(itemData == NULL, NULL, "itemData is NULL"); + + ugData *ugd = (ugData *)(itemData->ug_pData); + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + Evas_Object *radio_box = NULL; + radio_box = elm_radio_add(parent); + elm_radio_state_value_set(radio_box, itemData->ug_iGroupValue); + elm_radio_group_add(radio_box, ugd->ug_MainWindow.ug_pRadioGroup); + elm_radio_value_set(ugd->ug_MainWindow.ug_pRadioGroup, ugd->ug_Status.ug_iRadioOn); + UG_TRACE_END; + return radio_box; +} + + +static bool __mf_ug_list_play_timer_cb(void *data) +{ + ugListItemData *item_data = (ugListItemData *)data; + ugData *ugd = (ugData *)item_data->ug_pData; + + + if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PLAYING || ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PAUSED) { + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, item_data->ug_pItemName->str) == 0) { + mf_ug_list_play_destory_playing_file(ugd); + //mf_ug_list_disable_play_itc(ugd, true); + //mf_ug_list_play_update_item_icon(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } else { + //mf_ug_list_paly_hide_play_icon(ugd); + } + } + mf_ug_cb_list_play_cb(item_data, NULL, NULL); + if (elm_radio_value_get(ugd->ug_MainWindow.ug_pRadioGroup) != item_data->ug_iGroupValue) { + ugd->ug_Status.ug_iRadioOn = item_data->ug_iGroupValue; + item_data->ug_bChecked = true; + elm_radio_value_set(ugd->ug_MainWindow.ug_pRadioGroup, item_data->ug_iGroupValue); + } + + item_data->ug_pData->ug_Status.play_timer = NULL; + return ECORE_CALLBACK_CANCEL; + +} + +/****************************** +** Prototype : __mf_ug_genlist_radio_box_cb +** Description : Samsung +** Input : void *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_genlist_radio_box_cb(void *data, Evas_Object *obj, void *event_info) +{ + + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retm_if(itemData == NULL, "ugListItemData is NULL"); + ugData *ugd = (ugData *)itemData->ug_pData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + itemData->ug_bChecked = true; + itemData->ug_pData->ug_Status.ug_iRadioOn = itemData->ug_iGroupValue; + elm_radio_value_set(itemData->ug_pData->ug_MainWindow.ug_pRadioGroup, itemData->ug_iGroupValue); + mf_ug_ctrl_bar_set_item_disable(itemData->ug_pData); + + + mf_ug_launch_type launch_type = mf_ug_util_get_file_launch_type(itemData->ug_pItemName->str); + if (launch_type == LAUNCH_TYPE_MUSIC) { + if (ugd->ug_Status.play_timer == NULL) { + ug_error(">>>>>>>>>>>>>> entry list play"); + ugd->ug_Status.play_timer = ecore_timer_add(MF_UG_LIST_PLAY_TIME_OUT, (Ecore_Task_Cb)__mf_ug_list_play_timer_cb, itemData); + } else { + ug_error(">>>>>>>>>>>>>> Faild entry list play"); + + } + } + + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_genlist_get_gl_label +** Description : +** Input : const void *data +** Evas_Object *obj +** const char *part +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static char *__mf_ug_genlist_get_gl_label(void *data, Evas_Object *obj, const char *part) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retvm_if(itemData == NULL, NULL, "itemData is NULL"); + + if (strcmp(part, "elm.text") == 0) { + UG_TRACE_END; + if (g_strcmp0(itemData->ug_pItemName->str, PHONE_FOLDER) == 0) { + return g_strdup(MF_UG_LABEL_PHONE); + } else if (g_strcmp0(itemData->ug_pItemName->str, MEMORY_FOLDER) == 0) { + return g_strdup(MF_UG_LABEL_MMC); + } else { + return strdup(ecore_file_file_get(itemData->ug_pItemName->str)); + } + } else if (strcmp(part, "elm.uptitle.text") == 0) { + UG_TRACE_END; + return strdup(("Upper Level")); + } else { + UG_TRACE_END; + return strdup(""); + } +} + + +/****************************** +** Prototype : __mf_ug_genlist_get_thumbnail +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_genlist_get_thumbnail(void *data) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + + const char *dir_icon_path = UG_ICON_FOLDER; + //const char *dir_create_icon_path = UG_ICON_FOLDER_CREATED; + char *icon_path = NULL; + int error_code = MYFILE_ERR_NONE; + int thumbnail_type = 0; + + if (itemData->ug_pThumbPath == NULL) { + if (ecore_file_is_dir(itemData->ug_pItemName->str)) { + itemData->ug_pThumbPath = strdup(dir_icon_path); + itemData->ug_bRealThumbFlag = true; + } else { + thumbnail_type = mf_ug_file_attr_get_file_icon(itemData->ug_pItemName->str, &error_code, &icon_path); + if (icon_path) { + itemData->ug_pThumbPath = strdup(icon_path); + itemData->ug_bRealThumbFlag = true; + free(icon_path); + icon_path = NULL; + } else { /*/must be image/video file */ + + mf_ug_fs_file_type type = UG_FILE_TYPE_NONE; + type = mf_ug_file_attr_get_file_type_by_mime(itemData->ug_pItemName->str); + + if (type == UG_FILE_TYPE_VIDEO) { + itemData->ug_pThumbPath = strdup(UG_ICON_VIDEO); + } else if (type == UG_FILE_TYPE_IMAGE) { + itemData->ug_pThumbPath = strdup(UG_ICON_IMAGE); + } else { + itemData->ug_pThumbPath = strdup(UG_DEFAULT_ICON); + } + itemData->ug_bRealThumbFlag = false; + error_code = MYFILE_ERR_GET_THUMBNAIL_FAILED; + } + } + } else if (itemData->ug_pThumbPath && ecore_file_exists(itemData->ug_pThumbPath)) { + if (itemData->ug_bRealThumbFlag == false) { + error_code = MYFILE_ERR_GET_THUMBNAIL_FAILED; + } + } else if (!ecore_file_exists(itemData->ug_pThumbPath)) { + + ug_debug("ug_pThumbPath[%s] is not exist", itemData->ug_pThumbPath); + free(itemData->ug_pThumbPath); + itemData->ug_pThumbPath = NULL; + /*/set default icon */ + itemData->ug_pThumbPath = strdup(UG_DEFAULT_ICON); + itemData->ug_bRealThumbFlag = false; + error_code = MYFILE_ERR_GET_THUMBNAIL_FAILED; + } +#ifdef UG_THUMB_REAL_TIME_UPDATE + /*/check if we need to add refresh timer */ + if (error_code != 0 && itemData->ug_pData->ug_Status.ug_pThumbUpdateTimer == NULL) { + itemData->ug_pData->ug_Status.ug_pThumbUpdateTimer = ecore_timer_add(INTERVAL_THUMB_UPDATE, mf_ug_cb_thumb_timer_cb, itemData); + } +#endif + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_genlist_create_thumbnail +** Description : Samsung +** Input : void *data +** Evas_Object *parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_genlist_create_thumbnail(void *data, Evas_Object *parent) +{ + + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retvm_if(itemData == NULL, NULL, "itemData is NULL"); + + Evas_Object *thumb = NULL; + +#ifdef USE_IMAGE_OBJECT + thumb = evas_object_image_add(evas_object_evas_get(parent)); +#else + thumb = elm_image_add(parent); +#endif + if (thumb == NULL) { + ug_debug("thumb is NULL"); + } + if (thumb) { +#ifdef USE_IMAGE_OBJECT + int load_err = EVAS_LOAD_ERROR_NONE; + evas_object_image_file_set(thumb, itemData->ug_pThumbPath, NULL); + load_err = evas_object_image_load_error_get(thumb); + + if (load_err != EVAS_LOAD_ERROR_NONE) { + evas_object_del(thumb); + thumb = NULL; + } else { + evas_object_image_filled_set(thumb, EINA_TRUE); + } +#else + elm_image_file_set(thumb, itemData->ug_pThumbPath, NULL); +#endif + } + UG_TRACE_END; + return thumb; +} + + +/****************************** +** Prototype : __mf_ug_genlist_create_mmc_icon +** Description : Samsung +** Input : Evas_Object *parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_genlist_create_mmc_icon(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + Evas_Object *ic_memory = NULL; + const char *memory_icon_path = UG_ICON_MEMORY_SUB; + + ic_memory = elm_image_add(parent); + elm_image_file_set(ic_memory, memory_icon_path, NULL); + evas_object_show(ic_memory); + + UG_TRACE_END; + return ic_memory; +} + + +/****************************** +** Prototype : __mf_ug_genlist_add_checkbox +** Description : Samsung +** Input : void *data +** Evas_Object *parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_genlist_add_checkbox(void *data, Evas_Object *parent) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retvm_if(itemData == NULL, NULL, "itemData is NULL"); + + Evas_Object *check_box = __mf_ug_genlist_create_checkbox(parent); + evas_object_propagate_events_set(check_box, 0); + + elm_check_state_set(check_box, itemData->ug_bChecked); + + itemData->ug_pCheckBox = check_box; + evas_object_smart_callback_add(check_box, "changed", __mf_ug_genlist_checkbox_cb, itemData); + + UG_TRACE_END; + return check_box; +} + + + +/****************************** +** Prototype : __mf_ug_genlist_add_radio_box +** Description : Samsung +** Input : void *data +** Evas_Object *parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_genlist_add_radio_box(void *data, Evas_Object *parent) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retvm_if(itemData == NULL, NULL, "itemData is NULL"); + + Evas_Object *radio_box = __mf_ug_genlist_create_radio_box(parent, itemData); + + evas_object_propagate_events_set(radio_box, 0); + itemData->ug_pRadioBox = radio_box; + evas_object_smart_callback_add(radio_box, "changed", __mf_ug_genlist_radio_box_cb, itemData); + + UG_TRACE_END; + return radio_box; +} + + +static Evas_Object *__mf_ug_genlist_gl_upper_icon_get(void *data, Evas_Object * obj, const char *part) +{ + UG_TRACE_BEGIN; + ugListItemData *listItemData = (ugListItemData *)data; + + ug_mf_retvm_if(listItemData == NULL, NULL, "listItemData is NULL"); + ug_mf_retvm_if(listItemData->ug_pItemName == NULL, NULL, "m_ItemName is NULL"); + ug_mf_retvm_if(part == NULL, NULL, "part is NULL"); + ug_mf_retvm_if(obj == NULL, NULL, "obj is NULL"); + + Evas_Object *thumb = NULL; + if (!strcmp(part, "elm.icon")) { + thumb = elm_image_add(obj); + elm_object_focus_set(thumb, EINA_FALSE); + if (thumb) { + elm_image_file_set(thumb, listItemData->ug_pThumbPath, NULL); + } + } + return thumb; +} + + +static Evas_Object *__mf_ug_genlist_upper_icon_get(void *data, Evas_Object * obj, const char *part) +{ + ug_mf_retvm_if(data == NULL, NULL, "data is NULL"); + ug_mf_retvm_if(obj == NULL, NULL, "obj is NULL"); + + ugData *ugd = (ugData *)data; + + if (!strcmp(part, "elm.icon.1")) { + Evas_Object *btn = elm_button_add(obj); + elm_object_text_set(btn, MF_UG_LABEL_HOME); + evas_object_smart_callback_add(btn, "clicked", mf_ug_cb_home_button_cb, ugd); + return btn; + } else if (!strcmp(part, "elm.icon.2")) { + Evas_Object *btn = elm_button_add(obj); + elm_object_text_set(btn, MF_UG_LABEL_UPPER); + evas_object_smart_callback_add(btn, "clicked", mf_ug_cb_upper_click_cb, ugd); + return btn; + } + return NULL; +} + +/****************************** +** Prototype : __mf_ug_genlist_get_gl_icon +** Description : Samsung +** Input : const void *data +** Evas_Object *obj +** const char *part +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__mf_ug_genlist_get_gl_icon(void *data, Evas_Object *obj, const char *part) +{ + UG_TRACE_BEGIN; + Evas_Object *thumb = NULL, *ic_memory = NULL; + Evas_Object *layout = NULL; + Evas_Object *selected_box = NULL; + + mf_ug_storage_type is_in_mmc = 0; + ugListItemData *listItemData = (ugListItemData *)data; + ug_mf_retv_if(listItemData == NULL, NULL); + ugData *ugd = listItemData->ug_pData; + ug_mf_retv_if(ugd == NULL, NULL); + + if (!strcmp(part, "elm.icon")) { + __mf_ug_genlist_get_thumbnail(listItemData); + thumb = __mf_ug_genlist_create_thumbnail(listItemData, obj); + layout = elm_layout_add(obj); + elm_layout_file_set(layout, UG_EDJ_NAVIGATIONBAR, UG_GRP_LIST); + elm_object_part_content_set(layout, "swallow_thumb", thumb); + + mf_ug_file_attr_get_store_type_by_full(listItemData->ug_pItemName->str, &is_in_mmc); + if (is_in_mmc == MF_UG_MMC) { + ic_memory = __mf_ug_genlist_create_mmc_icon(obj); + elm_object_part_content_set(layout, "myfile.memory_icon.sub", ic_memory); + } + UG_TRACE_END; + return layout; + } else if (!strcmp(part, "elm.icon.1")) { + if (ugd->ug_UiGadget.ug_pMultiSelectFileList) { + if (__mf_ug_genlist_is_file_marked(ugd->ug_UiGadget.ug_pMultiSelectFileList, listItemData->ug_pItemName)) { + listItemData->ug_bChecked = true; + } + } + if (ecore_file_is_dir(listItemData->ug_pItemName->str)) { + if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE) { + selected_box = __mf_ug_genlist_add_checkbox(listItemData, obj); + } else if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE) { + selected_box = __mf_ug_genlist_add_radio_box(listItemData, obj); + } + } else { + if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE + || ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE) { + selected_box = __mf_ug_genlist_add_checkbox(listItemData, obj); + } else if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE + || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + + selected_box = __mf_ug_genlist_add_radio_box(listItemData, obj); + } + } + evas_object_propagate_events_set(selected_box, EINA_FALSE); + return selected_box; + } else if (!strcmp(part, "elm.icon.2")) { + __mf_ug_genlist_get_thumbnail(listItemData); + thumb = __mf_ug_genlist_create_thumbnail(listItemData, obj); + return thumb; + } else if (!strcmp(part, "elm.icon.3")) { +#ifdef LIST_PLAY_SUPPORT + if (!ecore_file_is_dir(listItemData->ug_pItemName->str)) { + Evas_Object *music_icon = NULL; + Evas_Object *music_button = NULL; + mf_ug_launch_type launch_type = mf_ug_util_get_file_launch_type(listItemData->ug_pItemName->str); + ug_error("item name is [%s]", listItemData->ug_pItemName->str); + if (launch_type == LAUNCH_TYPE_MUSIC) { + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, listItemData->ug_pItemName->str) == 0) { + char *play_icon = NULL; + char *pause_icon = NULL; + + music_button = elm_button_add(obj); + elm_object_style_set(music_button, "circle/empty"); + + music_icon = elm_image_add(music_button); + if (ugd->ug_ListPlay.ug_pPlayFilePath) { + if (g_strcmp0(ugd->ug_ListPlay.ug_pPlayFilePath, listItemData->ug_pItemName->str) == 0) { + if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PLAYING) { + pause_icon = strdup(UG_ICON_MUSIC_PAUSE_WHITE); + elm_image_file_set(music_icon, pause_icon, NULL); + } else if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PAUSED) { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } else { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } + } else { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } + } else { + play_icon = strdup(UG_ICON_MUSIC_PLAY_WHITE); + elm_image_file_set(music_icon, play_icon, NULL); + } + evas_object_size_hint_aspect_set(music_icon, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + elm_object_part_content_set(music_button, "icon", music_icon); + evas_object_propagate_events_set(music_button, EINA_FALSE); + evas_object_smart_callback_add(music_button, "clicked", (Evas_Smart_Cb)mf_ug_cb_list_play_cb, (void*)listItemData); + evas_object_smart_callback_add(music_button, "pressed", mf_ug_cb_play_button_pressed_cb, ugd); + evas_object_smart_callback_add(music_button, "unpressed", mf_ug_cb_play_button_unpressed_cb, ugd); + listItemData->ug_pPlaybtn = music_button; + UG_TRACE_END; + return music_button; + } + } + } +#endif + UG_TRACE_END; + + return NULL; + + } else { + UG_TRACE_END; + return NULL; + } +} + +static Evas_Object *__mf_ug_genlist_get_gl_editfiled_icon(void *data, Evas_Object *obj, const char *part) +{ + ugListItemData *listItemData = (ugListItemData *)data; + ug_mf_retv_if(listItemData == NULL, NULL); + ugData *ugd = listItemData->ug_pData; + ug_mf_retv_if(ugd == NULL, NULL); + + ug_debug("listItemData is [%p]", listItemData); + + if (!strcmp(part, "elm.icon")) { + Evas_Object *button = NULL; + button = elm_button_add(obj); + evas_object_propagate_events_set(button, EINA_FALSE); + elm_object_text_set(button, MF_UG_LABEL_GO_TO_MYFILES); + evas_object_smart_callback_add(button, "clicked", mf_ug_cb_goto_myfile_button_cb, ugd); + if(listItemData->ug_pItem) + elm_genlist_item_select_mode_set(listItemData->ug_pItem, ELM_OBJECT_SELECT_MODE_NONE); + return button; + } + return NULL; +} + +/****************************** +** Prototype : __mf_ug_genlist_get_gl_state +** Description : +** Input : const void *data +** Evas_Object *obj +** const char *part +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Eina_Bool __mf_ug_genlist_get_gl_state(void *data, Evas_Object *obj, const char *part) +{ + return EINA_FALSE; +} + + +/****************************** +** Prototype : __mf_ug_genlist_del_gl +** Description : +** Input : const void *data +** Evas_Object *obj +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_genlist_del_gl(void *data, Evas_Object *obj) +{ + UG_TRACE_BEGIN; + ugListItemData *itemData = (ugListItemData *)data; + ug_mf_retm_if(itemData == NULL, "itemData is NULL"); + if (itemData->ug_pItemName && itemData->ug_pItemName->str) { + g_string_free(itemData->ug_pItemName, TRUE); + itemData->ug_pItemName = NULL; + } + if (itemData->ug_pThumbPath) { + free(itemData->ug_pThumbPath); + itemData->ug_pThumbPath = NULL; + } + free(itemData); + itemData = NULL; + UG_TRACE_END; + return; +} + + + +/****************************** +** Prototype : mf_ug_genlist_selected_gl +** Description : Samsung +** Input : void *data +** Evas_Object *obj +** void *event_info +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ + +void mf_ug_genlist_selected_gl(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Elm_Object_Item *item = (Elm_Object_Item *) event_info; + int error_code = 0; + int mmc_card = 0; + error_code = mf_ug_util_get_mmc_state(&mmc_card); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + if (item != NULL) { + ugListItemData *selected = (ugListItemData *)elm_object_item_data_get(item); + fprintf(stdout, "selected text %s\n", (char *)selected->ug_pItemName->str); + elm_genlist_item_selected_set(item, EINA_FALSE); + if (ugd->ug_Status.ug_b_NaviPushFlag) + return; + if (!ecore_file_is_dir(selected->ug_pItemName->str)) { + + if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE) { + return; + } + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE) { + mf_ug_launch_type launch_type = mf_ug_util_get_file_launch_type(selected->ug_pItemName->str); + if (launch_type == LAUNCH_TYPE_MUSIC) { + if (ugd->ug_Status.play_timer == NULL) { + ug_error(">>>>>>>>>>>>>> entry list play"); + ugd->ug_Status.play_timer = ecore_timer_add(MF_UG_LIST_PLAY_TIME_OUT, (Ecore_Task_Cb)__mf_ug_list_play_timer_cb, selected); + } else { + ug_error(">>>>>>>>>>>>>> Faild entry list play"); + + } + } else { + if (elm_radio_value_get(ugd->ug_MainWindow.ug_pRadioGroup) != selected->ug_iGroupValue) { + ugd->ug_Status.ug_iRadioOn = selected->ug_iGroupValue; + selected->ug_bChecked = true; + elm_radio_value_set(ugd->ug_MainWindow.ug_pRadioGroup, selected->ug_iGroupValue); + } + } + + + } else { + if (selected->ug_bChecked == 0) { + selected->ug_bChecked = 1; + } else { + selected->ug_bChecked = 0; + } + elm_check_state_set(selected->ug_pCheckBox, selected->ug_bChecked); + + if (selected->ug_bChecked) { + ugd->ug_Status.ug_iCheckedCount++; + } else { + ugd->ug_Status.ug_iCheckedCount--; + } + if (ugd->ug_MainWindow.ug_pSelectAllCheckBox) { + if (ugd->ug_Status.ug_iTotalCount == ugd->ug_Status.ug_iCheckedCount) { + ugd->ug_Status.ug_bSelectAllChecked = EINA_TRUE; + } else { + ugd->ug_Status.ug_bSelectAllChecked = EINA_FALSE; + } + elm_check_state_pointer_set(ugd->ug_MainWindow.ug_pSelectAllCheckBox, &ugd->ug_Status.ug_bSelectAllChecked); + } + __mf_ug_genlist_show_select_info(selected); + } + } else if (ecore_file_is_dir(selected->ug_pItemName->str) && strcmp(selected->ug_pItemName->str, "Upper Level")) { + if (ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PLAYING || ugd->ug_ListPlay.ug_iPlayState == PLAY_STATE_PAUSED) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + if (ugd->ug_Status.ug_pPath) { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + ugd->ug_Status.ug_pPath = g_string_new(selected->ug_pItemName->str); + ugd->ug_Status.ug_b_NaviPushFlag = true; + + if (pNavi_s->ug_pCurrentPath != NULL) { + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + } + pNavi_s->ug_pCurrentPath = strdup(selected->ug_pItemName->str); + mf_ug_navi_bar_create_default_view(ugd); + } + + mf_ug_ctrl_bar_set_item_disable(ugd); + } + UG_TRACE_END; +} + + +static Evas_Object *__mf_ug_genlist_create_editfield(Evas_Object *parent, Evas_Object **pEntry) +{ + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *layout = elm_layout_add(parent); + elm_layout_theme_set(layout, "layout", "editfield", "default"); + Evas_Object *entry = elm_entry_add(parent); + elm_object_part_content_set(layout, "elm.swallow.content", entry); + *pEntry = entry; + return layout; +} + +static Evas_Object *__mf_ug_genlist_gl_new_folder_icon_get(void *data, Evas_Object * obj, const char *part) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + if (!strcmp(part, "elm.icon")) { + int error_code = 0; + char *fileName = NULL; + char *fullpath = (char *)malloc(sizeof(char) * MYFILE_FILE_PATH_LEN_MAX); + if (fullpath == NULL) { + return NULL; + } + GString *dest_fullpath; + static Elm_Entry_Filter_Limit_Size limit_filter; + Evas_Object *entry = NULL; + + Evas_Object *edit_field = __mf_ug_genlist_create_editfield(obj, &entry); + + elm_entry_single_line_set(entry, EINA_TRUE); + elm_entry_scrollable_set(entry, EINA_TRUE); + + elm_object_signal_emit(edit_field, "elm,state,eraser,show", "elm"); + + evas_object_size_hint_weight_set(edit_field, 1, 1); + evas_object_size_hint_align_set(edit_field, 1, 0.5); + //evas_object_show(edit_field); + ugd->ug_MainWindow.ug_pEditField = edit_field; + + ugd->ug_MainWindow.ug_pEntry = entry; + + limit_filter.max_char_count = MYFILE_FILE_NAME_LEN_MAX; + limit_filter.max_byte_count = 0; + + memset(fullpath, 0, MYFILE_FILE_PATH_LEN_MAX); + fileName = elm_entry_markup_to_utf8(MF_UG_LABEL_FOLDER); + snprintf(fullpath, (MYFILE_FILE_PATH_LEN_MAX), "%s/%s", (char *)ugd->ug_Status.ug_pPath->str, fileName); + + dest_fullpath = g_string_new(fullpath); + + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter); + evas_object_smart_callback_add(entry, "maxlength,reached", mf_ug_cb_reach_max_len_cb, ugd); + + if (mf_ug_fm_svc_wrapper_detect_duplication(dest_fullpath)) { + ug_debug("dectetion result is TRUE\ndest_fullpath is %s\n", dest_fullpath->str); + error_code = mf_ug_fm_svc_wrapper_file_auto_rename(ugd, dest_fullpath, FILE_NAME_WITH_BRACKETS, &dest_fullpath); + ug_debug("rename result is %s\n", dest_fullpath->str); + memset(fullpath, 0, strlen(fullpath)); + int len = strlen(ugd->ug_Status.ug_pPath->str) + 1; + strncpy(fullpath, dest_fullpath->str + len, MYFILE_FILE_PATH_LEN_MAX); + /*memset(fileName,0,strlen(fileName));*/ + + UG_SAFE_FREE_CHAR(fileName); + fileName = elm_entry_markup_to_utf8(fullpath); + } + + /*elm_entry_entry_set(entry, ecore_file_file_get(params->m_ItemName->str));*/ + + elm_object_signal_callback_add(edit_field, "elm,eraser,clicked", "elm", mf_ug_cb_eraser_clicked_cb, entry); + + evas_object_show(entry); + elm_object_focus_set(entry, EINA_TRUE); + + elm_entry_entry_set(entry, fileName); + elm_entry_cursor_end_set(entry); + UG_SAFE_FREE_CHAR(fullpath); + UG_SAFE_FREE_GSTRING(dest_fullpath); + UG_SAFE_FREE_CHAR(fileName); + return edit_field; + } + return NULL; +} + +Evas_Object *mf_ug_genlist_create_list_new_folder_style(void *data) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + Evas_Object *genlist = NULL; + Evas_Object *pNaviBar = NULL; + + pNaviBar = ugd->ug_MainWindow.ug_pNaviBar; + + genlist = elm_genlist_add(pNaviBar); + elm_object_focus_set(genlist, EINA_FALSE); + + ugd->ug_Status.ug_newfolderitec.item_style = "1icon"; + ugd->ug_Status.ug_newfolderitec.func.text_get = NULL; + ugd->ug_Status.ug_newfolderitec.func.content_get = __mf_ug_genlist_gl_new_folder_icon_get; + ugd->ug_Status.ug_newfolderitec.func.state_get = NULL; + ugd->ug_Status.ug_newfolderitec.func.del = NULL; + + Elm_Object_Item *it = elm_genlist_item_append(genlist, &ugd->ug_Status.ug_newfolderitec, ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_NONE); + return genlist; +} + +/****************************** +** Prototype : __mf_ug_genlist_create_gl +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +Evas_Object *__mf_ug_genlist_create_gl(void *data) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + ugNaviBar *pNaviInUse = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retvm_if(pNaviInUse == NULL, NULL, "pNaviInUse is NULL"); + + Evas_Object *genlist; + genlist = elm_genlist_add(ugd->ug_MainWindow.ug_pNaviBar); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + + evas_object_smart_callback_add(genlist, "selected", mf_ug_genlist_selected_gl, ugd); + +#ifdef UG_THUMB_REAL_TIME_UPDATE + if (ugd->ug_Status.ug_pThumbUpdateTimer != NULL) { + ecore_timer_del(ugd->ug_Status.ug_pThumbUpdateTimer); + ugd->ug_Status.ug_pThumbUpdateTimer = NULL; + } +#endif + + ugd->ug_Status.ug_itc.item_style = "1text.3icon"; + ugd->ug_Status.ug_itc.func.text_get = __mf_ug_genlist_get_gl_label; + ugd->ug_Status.ug_itc.func.content_get = __mf_ug_genlist_get_gl_icon; + ugd->ug_Status.ug_itc.func.state_get = __mf_ug_genlist_get_gl_state; + ugd->ug_Status.ug_itc.func.del = __mf_ug_genlist_del_gl; + + if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + ugd->ug_Status.ug_normalitc.item_style = "1text.1icon.2"; + ugd->ug_Status.ug_normalitc.func.text_get = __mf_ug_genlist_get_gl_label; + ugd->ug_Status.ug_normalitc.func.content_get = __mf_ug_genlist_get_gl_icon; + ugd->ug_Status.ug_normalitc.func.state_get = __mf_ug_genlist_get_gl_state; + ugd->ug_Status.ug_normalitc.func.del = __mf_ug_genlist_del_gl; + } + + UG_TRACE_END; + + return genlist; +} + + +/****************************** +** Prototype : __mf_ug_genlist_init_item_data +** Description : Samsung +** Input : void *data +** ugListItemData **itemData +** char *fullname +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_genlist_init_item_data(void *data, ugListItemData **itemData, char *fullname) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ugListItemData **ug_ItemData = itemData; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + ug_mf_retm_if(ug_ItemData == NULL, "ug_ItemData is NULL"); + + *ug_ItemData = (ugListItemData *)malloc(sizeof(ugListItemData)); + if (*ug_ItemData == NULL) { + ug_debug("ug_ItemData malloc failed"); + } else { + memset(*ug_ItemData, 0, sizeof(ugListItemData)); + if (fullname) { + (*ug_ItemData)->ug_pItemName = g_string_new(fullname); + } else { + (*ug_ItemData)->ug_pItemName = NULL; + } + (*ug_ItemData)->ug_bChecked = false; + (*ug_ItemData)->ug_pRadioBox = NULL; + (*ug_ItemData)->ug_pCheckBox = NULL; + (*ug_ItemData)->ug_pPlaybtn = NULL; + (*ug_ItemData)->ug_iGroupValue = 0; + (*ug_ItemData)->ug_pItem = NULL; + (*ug_ItemData)->ug_pThumbPath = NULL; + (*ug_ItemData)->ug_bRealThumbFlag = false; + (*ug_ItemData)->ug_pData = ugd; + } + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_genlist_create_content_list_view +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_genlist_upper_style_set(void *data) +{ + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + ugd->ug_Status.ug_topitc.item_style = "1text.1icon.2"; + ugd->ug_Status.ug_topitc.func.text_get = __mf_ug_genlist_get_gl_label; + ugd->ug_Status.ug_topitc.func.content_get = __mf_ug_genlist_gl_upper_icon_get; + ugd->ug_Status.ug_topitc.func.state_get = __mf_ug_genlist_get_gl_state; + ugd->ug_Status.ug_topitc.func.del = __mf_ug_genlist_del_gl; +} + +void mf_ug_genlist_goto_myfile_style_set(void *data) +{ + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + ugd->ug_Status.ug_editfileditc.item_style = "1icon"; + ugd->ug_Status.ug_editfileditc.func.text_get = NULL; + ugd->ug_Status.ug_editfileditc.func.content_get = __mf_ug_genlist_get_gl_editfiled_icon; + ugd->ug_Status.ug_editfileditc.func.state_get = NULL; + ugd->ug_Status.ug_editfileditc.func.del = __mf_ug_genlist_del_gl; + + ugd->ug_Status.ug_editfiledBottomSeperatoritc.item_style = "dialogue/separator/11/with_line"; + ugd->ug_Status.ug_editfiledBottomSeperatoritc.func.text_get = NULL; + ugd->ug_Status.ug_editfiledBottomSeperatoritc.func.content_get = NULL; + ugd->ug_Status.ug_editfiledBottomSeperatoritc.func.state_get = NULL; + ugd->ug_Status.ug_editfiledBottomSeperatoritc.func.del = NULL; + + ugd->ug_Status.ug_editfiledUpperSeperatoritc.item_style = "dialogue/separator/10"; + ugd->ug_Status.ug_editfiledUpperSeperatoritc.func.text_get = NULL; + ugd->ug_Status.ug_editfiledUpperSeperatoritc.func.content_get = NULL; + ugd->ug_Status.ug_editfiledUpperSeperatoritc.func.state_get = NULL; + ugd->ug_Status.ug_editfiledUpperSeperatoritc.func.del = NULL; + +} + +Evas_Object *mf_navi_bar_upper_create(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *upper_genlist = NULL; + upper_genlist = elm_genlist_add(parent); + ug_mf_retvm_if(upper_genlist == NULL, NULL, "upper_genlist is NULL"); + elm_object_focus_set(upper_genlist, EINA_FALSE); + evas_object_size_hint_weight_set(upper_genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(upper_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_scroller_bounce_set(upper_genlist, EINA_FALSE, EINA_FALSE); + evas_object_show(upper_genlist); + UG_TRACE_END; + return upper_genlist; + +} + + +void mf_ug_upper_genlist_item_append(Evas_Object *pGenlist, void *data) +{ + ug_mf_retm_if(data == NULL, "data is NULL"); + ug_mf_retm_if(pGenlist == NULL, "pGenlist is NULL"); + ugData *ugd = (ugData *)data; + + Elm_Object_Item *item = NULL; + + ugd->ug_Status.ug_topitc.item_style = "dialogue/bg/2icon"; + ugd->ug_Status.ug_topitc.func.text_get = NULL; + ugd->ug_Status.ug_topitc.func.content_get = __mf_ug_genlist_upper_icon_get; + ugd->ug_Status.ug_topitc.func.state_get = NULL; + ugd->ug_Status.ug_topitc.func.del = NULL; + ugd->ug_Status.ug_separtor_no_bottom_line_itc.item_style = "dialogue/seperator.4"; + ugd->ug_Status.ug_separtor_no_bottom_line_itc.func.text_get = NULL; + ugd->ug_Status.ug_separtor_no_bottom_line_itc.func.content_get = NULL; + ugd->ug_Status.ug_separtor_no_bottom_line_itc.func.state_get = NULL; + ugd->ug_Status.ug_separtor_no_bottom_line_itc.func.del = NULL; + + ugd->ug_Status.ug_separtor_with_bottom_line_itc.item_style = "dialogue/seperator.2"; + ugd->ug_Status.ug_separtor_with_bottom_line_itc.func.text_get = NULL; + ugd->ug_Status.ug_separtor_with_bottom_line_itc.func.content_get = NULL; + ugd->ug_Status.ug_separtor_with_bottom_line_itc.func.state_get = NULL; + ugd->ug_Status.ug_separtor_with_bottom_line_itc.func.del = NULL; + + // separator with no bottom line + item = elm_genlist_item_append(pGenlist, &ugd->ug_Status.ug_separtor_no_bottom_line_itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + // button for dialogue item (dialogue bg) + elm_genlist_item_append(pGenlist, &ugd->ug_Status.ug_topitc, (void *) ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + // separator with bottom line + item = elm_genlist_item_append(pGenlist, &ugd->ug_Status.ug_separtor_with_bottom_line_itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); +} + +void mf_ug_genlist_goto_myfile_item_append(Evas_Object *pGenlist, void *data) +{ + ug_mf_retm_if(pGenlist == NULL, "pGenlist is NULL"); + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + ugListItemData *ug_ItemData; + Elm_Object_Item *it = NULL; + + __mf_ug_genlist_init_item_data(ugd, &ug_ItemData, NULL); + ug_debug("ug_ItemData is [%p]", &ug_ItemData); + + //it = elm_genlist_item_append(pGenlist, &ugd->ug_Status.ug_editfiledUpperSeperatoritc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, + // NULL); + //elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + it = elm_genlist_item_append(pGenlist, &ugd->ug_Status.ug_editfileditc, ug_ItemData, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + ug_ItemData->ug_pItem = it; + //elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + //it = elm_genlist_item_append(pGenlist, &ugd->ug_Status.ug_editfiledBottomSeperatoritc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, + // NULL); + //elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); +} + +Elm_Object_Item *mf_ug_genlist_item_append(Evas_Object *parent, + ugFsNodeInfo *pNode, + void *data, + int groudValue, + Elm_Genlist_Item_Class *itc) +{ + ug_mf_retvm_if(parent == NULL, NULL, "pGenlist is NULL"); + ug_mf_retvm_if(pNode == NULL, NULL, "pNode is NULL"); + ug_mf_retvm_if(data == NULL, NULL, "data is NULL"); + ug_mf_retvm_if(itc == NULL, NULL, "itc is NULL"); + + ugData *ugd = (ugData *)data; + ugListItemData *ug_ItemData = NULL; + Elm_Object_Item *it = NULL; + char *real_name = NULL; + + real_name = g_strconcat(pNode->path, "/", pNode->name, NULL); + __mf_ug_genlist_init_item_data(ugd, &ug_ItemData, real_name); + if (ug_ItemData == NULL) { + ug_debug("alloc memory error\n"); + if (real_name) { + free(real_name); + real_name = NULL; + } + return NULL; + } + + if (ugd->ug_Status.ug_iViewType == mf_ug_view_root) { + if(g_strcmp0(real_name, PHONE_FOLDER) == 0) { + ug_ItemData->ug_pThumbPath = strdup(UG_ICON_ITEM_PHONE); + ug_ItemData->ug_bRealThumbFlag = true; + + } else if(g_strcmp0(real_name, MEMORY_FOLDER) == 0) { + ug_ItemData->ug_pThumbPath = strdup(UG_ICON_ITEM_MMC); + ug_ItemData->ug_bRealThumbFlag = true; + } + } + + ug_ItemData->ug_iGroupValue = groudValue; + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + if (__mf_ug_genlist_is_file_marked(ugd->ug_UiGadget.ug_pMultiSelectFileList, ug_ItemData->ug_pItemName)) { + ug_ItemData->ug_bChecked = true; + ugd->ug_Status.ug_iRadioOn = ug_ItemData->ug_iGroupValue; + } + } + it = elm_genlist_item_append(parent, itc, ug_ItemData, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + ug_ItemData->ug_pItem = it; + + if (real_name) { + free(real_name); + real_name = NULL; + } + + return it; +} + + +Evas_Object *mf_ug_genlist_create_layout(Evas_Object *parent, const char *group_name, + double x_weight, double y_weight, + double x_align, double y_align) +{ + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + ug_mf_retvm_if(group_name == NULL, NULL, "group_name is NULL"); + + Evas_Object *layout = elm_layout_add(parent); + + ug_mf_retvm_if(layout == NULL, NULL, "layout is NULL"); + + elm_object_focus_set(layout, EINA_FALSE); + + Eina_Bool result = elm_layout_file_set(layout, UG_EDJ_NAVIGATIONBAR, group_name); + + if (result == EINA_TRUE) + { + evas_object_size_hint_weight_set(layout, x_weight, y_weight); + evas_object_size_hint_align_set(layout, x_align, y_align); + + evas_object_show(layout); + } + + return layout; +} + +Evas_Object *mf_ug_genlist_create_default_layout(Evas_Object *parent, const char *group_name) +{ + return mf_ug_genlist_create_layout(parent, group_name, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND, + EVAS_HINT_FILL, EVAS_HINT_FILL); +} + + +Evas_Object *mf_ug_genlist_no_mem_card(void *data) +{ + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + Evas_Object *nocontent = mf_ug_genlist_create_default_layout(ugd->ug_MainWindow.ug_pMainLayout, UG_GRP_NO_CONTENT); + elm_object_signal_emit(nocontent, "show,no,memcard", "elm"); + elm_object_part_text_set(nocontent, "message", MF_UG_LABEL_NO_MEM_CARD); + + ugd->ug_Status.ug_bNoContentFlag = true; + return nocontent; +} + + +Evas_Object *mf_ug_genlist_create_no_content(void *data) +{ + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + Evas_Object *nocontent = NULL; + + nocontent = elm_layout_add(ugd->ug_MainWindow.ug_pMainLayout); + elm_layout_theme_set(nocontent, "layout", "nocontents", "text"); + elm_object_part_text_set(nocontent, "elm.text", MF_UG_LABEL_NO_FILES); + + ugd->ug_Status.ug_bNoContentFlag = true; + + return nocontent; +} + +Evas_Object *mf_ug_genlist_create_content_list_view(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + ugNaviBar *pNaviInUse = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retvm_if(pNaviInUse == NULL, NULL, "pNaviInUse is NULL"); + + Evas_Object *genlist; + int error_code = 0; + Eina_List *dir_list = NULL; + Eina_List *file_list = NULL; + Elm_Object_Item *it = NULL; + int groupValue = 1; + int count = 0; + + ugListItemData *ug_ItemData; + + ugd->ug_Status.ug_iRadioOn = 0; + ugd->ug_Status.ug_bNoContentFlag = false; + + + GString *fullpath = g_string_new(ugd->ug_Status.ug_pPath->str); + + + + error_code = mf_ug_fm_svc_wapper_get_file_list_by_filter(ugd, fullpath, &dir_list, &file_list); + if (error_code == 0) { + + if (ugd->ug_UiGadget.ug_pDirList) { + mf_ug_util_free_eina_list_data(&ugd->ug_UiGadget.ug_pDirList, NODE_TYPE_PNODE); + ugd->ug_UiGadget.ug_pDirList = NULL; + } + if (ugd->ug_UiGadget.ug_pFilterList) { + mf_ug_util_free_eina_list_data(&ugd->ug_UiGadget.ug_pFilterList, NODE_TYPE_PNODE); + ugd->ug_UiGadget.ug_pFilterList = NULL; + } + + ugd->ug_UiGadget.ug_pFilterList = file_list; + ugd->ug_UiGadget.ug_pDirList = dir_list; + mf_ug_util_sort_the_file_list(ugd); + + } + + + /* list option set */ + unsigned int dir_list_len = eina_list_count(dir_list); + unsigned int filter_file_list_len = eina_list_count(ugd->ug_UiGadget.ug_pFilterList); + ug_debug("error_code is [%d]dir_list_len is [%d]file_list_len is [%d]\n", error_code, dir_list_len, filter_file_list_len); + + + if ((dir_list_len == 0 && filter_file_list_len == 0)) { + ug_debug("=========================================== create the no content view"); + mf_ug_util_add_dir_watch(fullpath->str, ugd); + g_string_free(fullpath, true); + fullpath = NULL; + return mf_ug_genlist_create_no_content(ugd); + } + + genlist = __mf_ug_genlist_create_gl(ugd); + + ugd->ug_MainWindow.ug_pNaviGenlist = genlist; + ugFsNodeInfo *pNode = NULL; + Eina_List *l = NULL; + + EINA_LIST_FOREACH(ugd->ug_UiGadget.ug_pDirList, l, pNode) { + count++; + + + if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || + ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE || + ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + + mf_ug_genlist_item_append(genlist, pNode, ugd, 0, &ugd->ug_Status.ug_normalitc); + } else { + mf_ug_genlist_item_append(genlist, pNode, ugd, groupValue, &ugd->ug_Status.ug_itc); + groupValue++; + } + } + + EINA_LIST_FOREACH(ugd->ug_UiGadget.ug_pFilterList, l, pNode) { + count++; + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + mf_ug_genlist_item_append(genlist, pNode, ugd, groupValue, &ugd->ug_Status.ug_itc); + groupValue++; + } else if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE) { + mf_ug_genlist_item_append(genlist, pNode, ugd, 0, &ugd->ug_Status.ug_normalitc); + } else { + mf_ug_genlist_item_append(genlist, pNode, ugd, 0, &ugd->ug_Status.ug_itc); + } + } + + if (fullpath != NULL) { + if ( !mf_ug_fm_svc_wapper_is_root_path(ugd->ug_Status.ug_pPath) ) { + mf_ug_util_add_dir_watch(fullpath->str, ugd); + } + g_string_free(fullpath, TRUE); + } + UG_TRACE_END; + return genlist; +} + +static char *__get_title_gl_text(void *data, Evas_Object *obj, const char *part) +{ + if (data) + return g_strdup((char *)data); + else + return NULL; +} +static void __del_title_gl(void *data, Evas_Object * obj) +{ + UG_SAFE_FREE_CHAR(data); +} + +Evas_Object *mf_ug_genlist_create_path_info(Evas_Object *parent, Elm_Genlist_Item_Class *itc, char *info) +{ + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *genlist = NULL; + Elm_Object_Item *git=NULL; + + genlist = elm_genlist_add(parent); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + + itc->item_style = "grouptitle"; + itc->func.text_get = __get_title_gl_text; + itc->func.del = __del_title_gl; + + git = elm_genlist_item_append(genlist, itc, info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + return genlist; +} + +void mf_ug_genlist_item_remove(Evas_Object *parent, const char *path) +{ + ug_debug("path is [%s]", path); + ug_mf_retm_if(parent == NULL, "parent is NULL"); + ug_mf_retm_if(path == NULL, "path is NULL"); + + ugListItemData *itemData = NULL; + Elm_Object_Item *it = NULL; + + it = elm_genlist_first_item_get(parent); + while (it) { + itemData = elm_object_item_data_get(it); + if (itemData->ug_pItemName == NULL || itemData->ug_pItemName->str == NULL) { + continue; + } + ug_debug("itemData->m_ItemName->str is [%s]", itemData->ug_pItemName->str); + if (g_strcmp0(path, itemData->ug_pItemName->str) == 0) { + elm_object_item_del(it); + break; + } + + it = elm_genlist_item_next_get(it); + } + +} + diff --git a/src/widget/mf-ug-navi-bar.c b/src/widget/mf-ug-navi-bar.c new file mode 100644 index 0000000..d50e530 --- /dev/null +++ b/src/widget/mf-ug-navi-bar.c @@ -0,0 +1,956 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mf-ug-winset.h" +#include "mf-ug-cb.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-util.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-resource.h" + + +/****************************** +** Prototype : __mf_ug_navi_bar_create_group_radio_box +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_navi_bar_create_group_radio_box(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Evas_Object *group_radio = NULL; + + if (ugd->ug_MainWindow.ug_pRadioGroup != NULL) { + evas_object_del(ugd->ug_MainWindow.ug_pRadioGroup); + ugd->ug_MainWindow.ug_pRadioGroup = NULL; + } + + group_radio = elm_radio_add(ugd->ug_MainWindow.ug_pMainLayout); + ug_mf_retm_if(group_radio == NULL, "ugd is NULL"); + + elm_radio_value_set(group_radio, 0); + evas_object_hide(group_radio); + /*/Internal/invisible Radio Objects used to group the radio buttons in the list. */ + ugd->ug_MainWindow.ug_pRadioGroup = group_radio; + UG_TRACE_END; +} + + +/****************************** +** Prototype : __mf_ug_navi_bar_push_content +** Description : Samsung +** Input : ugData *data +** Evas_Object *NaviContent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static void __mf_ug_navi_bar_push_content(void *data, Evas_Object *NaviContent) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "pNavi_s is NULL"); + ugData *ugd = (ugData *)data; + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + + Evas_Object *NaviBar = ugd->ug_MainWindow.ug_pNaviBar; + char *title = NULL; + + ugd->ug_MainWindow.ug_pPreNaviItem = ugd->ug_MainWindow.ug_pNaviItem; + + if (pNavi_s) { + if(!g_strcmp0(pNavi_s->ug_pNaviTitle, "Ringtones")) { + if (pNavi_s->ug_pNaviTitle) { + g_free(pNavi_s->ug_pNaviTitle); + pNavi_s->ug_pNaviTitle = NULL; + } + pNavi_s->ug_pNaviTitle = g_strdup(MF_UG_LABEL_RINGTONES); + } else if(!g_strcmp0(pNavi_s->ug_pNaviTitle, "Alarms")) { + if (pNavi_s->ug_pNaviTitle) { + g_free(pNavi_s->ug_pNaviTitle); + pNavi_s->ug_pNaviTitle = NULL; + } + pNavi_s->ug_pNaviTitle = g_strdup(MF_UG_LABEL_ALARM); + } else if (!g_strcmp0(pNavi_s->ug_pNaviTitle, "Alerts")) { + } + title = pNavi_s->ug_pNaviTitle; + } + ug_debug("title=%s", title); + + ugd->ug_MainWindow.ug_pNaviItem = elm_naviframe_item_push(NaviBar, title, NULL, NULL, NaviContent, NULL); + + UG_TRACE_END; +} + + +static Eina_Bool __mf_widget_notify_popup_timer_cb(void *data) +{ + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, EINA_FALSE, "ugd is null"); + + elm_object_part_content_unset(ugd->ug_MainWindow.ug_pNaviLayout, + "sel_contents"); + + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pSelectInfoLayout); + ugd->ug_Status.pPopupTimer = NULL; + return false; +} + +Evas_Object *mf_ug_navibar_create_notify_popup(void *data, + Evas_Object *parent, + char *label, + bool time_out, + void func(void *data, Evas_Object *obj, void *event_info)) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(data == NULL, NULL, "data is NULL"); + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + ug_mf_retvm_if(label == NULL, NULL, "label is NULL"); + ugData *ugd = (ugData *)data; + + + Evas_Object *countlabel = NULL; + if (ugd->ug_MainWindow.ug_pSelectInfoLayout && ugd->ug_Status.pPopupTimer) { + elm_object_part_text_set(ugd->ug_MainWindow.ug_pSelectInfoLayout, "elm.text", label); + countlabel = ugd->ug_MainWindow.ug_pSelectInfoLayout; + } else { + elm_object_part_content_unset(ugd->ug_MainWindow.ug_pNaviLayout, + "sel_contents"); + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pSelectInfoLayout); + countlabel = elm_layout_add(parent); + evas_object_size_hint_weight_set(countlabel, + EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(countlabel, + EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_layout_theme_set(countlabel, "standard", "selectioninfo", "center_text"); + elm_object_part_text_set(countlabel, "elm.text", label); + elm_object_part_content_set(parent, + "sel_contents", + countlabel); + elm_object_signal_emit(countlabel, "show,selection,info", "elm"); + } + + UG_SAFE_DEL_ECORE_TIMER(ugd->ug_Status.pPopupTimer); + if (time_out) { + ugd->ug_Status.pPopupTimer = ecore_timer_add(3, __mf_widget_notify_popup_timer_cb, ugd); + } + + evas_object_show(countlabel); + UG_TRACE_END; + return countlabel; + + +} + +/****************************** +** Prototype : mf_ug_navi_bar_create_navi_bar +** Description : +** Input : Evas_Object* parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +Evas_Object *mf_ug_navi_bar_create_navi_bar(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + Evas_Object *navi_bar = NULL; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + navi_bar = elm_naviframe_add(parent); + ug_mf_retvm_if(navi_bar == NULL, NULL, "Failed elm_navigationbar_add"); + elm_naviframe_prev_btn_auto_pushed_set(navi_bar, EINA_FALSE); + + evas_object_show(navi_bar); + + UG_TRACE_END; + return navi_bar; +} + + +/****************************** +** Prototype : mf_ug_navi_bar_set_new_content +** Description : Samsung +** Input : Evas_Object *pLayout +** Evas_Object *NaviContent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_navi_bar_set_new_content(Evas_Object *pLayout, Evas_Object *NaviContent) +{ + UG_TRACE_BEGIN; + Evas_Object *unUsed = elm_object_part_content_unset(pLayout, "part1"); + evas_object_del(unUsed); + elm_object_part_content_set(pLayout, "part1", NaviContent); + UG_TRACE_END; +} + +Evas_Object *mf_ug_navi_bar_create_box(Evas_Object * parent) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *box = NULL; + box = elm_box_add(parent); + ug_mf_retvm_if(box == NULL, NULL, "box is NULL"); + elm_object_focus_set(box, EINA_FALSE); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_FILL); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_clear(box); + evas_object_show(box); + UG_TRACE_END; + return box; + +} + +Evas_Object *mf_ug_navi_bar_create_layout(Evas_Object *parent, const char *edj, const char *grp_name) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + ug_mf_retvm_if(edj == NULL, NULL, "edj is NULL"); + ug_mf_retvm_if(grp_name == NULL, NULL, "grp_name is NULL"); + + Evas_Object *layout = NULL; + + layout = elm_layout_add(parent); + ug_mf_retvm_if(layout == NULL, NULL, "layout is NULL"); + elm_object_focus_set(layout, EINA_FALSE); + elm_layout_file_set(layout, edj, grp_name); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(layout); + UG_TRACE_END; + return layout; + +} + +/****************************** +** Prototype : mf_ug_navi_bar_create_default_view +** Description : Samsung +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +Evas_Object *__mf_ug_navi_bar_pathinfo_create(Evas_Object *parent, const char *content) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + ug_mf_retvm_if(content == NULL, NULL, "content is NULL"); + + Evas_Object *layout = NULL; + + layout = elm_layout_add(parent); + elm_object_focus_set(layout, EINA_FALSE); + elm_layout_file_set(layout, UG_EDJ_NAVIGATIONBAR, UG_GRP_PATH_INFO); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_part_text_set(layout, "info", content); + evas_object_show(layout); + UG_TRACE_END; + return layout; +} + + +void mf_ug_navi_bar_title_set(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + elm_object_part_text_set(ugd->ug_MainWindow.ug_pNaviBar, "elm.text.title", MF_UG_LABEL_IMPORT); + } else if (!(ugd->ug_Status.ug_bSettingEntry == true && ugd->ug_Status.ug_bInSettingView == true)) { + Evas_Object *home_btn = elm_button_add(ugd->ug_MainWindow.ug_pNaviBar); + elm_object_style_set(home_btn, "naviframe/title_icon"); + Evas_Object *home_ic = elm_image_add(ugd->ug_MainWindow.ug_pNaviBar); + elm_image_file_set(home_ic, UG_TITLE_ICON_HOME, NULL); + elm_image_resizable_set(home_ic, EINA_TRUE, EINA_TRUE); + elm_object_content_set(home_btn, home_ic); + evas_object_smart_callback_add(home_btn, "clicked", mf_ug_cb_home_button_cb, ugd); + evas_object_smart_callback_add(home_btn, "pressed", mf_ug_cb_home_button_pressed_cb, home_ic); + evas_object_smart_callback_add(home_btn, "unpressed", mf_ug_cb_home_button_unpressed_cb, home_ic); + evas_object_show(home_btn); + elm_object_item_part_content_set(ugd->ug_MainWindow.ug_pNaviItem, TITLE_LEFT_BTN, home_btn); + + Evas_Object *up_btn = elm_button_add(ugd->ug_MainWindow.ug_pNaviBar); + elm_object_style_set(up_btn, "naviframe/title_icon"); + Evas_Object *up_ic = elm_image_add(ugd->ug_MainWindow.ug_pNaviBar); + elm_image_file_set(up_ic, UG_TITLE_ICON_UPPER, NULL); + elm_image_resizable_set(up_ic, EINA_TRUE, EINA_TRUE); + elm_object_content_set(up_btn, up_ic); + evas_object_smart_callback_add(up_btn, "clicked", mf_ug_cb_upper_click_cb, ugd); + evas_object_smart_callback_add(up_btn, "pressed", mf_ug_cb_upper_button_pressed_cb, up_ic); + evas_object_smart_callback_add(up_btn, "unpressed", mf_ug_cb_upper_button_unpressed_cb, up_ic); + evas_object_show(up_btn); + + elm_object_item_part_content_set(ugd->ug_MainWindow.ug_pNaviItem, TITLE_RIGHT_BTN, up_btn); + } + elm_naviframe_item_title_visible_set(ugd->ug_MainWindow.ug_pNaviItem, EINA_TRUE); +} + +Eina_Bool mf_ug_navi_search_idler_cb(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(data == NULL, ECORE_CALLBACK_CANCEL, "data is NULL"); + ugData *ugd = (ugData *)data; + + mf_ug_search_view_enter_search_routine(ugd, NULL, NULL); + ugd->ug_Status.search_idler = NULL; + + return ECORE_CALLBACK_CANCEL; +} + +Evas_Object *__mf_ug_navi_bar_backbutton_create(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *btn = NULL; + btn = elm_button_add(parent); + elm_object_style_set(btn, "naviframe/end_btn/default"); + evas_object_show(btn); + return btn; + +} + +void mf_ug_navi_add_back_button(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + Evas_Object *pBackButton = NULL; + + pBackButton = __mf_ug_navi_bar_backbutton_create(ugd->ug_MainWindow.ug_pNaviBar); + if (pBackButton) { + elm_object_item_part_content_set(ugd->ug_MainWindow.ug_pNaviItem, "prev_btn", pBackButton); + evas_object_smart_callback_add(pBackButton, "clicked", mf_ug_cb_back_button_cb, ugd); + } +} + +void mf_ug_callback_tab_click(void *data) +{ + int mmc_card = 0; + int error_code = 0; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + Evas_Object *newContent = NULL; + newContent = mf_ug_genlist_create_content_list_view(ugd); + Elm_Object_Item * selected_item = elm_toolbar_selected_item_get(ugd->ug_MainWindow.ug_pTabBar); + char *name = elm_object_item_text_get(selected_item); + + if(!strcmp(name, MF_UG_LABEL_MMC)) + { + error_code = mf_ug_util_get_mmc_state(&mmc_card); + if (error_code == 0 && mmc_card == 0) + { + newContent = mf_ug_genlist_no_mem_card(ugd); + } + } + + Evas_Object *playout = ugd->ug_MainWindow.ug_pNaviLayout; + ug_mf_retm_if(playout == NULL, "get conformant failed"); + Evas_Object *unUsed = elm_object_part_content_unset(playout, "part1"); + evas_object_del(unUsed); + + elm_object_part_content_set(playout, "part1", newContent); +} + +void mf_ug_tab_bar_generate(void *data) +{ + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + Elm_Object_Item *item_1 = NULL; + Elm_Object_Item *item_2 = NULL; + Evas_Object *parent = ugd->ug_MainWindow.ug_pNaviBar; + + Evas_Object *layout = mf_ug_navi_bar_create_layout(parent, UG_EDJ_NAVIGATIONBAR, UG_GRP_CTRL_BAR); + Evas_Object * tab_bar = elm_toolbar_add(layout); + ugd->ug_MainWindow.ug_pTabBar = tab_bar; + elm_object_focus_set(tab_bar, EINA_FALSE); + elm_toolbar_shrink_mode_set(tab_bar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_object_style_set(tab_bar, "tabbar"); + elm_toolbar_transverse_expanded_set(tab_bar, EINA_TRUE); + elm_toolbar_select_mode_set(tab_bar, ELM_OBJECT_SELECT_MODE_ALWAYS); + + evas_object_size_hint_weight_set(tab_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(tab_bar, EVAS_HINT_FILL, EVAS_HINT_FILL); + + + elm_object_part_content_set(layout, "content", tab_bar); + elm_object_part_content_set(ugd->ug_MainWindow.ug_pNaviLayout, "title", layout); + item_1 = elm_toolbar_item_append(tab_bar, UG_ICON_PHONE, MF_UG_LABEL_PHONE, mf_ug_callback_tab_click, ugd); + item_2 = elm_toolbar_item_append(tab_bar, UG_ICON_MEMORY, MF_UG_LABEL_MMC, mf_ug_callback_tab_click, ugd); + elm_object_signal_emit(ugd->ug_MainWindow.ug_pNaviLayout, "show,title,button", "elm"); + +} + +void mf_ug_navi_bar_set_ctrl_button(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + Elm_Object_Item *navi_it = ugd->ug_MainWindow.ug_pNaviItem;//ap->mf_MainWindow.pNaviItem; + Evas_Object *pNavi = ugd->ug_MainWindow.ug_pNaviBar; + Elm_Object_Item *item_1 = NULL; + Elm_Object_Item *item_2 = NULL; + + + Evas_Object *layout = mf_ug_navi_bar_create_layout(pNavi, UG_EDJ_NAVIGATIONBAR, UG_GRP_CTRL_BAR); + Evas_Object * tab_bar = elm_toolbar_add(layout); + elm_object_focus_set(tab_bar, EINA_FALSE); + elm_toolbar_shrink_mode_set(tab_bar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_object_style_set(tab_bar, "transparent"); + elm_toolbar_transverse_expanded_set(tab_bar, EINA_TRUE); + elm_toolbar_select_mode_set(tab_bar, ELM_OBJECT_SELECT_MODE_DEFAULT); + + evas_object_size_hint_weight_set(tab_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(tab_bar, EVAS_HINT_FILL, EVAS_HINT_FILL); + + + elm_object_part_content_set(layout, "content", tab_bar); + + if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + item_1 = elm_toolbar_item_append(tab_bar, NULL, MF_UG_LABEL_IMPORT, mf_ug_cb_add_button_cb, ugd); + evas_object_show(tab_bar); + + } else if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE) { + item_1 = elm_toolbar_item_append(tab_bar, NULL, MF_UG_LABEL_EXPORT, mf_ug_cb_add_button_cb, ugd); + item_2 = elm_toolbar_item_append(tab_bar, NULL, MF_UG_LABEL_CREATE, mf_ug_cb_more_cb, ugd); + } else if (ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE) { + item_1 = elm_toolbar_item_append(tab_bar, NULL, MF_UG_LABEL_SAVE_HERE, mf_ug_cb_add_button_cb, ugd); + item_2 = elm_toolbar_item_append(tab_bar, NULL, MF_UG_LABEL_CREATE, mf_ug_cb_more_cb, ugd); + } else if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + item_1 = elm_toolbar_item_append(tab_bar, NULL, MF_UG_LABEL_DONE, mf_ug_cb_add_button_cb, ugd); + } + else if (!(ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE)) { + item_1 = elm_toolbar_item_append(tab_bar, NULL, MF_UG_LABEL_ATTACH, mf_ug_cb_add_button_cb, ugd); + } + if (item_1 || item_2) + { + elm_object_signal_emit(ugd->ug_MainWindow.ug_pNaviLayout, "show,toolbar,button", "elm"); + } + elm_object_part_content_set(ugd->ug_MainWindow.ug_pNaviLayout, "toolbar_button", layout); + mf_ug_navi_add_back_button(ugd); + +} + + + +void mf_ug_navi_bar_create_default_view(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + GString *title = NULL; + Evas_Object *pNaviLayout = NULL; + Evas_Object *newContent = NULL; + Evas_Object *box = NULL; + Evas_Object *top_layout = NULL; + Evas_Object *upper_genlist = NULL; + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navigation bar in use failed"); + + + /*if the muisc is playing, destory the play */ + if (0 != ugd->ug_ListPlay.ug_Player) { + mf_ug_list_play_destory_playing_file(ugd); + UG_SAFE_FREE_CHAR(ugd->ug_ListPlay.ug_pPlayFilePath); + } + + box = mf_ug_navi_bar_create_box(ugd->ug_MainWindow.ug_pNaviBar); + pNaviLayout = mf_ug_navi_bar_create_layout(box, UG_EDJ_NAVIGATIONBAR, UG_GRP_NAVI_VIEW); + ugd->ug_MainWindow.ug_pNaviLayout = pNaviLayout; + elm_object_signal_emit(ugd->ug_MainWindow.ug_pNaviLayout, "hide,toolbar,button", "elm"); + + + if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + newContent = __mf_ug_genlist_create_gl(ugd); + ugd->ug_MainWindow.ug_pNaviGenlist = newContent; + + } else { + if (ugd->ug_Status.ug_bSettingEntry == true && ugd->ug_Status.ug_bInSettingView == true) { + top_layout = mf_ug_navi_bar_create_box(box); + evas_object_size_hint_min_set(top_layout, MF_UG_UPPER_WIDTH, MF_UG_UPPER_HEIGHT); + upper_genlist = mf_navi_bar_upper_create(top_layout); + elm_object_scroll_freeze_push(upper_genlist); + elm_genlist_scroller_policy_set(upper_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + mf_ug_genlist_goto_myfile_style_set(ugd); + mf_ug_genlist_goto_myfile_item_append(upper_genlist, ugd); + ugd->ug_Status.ug_bUpperFlag = true; + elm_box_pack_end(top_layout, upper_genlist); + } + if (top_layout) { + elm_box_pack_start(box, top_layout); + } else { + ugd->ug_Status.ug_bUpperFlag = true; + } + /*set content */ + if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + __mf_ug_navi_bar_create_group_radio_box(ugd); + } + newContent = mf_ug_genlist_create_content_list_view(ugd); + ugd->ug_MainWindow.ug_pNaviGenlist = newContent; + /*set title segment or title */ + if (mf_ug_fm_svc_wapper_is_root_path(ugd->ug_Status.ug_pPath)) { + title = g_string_new(MF_UG_LABEL_MYFILES); + } else { + title = mf_ug_fm_svc_wapper_get_file_name(ugd->ug_Status.ug_pPath); + } + + if (title != NULL) { + pNavi_s->ug_pNaviTitle = g_strdup(title->str); + g_string_free(title, TRUE); + title = NULL; + } + } + + /*navigation view integration */ + evas_object_show(newContent); + elm_object_part_content_set(pNaviLayout, "part1", newContent); + + elm_box_pack_end(box, pNaviLayout); + ugd->ug_MainWindow.ug_pNaviBox = box; + __mf_ug_navi_bar_push_content(ugd, box); + + /*add control bar for navigation bar */ + elm_naviframe_item_title_visible_set(ugd->ug_MainWindow.ug_pNaviItem, EINA_FALSE); + if(mf_ug_fm_svc_wapper_is_root_path(ugd->ug_Status.ug_pPath)) + { + mf_ug_tab_bar_generate(ugd); + } + else + { + elm_object_signal_emit(ugd->ug_MainWindow.ug_pNaviLayout, "hide,title,button", "elm"); + mf_ug_navi_bar_set_ctrl_button(ugd); + mf_ug_navi_bar_title_set(ugd); + } + + mf_ug_navi_bar_remove_previous_contents(ugd); + + if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + ug_ecore_idler_del(ugd->ug_Status.search_idler); + ugd->ug_Status.search_idler = ecore_idler_add(mf_ug_navi_search_idler_cb, ugd); + } + UG_SAFE_DEL_ECORE_TIMER(ugd->ug_Status.play_timer); + UG_TRACE_END; +} + +void mf_ug_navi_bar_create_new_folder_view(void *data) +{ + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Evas_Object *newContent = NULL; + + Evas_Object *pNaviBar = NULL; + GString *title = NULL; + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "pNavi_s is NULL"); + + pNaviBar = ugd->ug_MainWindow.ug_pNaviBar; + + /*set content*/ + newContent = mf_ug_genlist_create_list_new_folder_style(ugd); + /*set title segment or title*/ + title = g_string_new(MF_UG_LABEL_CREATE); + + if (title != NULL) { + pNavi_s->ug_pNaviTitle = g_strdup(title->str); + g_string_free(title, TRUE); + title = NULL; + } + /*navigation view integration*/ + __mf_ug_navi_bar_push_content(ugd, newContent); + + Evas_Object *l_bt = NULL; + Evas_Object *r_bt = NULL; + + l_bt = elm_button_add(pNaviBar); + elm_object_focus_set(l_bt, EINA_FALSE); + elm_object_style_set(l_bt, "naviframe/title/default"); + elm_object_text_set(l_bt, MF_UG_LABEL_SAVE); + evas_object_smart_callback_add(l_bt, "clicked", mf_ug_cb_save_cb, ugd); + evas_object_show(l_bt); + elm_object_item_part_content_set(ugd->ug_MainWindow.ug_pNaviItem, "title_toolbar_button1", l_bt); + + r_bt = elm_button_add(pNaviBar); + elm_object_focus_set(r_bt, EINA_FALSE); + elm_object_style_set(r_bt, "naviframe/end_btn/default"); + evas_object_smart_callback_add(r_bt, "clicked", mf_ug_cb_cancel_new_folder_cb, ugd); + evas_object_show(r_bt); + elm_object_item_part_content_set(ugd->ug_MainWindow.ug_pNaviItem, "title_prev_btn", r_bt); + elm_object_item_signal_emit(ugd->ug_MainWindow.ug_pNaviItem, "elm,state,sip,shown", ""); + + elm_object_focus_set(ugd->ug_MainWindow.ug_pEntry, EINA_TRUE); + UG_SAFE_DEL_ECORE_TIMER(ugd->ug_Status.play_timer); +} + +/****************************** +** Prototype : mf_ug_navi_bar_get_in_use_navi +** Description : Samsung +** Input : void* data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +ugNaviBar *mf_ug_navi_bar_get_in_use_navi(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + Eina_List *pNaviList = ugd->ug_MainWindow.ug_pNaviBarList; + ug_mf_retvm_if(pNaviList == NULL, NULL, "pNavi_sList is NULL"); + + ugNaviBar *ret = NULL; + Eina_List *l = NULL; + void *item; + + EINA_LIST_FOREACH(pNaviList, l, item) { + ret = (ugNaviBar *)item; + if (ret->ug_bNaviFlagInUse == TRUE) { + break; + } else { + ret = NULL; + } + } + UG_TRACE_END; + return ret; +} + + +/****************************** +** Prototype : mf_ug_navi_bar_reset_navi_object +** Description : Samsung +** Input : ugNaviBar *pNavi_s +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_navi_bar_reset_navi_object(ugNaviBar *pNavi_s) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(pNavi_s == NULL, "pNavi_s is NULL"); + + pNavi_s->ug_pNaviTitle = NULL; + if (pNavi_s->ug_pCurrentPath != NULL) { + free(pNavi_s->ug_pCurrentPath); + pNavi_s->ug_pCurrentPath = NULL; + } + if (pNavi_s->ug_pNaviLabel != NULL) + free(pNavi_s->ug_pNaviLabel); + pNavi_s->ug_pNaviLabel = NULL; + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_navi_bar_get_navi_struct_by_label +** Description : Samsung +** Input : void* data +** const char* pNaviLabel +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +ugNaviBar *mf_ug_navi_bar_get_navi_struct_by_label(void *data, const char *pNaviLabel) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + ug_mf_retvm_if(pNaviLabel == NULL, NULL, "pNaviLabel is NULL"); + + Eina_List *l = NULL; + void *item = NULL; + + ugNaviBar *ret = NULL; + EINA_LIST_FOREACH(ugd->ug_MainWindow.ug_pNaviBarList, l, item) { + if (g_strcmp0(((ugNaviBar *)item)->ug_pNaviLabel, pNaviLabel) == 0) { + ret = (ugNaviBar *)item; + break; + } + } + UG_TRACE_END; + return ret; +} + + +/****************************** +** Prototype : mf_ug_navi_bar_remove_navi_list_item_by_label +** Description : Samsung +** Input : void *data +** const char* pNaviLabel +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_navi_bar_remove_navi_list_item_by_label(void *data, const char *pNaviLabel) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + ug_mf_retm_if(pNaviLabel == NULL, "pNaviLabel is NULL"); + + bool bInUseFlag = FALSE; + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_navi_struct_by_label(ugd, pNaviLabel); + + if (pNavi_s == NULL) { + return; + } + Eina_List *plistNaviMMC = eina_list_data_find_list(ugd->ug_MainWindow.ug_pNaviBarList, pNavi_s); + ugd->ug_MainWindow.ug_pNaviBarList = eina_list_remove_list(ugd->ug_MainWindow.ug_pNaviBarList, plistNaviMMC); + + if (pNavi_s->ug_bNaviFlagInUse == TRUE) { + bInUseFlag = TRUE; + } + + mf_ug_navi_bar_reset_navi_object(pNavi_s); + + if (bInUseFlag == TRUE) { + pNavi_s = (ugNaviBar *)eina_list_nth(ugd->ug_MainWindow.ug_pNaviBarList, 0); + pNavi_s->ug_bNaviFlagInUse = TRUE; + } + UG_TRACE_END; +} + + +/****************************** +** Prototype : mf_ug_navi_bar_refresh_navibar_recovered_view +** Description : Samsung +** Input : void *data +** ugNaviBar* pNaviStruct +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_navi_bar_refresh_navibar_recovered_view(void *data, ugNaviBar *pNaviStruct) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + ug_mf_retm_if(pNaviStruct == NULL, "pNaviStruct is NULL"); + + if (ugd->ug_Status.ug_pPath != NULL) { + g_string_free(ugd->ug_Status.ug_pPath, TRUE); + ugd->ug_Status.ug_pPath = NULL; + } + ugd->ug_Status.ug_pPath = g_string_new(pNaviStruct->ug_pCurrentPath); + mf_ug_navi_bar_create_default_view(ugd); + + UG_TRACE_END; +} + +void mf_ug_navi_bar_transition_finished_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ug_mf_retm_if(obj == NULL, "obj is NULL"); + ugData *ugd = (ugData *)data; + Elm_Object_Item *it = ugd->ug_MainWindow.ug_pPreNaviItem; + UG_SAFE_DEL_NAVI_ITEM(it); + ugd->ug_MainWindow.ug_pPreNaviItem = NULL; + mf_ug_navi_bar_set_blocking(data, false); + evas_object_smart_callback_del(obj, "transition,finished", mf_ug_navi_bar_transition_finished_cb); + UG_TRACE_END; +} + +void mf_ug_navi_bar_remove_previous_contents(void *data) +{ + UG_TRACE_BEGIN; + + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + Evas_Object *pNaviBar = NULL; + if (ugd->ug_MainWindow.ug_pNaviBar) { + pNaviBar = ugd->ug_MainWindow.ug_pNaviBar; + mf_ug_navi_bar_set_blocking(data, true); + evas_object_smart_callback_add(pNaviBar, "transition,finished", mf_ug_navi_bar_transition_finished_cb, ugd); + } + UG_TRACE_END; +} + +void mf_ug_navi_bar_del_item_directly(void *data) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + if (ugd->ug_Status.ug_b_NaviPushFlag) { + ugNaviBar *pNavi_s_previous = NULL; + pNavi_s_previous = mf_ug_navi_bar_get_in_use_navi(ugd) ; + if(pNavi_s_previous && ugd->ug_MainWindow.ug_pPreNaviItem) + { + UG_SAFE_DEL_NAVI_ITEM(ugd->ug_MainWindow.ug_pPreNaviItem); + mf_ug_navi_bar_set_blocking(ugd, false); + evas_object_smart_callback_del(ugd->ug_MainWindow.ug_pNaviBar, "transition,finished", mf_ug_navi_bar_transition_finished_cb); + } + } + UG_TRACE_END; +} + + +void mf_ug_navi_bar_set_blocking(void *data, bool bblock_during_transition) +{ + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + ugd->ug_Status.ug_bCancelDisableFlag = bblock_during_transition; + ugd->ug_Status.ug_b_NaviPushFlag = bblock_during_transition; + return; +} + +ugNaviBar *ug_mf_navi_bar_get_navi_from_navilist(Eina_List *navilist, const char *label) +{ + + UG_TRACE_BEGIN; + ug_mf_retvm_if(navilist == NULL, NULL, "navilist is NULL"); + ug_mf_retvm_if(label == NULL, NULL, "label is NULL"); + + void *data = NULL; + ugNaviBar *pNavi = NULL; + Eina_List *l = NULL; + EINA_LIST_FOREACH(navilist, l, data) { + if (data) { + pNavi = (ugNaviBar *)data; + if (pNavi && pNavi->ug_pNaviLabel && g_strcmp0(label, pNavi->ug_pNaviLabel) == 0) + return pNavi; + else + continue; + } + } + return NULL; +} + +void mf_ug_navi_bar_button_set_disable(void *data, bool disable) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + Evas_Object *btn = NULL; + Elm_Object_Item *navi_it = ugd->ug_MainWindow.ug_pNaviItem; + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navigation bar in use failed"); + + const char *disable_labe = NULL; + if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE + || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + disable_labe = MF_UG_LABEL_IMPORT; + } else if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) { + disable_labe = MF_UG_LABEL_SET; + } + else { + disable_labe = MF_UG_LABEL_ATTACH; + } + btn = elm_object_item_part_content_get(navi_it, NAVI_BOTTOM_BUTTON_1_PART); + const char *button_label = elm_object_text_get(btn); + if (g_strcmp0(button_label, disable_labe) == 0) + elm_object_disabled_set(btn, disable); +} + diff --git a/src/widget/mf-ug-popup.c b/src/widget/mf-ug-popup.c new file mode 100644 index 0000000..d789a51 --- /dev/null +++ b/src/widget/mf-ug-popup.c @@ -0,0 +1,599 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <notification.h> + +#include "mf-ug-util.h" +#include "mf-ug-winset.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-cb.h" +#include "mf-ug-resource.h" + +#define MF_UG_POPUP_STYLE_MIN_MENUSTYLE "min_menustyle" +#define MF_UG_POPUP_MENUSTYLE_WIDTH (614*elm_config_scale_get()) +#define MF_UG_POPUP_MENUSTYLE_HEIGHT(x) ((113*x-1)*elm_config_scale_get()) +#define MF_UG_POPUP_MENUSTYLE_HEIGHT_MAX (408*elm_config_scale_get()) +Elm_Genlist_Item_Class ug_listby_itc; +#define MF_UG_ITEM_COUNT 4 + +typedef struct { + int index; + ugData* ugd; +} ugListByData_s; + +static int __mf_ug_popup_get_list_by_selected_item(void *data) +{ + ug_mf_retvm_if(data == NULL, 0, "data is NULL"); + ugData *ugd = (ugData *)data; + + int iSortTypeValue = ugd->ug_Status.ug_iSortType; + + int ret = -1; + switch (iSortTypeValue) { + case MF_UG_SORT_BY_DATE_O2R: + case MF_UG_SORT_BY_DATE_R2O: + ret = 1; + break; + case MF_UG_SORT_BY_TYPE_A2Z: + case MF_UG_SORT_BY_TYPE_Z2A: + ret = 3; + break; + case MF_UG_SORT_BY_NAME_A2Z: + case MF_UG_SORT_BY_NAME_Z2A: + ret = 0; + break; + case MF_UG_SORT_BY_SIZE_S2L: + case MF_UG_SORT_BY_SIZE_L2S: + ret = 2; + break; + default: + ret = 0; + break; + } + return ret; +} + + +static char *__mf_ug_popup_get_genlist_label(void *data, Evas_Object * obj, const char *part) +{ + ugListByData_s *params = (ugListByData_s *) data; + assert(params); + ugData *ugd = params->ugd; + assert(ugd); + assert(part); + + char *ret = NULL; + if (!strcmp(part, "elm.text")) { + switch (params->index) { + case 0: /**< Sort by file name ascending */ + ret = g_strdup(MF_UG_LABEL_NAME); + break; + case 1: /**< Sort by file size ascending */ + ret = g_strdup(MF_UG_LABEL_DATE); + break; + case 2: /**< Sort by file date ascending */ + ret = g_strdup(MF_UG_LABEL_SIZE); + break; + case 3: /**< Sort by file type ascending */ + ret = g_strdup(MF_UG_LABEL_TYPE); + break; + default: + break; + } + return ret; + } + return NULL; +} + +static Evas_Object* __mf_ug_popup_get_genlist_icon(void *data, Evas_Object * obj, const char *part) +{ + ugListByData_s *params = (ugListByData_s *) data; + assert(params); + ugData *ugd = params->ugd; + assert(ugd); + assert(part); + + if (!strcmp(part, "elm.icon")) { + Evas_Object *radio = NULL; + radio = elm_radio_add(obj); + elm_object_focus_set(radio, EINA_FALSE); + elm_radio_state_value_set(radio, params->index); + elm_radio_group_add(radio, ugd->ug_Status.ug_pRadioGroup); + elm_radio_value_set(radio, ugd->ug_Status.ug_iRadioValue); + evas_object_show(radio); + return radio; + } + return NULL; +} + +static void __mf_ug_popup_genlist_select(void *data, Evas_Object * obj, void *event_info) +{ + assert(data); + assert(event_info); + ugListByData_s *params = NULL; + Elm_Object_Item *item = (Elm_Object_Item *) event_info; + if (item != NULL) { + params = (ugListByData_s *) elm_object_item_data_get(item); + if (params != NULL && params->ugd != NULL) { + params->ugd->ug_Status.ug_iSelectedSortType = params->index; + elm_radio_value_set(params->ugd->ug_Status.ug_pRadioGroup, params->index); + } + } +} + +/****************************** +** Prototype : mfPopupCreate +** Description : +** Input : void *data +** ePopMode popupMode +** char *title +** char *context +** char *first_btn_text +** char *second_btn_text +** char *third_btn_text +** Evas_Smart_Cb func +** void* param +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +static Evas_Object *__ug_mf_popup_button_create(Evas_Object *parent, const char *label) +{ + Evas_Object *btn = NULL; + btn = elm_button_add(parent); + if (label) { + elm_object_text_set(btn, label); + } + return btn; + +} + +static Evas_Object *__mf_ug_popup_box_set(Evas_Object *parent, Evas_Object *content, int item_cnt) +{ + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + ug_mf_retvm_if(content == NULL, NULL, "content is NULL"); + ug_mf_retvm_if(item_cnt < 0, NULL, "content is NULL"); + + Evas_Object *box = elm_box_add(parent); + if (item_cnt > MF_UG_ITEM_COUNT) { + evas_object_size_hint_min_set(box, MF_UG_POPUP_MENUSTYLE_WIDTH, + MF_UG_POPUP_MENUSTYLE_HEIGHT(item_cnt)); + } else { + evas_object_size_hint_min_set(box, MF_UG_POPUP_MENUSTYLE_WIDTH, + MF_UG_POPUP_MENUSTYLE_HEIGHT(item_cnt)); + } + + evas_object_show(content); + elm_box_pack_end(box, content); + return box; +} + +Evas_Object *mf_ug_popup_create_search(void *data, Evas_Smart_Cb func, void *param) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + Evas_Object *popup = NULL; + Evas_Object *btn1 = NULL; + Evas_Object *box = NULL; + Evas_Object *content = NULL; + Evas_Object *label = NULL; + + popup = elm_popup_add(ugd->ug_MainWindow.ug_pMainLayout); + elm_object_style_set(popup,"min_menustyle"); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + ugd->ug_MainWindow.ug_pNormalPopup = popup; + + + + btn1 = elm_button_add(popup); + elm_object_text_set(btn1, MF_UG_LABEL_CANCEL); + elm_object_part_content_set(popup, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", func, param); + + box = elm_box_add(popup); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + content = elm_layout_add(popup); + elm_layout_file_set(content, UG_EDJ_NAVIGATIONBAR, UG_GRP_SEARCH_PATH); + + evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(content, EVAS_HINT_FILL, EVAS_HINT_FILL); + + label = elm_label_add(content); + ugd->ug_MainWindow.ug_pSearchLabel = label; + elm_object_style_set(label, "popup/default"); + elm_label_wrap_width_set(label, 720); + elm_label_ellipsis_set(label, EINA_TRUE); + evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(label, "Test"); + + + elm_object_part_content_set(content, "path", label); + evas_object_show(label); + elm_box_pack_end(box, content); + + evas_object_size_hint_min_set(box, 720, 300); + evas_object_size_hint_max_set(box, 720, 300); + + evas_object_show(btn1); + evas_object_show(content); + evas_object_show(box); + + elm_object_content_set(popup, box); + + evas_object_show(popup); + return popup; +} + +Evas_Object *mf_ug_popup_create(void *data, mf_ug_popup_mode 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 *popup; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + Evas_Object *genlist; + Evas_Object *radio_group = NULL; + Evas_Object *box = NULL; + Evas_Object *btn1 = NULL; + Evas_Object *btn2 = NULL; + int index = 0; + int listby_selected= 0; + + popup = elm_popup_add(ugd->ug_MainWindow.ug_pMainLayout); + ugd->ug_MainWindow.ug_pNormalPopup = popup; + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + if (title) { + elm_object_part_text_set(popup, "title,text", title); + } + if (context && popupMode != UG_POPMODE_PROGRESSBAR) { + elm_object_text_set(popup, context); + } + switch (popupMode) { + case UG_POPMODE_TEXT: + case UG_POPMODE_TITLE_TEXT: + elm_popup_timeout_set(popup, 3); + if (func) { + evas_object_smart_callback_add(popup, "timeout", (Evas_Smart_Cb) func, param); + } + break; + case UG_POPMODE_TEXT_TWO_BTN: + case UG_POPMODE_TITLE_TEXT_TWO_BTN: + btn1 = __ug_mf_popup_button_create(popup, first_btn_text); + btn2 = __ug_mf_popup_button_create(popup, second_btn_text); + + evas_object_smart_callback_add(btn1, "clicked", func, param); + evas_object_smart_callback_add(btn2, "clicked", func, param); + elm_object_part_content_set(popup, "button1", btn1); + elm_object_part_content_set(popup, "button2", btn2); + break; + case UG_POPMODE_TEXT_BTN: + case UG_POPMODE_TITLE_TEXT_BTN: + btn1 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_OK); + evas_object_smart_callback_add(btn1, "clicked", func, param); + elm_object_part_content_set(popup, "button1", btn1); + break; + case UG_POPMODE_SEARCH: + btn1 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_CANCEL); + evas_object_smart_callback_add(btn1, "clicked", func, param); + elm_object_part_content_set(popup, "button1", btn1); + break; + case UG_POPMODE_LIST_BY: + elm_object_style_set(popup, MF_UG_POPUP_STYLE_MIN_MENUSTYLE); + + btn1 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_ASCENDING); + evas_object_smart_callback_add(btn1, "clicked", func, param); + elm_object_part_content_set(popup, "button1", btn1); + + btn2 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_DESCENDING); + evas_object_smart_callback_add(btn2, "clicked", func, param); + elm_object_part_content_set(popup, "button2", btn2); + + if (ugd->ug_Status.ug_pRadioGroup) { + evas_object_del(ugd->ug_Status.ug_pRadioGroup); + ugd->ug_Status.ug_pRadioGroup = NULL; + } + + radio_group = elm_radio_add(ugd->ug_MainWindow.ug_pWindow); + elm_object_focus_set(radio_group, EINA_FALSE); + elm_radio_value_set(radio_group, 0); + evas_object_hide(radio_group); + ugd->ug_Status.ug_pRadioGroup = radio_group; + + listby_selected = __mf_ug_popup_get_list_by_selected_item(ugd); + ugd->ug_Status.ug_iRadioValue = listby_selected; + + ug_listby_itc.item_style = "1text.1icon.2"; + ug_listby_itc.func.text_get = __mf_ug_popup_get_genlist_label; + ug_listby_itc.func.content_get = __mf_ug_popup_get_genlist_icon; + ug_listby_itc.func.state_get = NULL; + ug_listby_itc.func.del = NULL; + genlist = elm_genlist_add(popup); + elm_object_focus_set(genlist, EINA_FALSE); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + for (index = 0; index < MF_UG_ITEM_COUNT; index++) { + ugListByData_s *item_data = malloc(sizeof(ugListByData_s)); + if (item_data == NULL) + continue; + + item_data->index = index; + item_data->ugd = ugd; + elm_genlist_item_append(genlist, &ug_listby_itc, (void *)item_data, NULL, + ELM_GENLIST_ITEM_NONE, __mf_ug_popup_genlist_select, popup); + } + + box = __mf_ug_popup_box_set(popup, genlist, MF_UG_ITEM_COUNT); + elm_object_content_set(popup, box); + evas_object_smart_callback_add(popup, "response", func, param); + + break; + default: + evas_object_del(popup); + return NULL; + } + evas_object_show(popup); + return popup; +} + +void mf_ug_popup_indicator_popup(const char *text) +{ + ug_mf_retm_if(text == NULL, "text is NULL"); + int ret = notification_status_message_post(text); + ug_debug("status_message_post()... [0x%x]!", ret); + if (ret != 0) { + ug_debug("status_message_post()... [0x%x]!", ret); + } + return ; +} + +static void _move_ctxpopup(void *data, Evas_Object *parent, Evas_Object *ctxpopup ) +{ + elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP, + ELM_CTXPOPUP_DIRECTION_LEFT, + ELM_CTXPOPUP_DIRECTION_RIGHT, + ELM_CTXPOPUP_DIRECTION_DOWN); + + if (parent) { + int x = 0; + int y = 0; + int w = 0; + int h = 0; + + evas_object_geometry_get(parent, &x, &y, &w, &h); + evas_object_move(ctxpopup, x+w/2, + y + h/2); + } +} +static void _ctxpopup_hide_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(obj == NULL, "obj is NULL"); + evas_object_del(obj); + obj = NULL; + UG_TRACE_END; +} + + +void mf_ug_context_popup_create_more(void *data, Evas_Object *parent) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pContextPopup); + + Evas_Object *ctxpopup = elm_ctxpopup_add(ugd->ug_MainWindow.ug_pNaviBar); + ugd->ug_MainWindow.ug_pContextPopup = ctxpopup; + Elm_Object_Item *it = NULL; + + if (ugd->ug_UiGadget.ug_iSelectMode == EXPORT_MODE || ugd->ug_UiGadget.ug_iSelectMode == SAVE_MODE) { + /*Search*/ + it = elm_ctxpopup_item_append(ctxpopup, MF_UG_LABEL_CREATE, NULL, mf_ug_cb_create_new_folder, ugd); + } + _move_ctxpopup(ugd, parent, ctxpopup); + evas_object_show(ctxpopup); + + if(ctxpopup) + { + evas_object_smart_callback_add(ctxpopup,"dismissed", _ctxpopup_hide_cb, ugd); + } + UG_TRACE_END; +} + +static Evas_Object *__mf_ug_popup_entry_create(Evas_Object *parent) +{ + Evas_Object *en = NULL; + + en = elm_entry_add(parent); + elm_entry_scrollable_set(en, EINA_TRUE); + elm_entry_select_all(en); + elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_AUTO); + + Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(en); + + elm_entry_single_line_set(en, EINA_TRUE); + evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(en); + + return en; + +} + +static char *__new_folder_text_get(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, NULL, "ugd is NULL"); + + int error_code = 0; + char *fileName = NULL; + char *fullpath = (char *)malloc(sizeof(char) * MYFILE_FILE_PATH_LEN_MAX); + if (fullpath == NULL) { + return NULL; + } + GString *dest_fullpath = NULL; + + memset(fullpath, 0, MYFILE_FILE_PATH_LEN_MAX); + fileName = elm_entry_markup_to_utf8(MF_UG_LABEL_FOLDER); + snprintf(fullpath, (MYFILE_FILE_PATH_LEN_MAX), "%s/%s", (char *)ugd->ug_Status.ug_pPath->str, fileName); + + dest_fullpath = g_string_new(fullpath); + + + if (mf_ug_fm_svc_wrapper_detect_duplication(dest_fullpath)) { + ug_debug("dectetion result is TRUE\ndest_fullpath is %s\n", dest_fullpath->str); + error_code = mf_ug_fm_svc_wrapper_file_auto_rename(ugd, dest_fullpath, FILE_NAME_WITH_BRACKETS, &dest_fullpath); + ug_debug("rename result is %s\n", dest_fullpath->str); + memset(fullpath, 0, strlen(fullpath)); + int len = strlen(ugd->ug_Status.ug_pPath->str) + 1; + strncpy(fullpath, dest_fullpath->str + len, MYFILE_FILE_PATH_LEN_MAX); + /*memset(fileName,0,strlen(fileName));*/ + + UG_SAFE_FREE_CHAR(fileName); + fileName = elm_entry_markup_to_utf8(fullpath); + } + + /*elm_entry_entry_set(entry, ecore_file_file_get(params->m_ItemName->str));*/ + + + UG_SAFE_FREE_CHAR(fullpath); + UG_SAFE_FREE_GSTRING(dest_fullpath); + return fileName; +} +static void __mf_ug_popup_show_vk_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + Evas_Object *pEntry = NULL; + + evas_object_del(ugd->ug_MainWindow.ug_pNormalPopup); + + ugd->ug_MainWindow.ug_pNormalPopup = NULL; + + pEntry = ugd->ug_MainWindow.ug_pEntry; + elm_entry_cursor_end_set(ugd->ug_MainWindow.ug_pEntry); + + elm_object_focus_set(ugd->ug_MainWindow.ug_pEntry, EINA_TRUE); + + UG_TRACE_END; + +} + + +static void __mf_ug_popup_create_folder_imf_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(data == NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + const char *entry_data = NULL; + char *name = NULL; + char new_str[MYFILE_FILE_NAME_LEN_MAX] = { '\0', }; + + entry_data = elm_entry_entry_get(ugd->ug_MainWindow.ug_pEntry); + ug_mf_retm_if(entry_data == NULL, "entry_data is null"); + name = elm_entry_markup_to_utf8(entry_data); + ug_mf_retm_if(name == NULL, "name is null"); + + ug_error("name is [%s]", name); + if (mf_ug_file_attr_is_valid_name(name) != MYFILE_ERR_NONE) { + strncpy(new_str, name, MYFILE_FILE_NAME_LEN_MAX - 1); + if (strlen(name) > 0) + new_str[strlen(name) - 1] = '\0'; + elm_entry_entry_set(ugd->ug_MainWindow.ug_pEntry, new_str); + elm_entry_cursor_end_set(ugd->ug_MainWindow.ug_pEntry); + elm_object_focus_set(ugd->ug_MainWindow.ug_pEntry, EINA_FALSE); + + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pNormalPopup); + ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_ILLEGAL_CHAR, NULL, NULL, + NULL, __mf_ug_popup_show_vk_cb, ugd); + } + UG_SAFE_FREE_CHAR(name); + UG_TRACE_END; +} + +Evas_Object *mf_ug_popup_create_new_folder_popup(void *data, char *context) +{ + + UG_TRACE_BEGIN; + ug_mf_retvm_if(data == NULL, NULL, "data is NULL"); + ugData *ugd = (ugData *)data; + + Evas_Object *popup; + Evas_Object *layout; + char *text = NULL; + static Elm_Entry_Filter_Limit_Size limit_filter_data; + + popup = elm_popup_add(ugd->ug_MainWindow.ug_pMainLayout); + elm_object_focus_set(popup, EINA_FALSE); + + layout = elm_layout_add(popup); + elm_object_focus_set(layout, EINA_FALSE); + elm_layout_file_set(layout, UG_EDJ_NAVIGATIONBAR, UG_GRP_POPUP); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + Evas_Object *en = NULL; + en = __mf_ug_popup_entry_create(layout); + + text = __new_folder_text_get(ugd); + limit_filter_data.max_char_count = MYFILE_FILE_NAME_LEN_MAX; + elm_entry_entry_set(en, text); + elm_entry_cursor_end_set(en); + UG_SAFE_FREE_CHAR(text); + + elm_entry_markup_filter_append(en, elm_entry_filter_limit_size, + &limit_filter_data); + elm_object_part_content_set(layout, "elm.swallow.content", en); + + edje_object_part_text_set(elm_layout_edje_get(layout), "title.text", context); + evas_object_smart_callback_add(en, "maxlength,reached", mf_ug_cb_reach_max_len_cb, ugd); + evas_object_smart_callback_add(en, "changed", __mf_ug_popup_create_folder_imf_changed_cb, ugd); + ugd->ug_MainWindow.ug_pEntry = en; + + elm_object_content_set(popup, layout); + + + Evas_Object *btn1 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_OK); + elm_object_style_set(btn1, "popup_button/default"); + Evas_Object *btn2 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_CANCEL); + elm_object_style_set(btn2, "popup_button/default"); + + evas_object_smart_callback_add(btn1, "clicked", mf_ug_cb_save_cb, ugd); + evas_object_smart_callback_add(btn2, "clicked", mf_ug_cb_cancel_new_folder_cb, ugd); + elm_object_part_content_set(popup, "button1", btn1); + elm_object_part_content_set(popup, "button2", btn2); + + evas_object_show(popup); + + return popup; +} + diff --git a/src/widget/mf-ug-search-view.c b/src/widget/mf-ug-search-view.c new file mode 100644 index 0000000..2ff7215 --- /dev/null +++ b/src/widget/mf-ug-search-view.c @@ -0,0 +1,455 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Eina.h> +#include <Ecore_X.h> + +#include "mf-ug-main.h" +#include "mf-ug-util.h" +#include "mf-ug-winset.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-resource.h" +#include "mf-ug-cb.h" + +#define MF_SEARCH_OPTION_DEF (MF_SEARCH_OPT_EXT) +#define MF_SEARCH_ROOT_NUM 2 +#define MF_SEARCH_TIMER_INTERVAL 0.5 + +extern int flagSearchMsg; +extern pthread_mutex_t gLockSearchMsg; +extern pthread_cond_t gCondSearchMsg; + +typedef struct { + char *size; + char *create_date; +} mf_search_detail_infor_s; + +static void __mf_ug_search_select_all_check_changed_cb(void *data, Evas_Object * obj, void *event_info); + +Evas_Object *mf_ug_search_view_create_no_content(Evas_Object *parent) +{ + Evas_Object *nocontent = elm_layout_add(parent); + elm_layout_theme_set(nocontent, "layout", "nocontents", "text"); + elm_object_focus_set(nocontent, EINA_FALSE); + elm_object_part_text_set(nocontent, "elm.text", MF_UG_LABEL_NO_RESULT); + return nocontent; +} + +void mf_ug_search_view_item_append(void *data, void *user_data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)user_data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navi failed"); + + char *item_name = (char *)data; + ug_mf_retm_if(item_name == NULL, "input item_name error"); + + ugListItemData *m_TempItem = NULL; + GString *search_path = g_string_new(item_name); + + + g_string_free(search_path, TRUE); + search_path = NULL; + + m_TempItem = (ugListItemData *) malloc(sizeof(ugListItemData)); + + if (m_TempItem == NULL) { + return; + } + memset(m_TempItem, 0, sizeof(ugListItemData)); + + m_TempItem->ug_pItemName = g_string_new(item_name); + m_TempItem->ug_iGroupValue = 0; + m_TempItem->ug_pRadioBox = NULL; + m_TempItem->ug_bChecked = FALSE; + m_TempItem->ug_pCheckBox = NULL; + m_TempItem->ug_pThumbPath = NULL; + m_TempItem->ug_bRealThumbFlag = FALSE; + m_TempItem->ug_pData = ugd; + m_TempItem->ug_pItem = NULL; + + /*delete timer if exists*/ + +#ifdef UG_THUMB_REAL_TIME_UPDATE + if (ugd->ug_Status.ug_pThumbUpdateTimer != NULL) { + ecore_timer_del(ugd->ug_Status.ug_pThumbUpdateTimer); + ugd->ug_Status.ug_pThumbUpdateTimer = NULL; + } +#endif + Elm_Object_Item *it = NULL; + + it = elm_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, &ugd->ug_Status.ug_itc, m_TempItem, NULL, ELM_GENLIST_ITEM_NONE, NULL, ugd); + m_TempItem->ug_pItem = it; + UG_TRACE_END; + +} + +Evas_Object *mf_ug_search_create_select_all_layout(Evas_Object *parent) +{ + + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *pSelectedAllLayout = NULL; + pSelectedAllLayout = elm_layout_add(parent); + elm_object_focus_set(pSelectedAllLayout, EINA_FALSE); + elm_layout_theme_set(pSelectedAllLayout, "genlist", "item", "select_all/default"); + evas_object_size_hint_weight_set(pSelectedAllLayout, EVAS_HINT_EXPAND, EVAS_HINT_FILL); + evas_object_size_hint_align_set(pSelectedAllLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_text_set(pSelectedAllLayout, "elm.text", MF_UG_LABEL_SELECT_ALL); + evas_object_show(pSelectedAllLayout); + return pSelectedAllLayout; +} + +Evas_Object *mf_ug_search_create_check_box(Evas_Object *parent) +{ + ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL"); + + Evas_Object *checkbox = NULL; + checkbox = elm_check_add(parent); + elm_object_focus_set(checkbox, EINA_FALSE); + evas_object_propagate_events_set(checkbox, EINA_FALSE); + evas_object_show(checkbox); + return checkbox; +} + +void __mf_ug_search_select_all_layout_mouse_down_cb(void *data, Evas * evas, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugd->ug_Status.ug_bSelectAllChecked = !ugd->ug_Status.ug_bSelectAllChecked; + elm_check_state_pointer_set(ugd->ug_MainWindow.ug_pSelectAllCheckBox, &ugd->ug_Status.ug_bSelectAllChecked); + + __mf_ug_search_select_all_check_changed_cb(ugd, NULL, NULL); + UG_TRACE_END; +} + +static void __mf_ug_search_select_all_check_changed_cb(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + Evas_Object *genlist = ugd->ug_MainWindow.ug_pNaviGenlist; + ug_debug("ugd->ug_Status.ug_iTotalCount is [%d]", ugd->ug_Status.ug_iTotalCount); + if (ugd->ug_Status.ug_bSelectAllChecked) { + ug_debug(); + ugd->ug_Status.ug_iCheckedCount = ugd->ug_Status.ug_iTotalCount; + } else { + ug_debug(); + ugd->ug_Status.ug_iCheckedCount = 0; + } + + ugListItemData *it_data; + Elm_Object_Item *it; + int count = 0; + + it = elm_genlist_first_item_get(genlist); + while (it) { + ug_debug(); + it_data = elm_object_item_data_get(it); + if (it_data) { + ug_debug(); + it_data->ug_bChecked = ugd->ug_Status.ug_bSelectAllChecked; + count++; + } + it = elm_genlist_item_next_get(it); + } + elm_genlist_realized_items_update(genlist); + + if (count > 0 && ugd->ug_Status.ug_bSelectAllChecked) { + Evas_Object *notify_popup = NULL; + char lable_file[UG_LABEL_STRING_LENGTH] = { '\0', }; + char *label = NULL; + /*1 TODO: need to update for multi-language */ + + snprintf(lable_file, sizeof(lable_file), "%d", count); + label = g_strconcat(MF_UG_LABEL_SELECTED, "(", lable_file, ")", NULL); + notify_popup = mf_ug_navibar_create_notify_popup(ugd, ugd->ug_MainWindow.ug_pNaviLayout, label, false, NULL); + ugd->ug_MainWindow.ug_pSelectInfoLayout = notify_popup; + UG_SAFE_FREE_CHAR(label); + + } else { + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pSelectInfoLayout); + } + mf_ug_ctrl_bar_set_item_disable(ugd); + + UG_TRACE_END; +} + + +static void __mf_ug_search_view_result_cb(mf_search_result_t *result, void *user_data) +{ + ug_mf_retm_if(result == NULL, "result is NULL"); + + ugData *ugd = (ugData *)user_data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "get navi failed"); + + Evas_Object *playout = ugd->ug_MainWindow.ug_pNaviLayout; + ug_mf_retm_if(playout == NULL, "get conformant failed"); + Evas_Object *newContent = NULL; + Evas_Object *unUsed = elm_object_part_content_unset(playout, "part1"); + if (unUsed) { + evas_object_del(unUsed); + unUsed = NULL; + } + + if (g_list_length(result->dir_list) + g_list_length(result->file_list) == 0) { + ug_ecore_idler_del(ugd->ug_Status.popup_create_idler); + newContent = mf_ug_search_view_create_no_content(playout); + elm_object_part_content_set(playout, "part1", newContent); + mf_ug_navi_bar_button_set_disable(ugd, true); + } else { + + + + //newContent = mf_ug_genlist_create_content_list_view(ugd); + newContent = __mf_ug_genlist_create_gl(ugd); + ugd->ug_MainWindow.ug_pNaviGenlist = newContent; + + elm_object_part_content_set(playout, "part1", newContent); + + if (result->file_list != NULL) { + Evas_Object *pSelectAllLayout = NULL; + Evas_Object *pSelectAllCheckBox = NULL; + ugd->ug_Status.ug_bSelectAllChecked = false; + ugd->ug_Status.ug_iTotalCount = g_list_length(result->file_list); + ugd->ug_Status.ug_iCheckedCount = 0; + + pSelectAllLayout = mf_ug_search_create_select_all_layout(ugd->ug_MainWindow.ug_pNaviBox); + ug_mf_retm_if(pSelectAllLayout == NULL, "pSelectAllLayout is NULL"); + ugd->ug_MainWindow.ug_pSelectAllLayout = pSelectAllLayout; + evas_object_event_callback_add(pSelectAllLayout, EVAS_CALLBACK_MOUSE_DOWN, __mf_ug_search_select_all_layout_mouse_down_cb, ugd); + pSelectAllCheckBox = mf_ug_search_create_check_box(pSelectAllLayout); + ugd->ug_MainWindow.ug_pSelectAllCheckBox = pSelectAllCheckBox; + elm_check_state_pointer_set(pSelectAllCheckBox, &ugd->ug_Status.ug_bSelectAllChecked); + evas_object_smart_callback_add(pSelectAllCheckBox, "changed", __mf_ug_search_select_all_check_changed_cb, ugd); + + elm_object_part_content_set(pSelectAllLayout, "elm.icon", pSelectAllCheckBox); + elm_box_pack_start(ugd->ug_MainWindow.ug_pNaviBox, pSelectAllLayout); + } + if (result->dir_list != NULL) { + g_list_foreach(result->dir_list, mf_ug_search_view_item_append, ugd); + } + if (result->file_list != NULL) { + g_list_foreach(result->file_list, mf_ug_search_view_item_append, ugd); + } + } +} + + +static Eina_Bool __mf_ug_search_view_stop(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retvm_if(ugd == NULL, ECORE_CALLBACK_CANCEL, "ugd is NULL"); + + + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pSearchPopup); + + if (ugd->ug_UiGadget.ug_pSyncPipe != NULL) { + ecore_pipe_del(ugd->ug_UiGadget.ug_pSyncPipe); + ugd->ug_UiGadget.ug_pSyncPipe = NULL; + } + __mf_ug_search_view_result_cb(((ms_handle_t *) ugd->ug_Status.search_handler)->result, ugd); + + if (ugd->ug_Status.search_handler > 0) { + mf_ug_search_stop(ugd->ug_Status.search_handler); + } + + + if (ugd->ug_Status.search_handler > 0) { + mf_ug_search_finalize(&ugd->ug_Status.search_handler); + } + + UG_TRACE_END; + return ECORE_CALLBACK_CANCEL; +} + +static void __mf_ug_search_view_stop_cb(void *data, Evas_Object * obj, void *event_info) { + + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + __mf_ug_search_view_stop(ugd); + + UG_TRACE_END; +} + + +static int __mf_ug_search_view_idle_search_msg_cope_finished(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + if (ugd == NULL || ugd->ug_Status.msg_finish_idler == NULL) { + return ECORE_CALLBACK_CANCEL; + } + pthread_mutex_lock(&gLockSearchMsg); + if (flagSearchMsg == 0) { + flagSearchMsg = 1; + pthread_cond_signal(&gCondSearchMsg); + } + pthread_mutex_unlock(&gLockSearchMsg); + ugd->ug_Status.msg_finish_idler = NULL; + + return ECORE_CALLBACK_CANCEL; +} + +static void __mf_ug_search_view_pipe_cb(void *data, void *buffer, unsigned int nbyte) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + if (ugd == NULL) { + ug_debug("input ugd is NULL"); + return; + } + + mf_search_pipe_msg *pSearchMsg = (mf_search_pipe_msg *) buffer; + if (pSearchMsg == NULL) { + ug_debug("received message is NULL"); + goto MF_CONTINURE_SEARCH; + } + + if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_RESULT_REPORT) { + ug_debug("result get"); + } else if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_ROOT_CHANGE) { + ug_debug("root change "); + + char *new_desc = mf_ug_fm_svc_wrapper_translate_path(pSearchMsg->current_path); + //elm_object_text_set(ugd->ug_MainWindow.ug_pSearchPopup, new_desc); + elm_object_text_set(ugd->ug_MainWindow.ug_pSearchLabel, new_desc); + //elm_object_part_text_set(ugd->ug_MainWindow.ug_pSearchLabel, "path", new_desc); + if (pSearchMsg->current_path) { + free(pSearchMsg->current_path); + pSearchMsg->current_path = NULL; + } + if (new_desc != NULL) { + free(new_desc); + new_desc = NULL; + } + } else if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_FINISHED) { + + ug_ecore_idler_del(ugd->ug_Status.popup_del_idler); + UG_SAFE_FREE_OBJ(ugd->ug_MainWindow.ug_pSearchPopup); + //ugd->ug_Status.popup_del_idler = ecore_idler_add(mf_ug_cb_popup_del_idler_cb, ugd); + __mf_ug_search_view_result_cb((mf_search_result_t *) pSearchMsg->report_result, data); + } + +MF_CONTINURE_SEARCH: + ug_ecore_idler_del(ugd->ug_Status.msg_finish_idler); + ugd->ug_Status.msg_finish_idler = ecore_idler_add((Ecore_Task_Cb)__mf_ug_search_view_idle_search_msg_cope_finished, ugd); + //__mf_ug_search_view_idle_search_msg_cope_finished(NULL); + UG_TRACE_END; +} + +static void __mf_ug_search_view_idle_search_start(void *data) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + + ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd); + ug_mf_retm_if(pNavi_s == NULL, "pNavi_s is NULL"); + char *text = NULL; + + if (ugd->ug_UiGadget.ug_pExtension) + text = g_strdup(ugd->ug_UiGadget.ug_pExtension); + + int root_num = 0; + const char *SearchRoot[MF_SEARCH_ROOT_NUM] = {0}; + ug_debug("text is [%s] path is [%s]", text, ugd->ug_Status.ug_pPath->str); + if (ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE || ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) { + root_num = 2; + SearchRoot[0] = PHONE_FOLDER; + + SearchRoot[1] = MEMORY_FOLDER; + } else { + root_num = 1; + SearchRoot[0] = ugd->ug_Status.ug_pPath->str; + + } + //const char *SearchRoot[MF_SEARCH_ROOT_NUM] = { ugd->ug_Status.ug_pPath->str}; + //ug_debug("search path is [%s]", ugd->ug_Status.ug_pPath->str); + /*Start Search routine*/ + if (!mf_ug_search_start(ugd->ug_Status.search_handler, SearchRoot, root_num, \ + ((text) ? text : NULL), MF_SEARCH_OPTION_DEF, (void *)ugd)) { + ug_debug("start success"); + /*generate the popup used to show search path + **it's sure that new_desc is not NULL even if original path is NULL*/ + //ugd->ug_MainWindow.ug_pSearchPopup = mf_ug_popup_create(ugd, UG_POPMODE_SEARCH, NULL, MF_UG_LABEL_SEARCH, NULL, NULL, NULL, __mf_ug_search_view_stop_cb, ugd); + ugd->ug_MainWindow.ug_pSearchPopup = mf_ug_popup_create_search(ugd, __mf_ug_search_view_stop_cb, ugd); + } else { + ug_debug("start failed"); + } + ug_debug(); + + + if (text != NULL) { + free(text); + text = NULL; + } + +} + +void mf_ug_search_view_enter_search_routine(void *data, Evas_Object * obj, void *event_info) +{ + UG_TRACE_BEGIN; + ugData *ugd = (ugData *)data; + ug_mf_retm_if(ugd == NULL, "ugd is NULL"); + +#ifdef UG_THUMB_REAL_TIME_UPDATE + if (ugd->ug_Status.ug_pThumbUpdateTimer != NULL) { + ecore_timer_del(ugd->ug_Status.ug_pThumbUpdateTimer); + ugd->ug_Status.ug_pThumbUpdateTimer = NULL; + } +#endif + //ugd->ug_Status.ug_iMore = UG_MORE_SEARCH; + + if (ugd->ug_Status.search_handler > 0) + mf_ug_search_finalize(&ugd->ug_Status.search_handler); + + int ret = mf_ug_search_init(&ugd->ug_Status.search_handler); + ug_mf_retm_if(ret < 0, "Fail to mf_ug_search_init()"); + + if (ugd->ug_UiGadget.ug_pSyncPipe != NULL) { + ecore_pipe_del(ugd->ug_UiGadget.ug_pSyncPipe); + ugd->ug_UiGadget.ug_pSyncPipe = NULL; + } + ugd->ug_UiGadget.ug_pSyncPipe = ecore_pipe_add(__mf_ug_search_view_pipe_cb, ugd); + + if (ugd->ug_UiGadget.ug_pSyncPipe == NULL) { + ug_debug("add pipe failed"); + } + /*this is to init global variable to ensure the first message can be transmitted correctly*/ + /*flagSearchMsg is to indicate the condition wait to sync data of threads*/ + pthread_mutex_lock(&gLockSearchMsg); + flagSearchMsg = 1; + pthread_mutex_unlock(&gLockSearchMsg); + + /*delete guide text label in the box*/ + /*evas_object_del(elm_object_content_unset(pNavi_s->pNaviConform));*/ + __mf_ug_search_view_idle_search_start(ugd); + + UG_TRACE_END; +} + diff --git a/src/widget/mf-ug-tab-bar.c b/src/widget/mf-ug-tab-bar.c new file mode 100644 index 0000000..6aa4751 --- /dev/null +++ b/src/widget/mf-ug-tab-bar.c @@ -0,0 +1,266 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mf-ug-winset.h" +#include "mf-ug-util.h" +#include "mf-ug-fs-util.h" +#include "mf-ug-fm-svc-wrapper.h" +#include "mf-ug-cb.h" +#include "mf-ug-resource.h" + +/****************************** +** Prototype : mf_ug_tab_bar_create +** Description : Samsung +** Input : Evas_Object *parent +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +Evas_Object *mf_ug_tab_bar_create(Evas_Object *parent) +{ + UG_TRACE_BEGIN; + ug_mf_retv_if(parent == NULL, NULL); + Evas_Object *toolbar = elm_toolbar_add(parent); + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_object_style_set(toolbar, "tabbar/item_horizontal"); + elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_toolbar_homogeneous_set(toolbar, EINA_FALSE); + elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); + + UG_TRACE_BEGIN; + return toolbar; +} + + +/****************************** +** Prototype : mf_ug_tab_bar_append_item +** Description : Samsung +** Input : Evas_Object *pTabBar +** char *pTabIconPath +** char *pTabBarLabel +** Evas_Object *pTabView +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +Elm_Object_Item *mf_ug_tab_bar_append_item(Evas_Object *pTabBar, char *pTabIconPath, char *pTabBarLabel, void *user_data) +{ + UG_TRACE_BEGIN; + ug_mf_retv_if(pTabBar == NULL, NULL); + + Elm_Object_Item *pItem = NULL; + pItem = elm_toolbar_item_append(pTabBar, pTabIconPath, pTabBarLabel, mf_ug_cb_tab_bar_cb, user_data); + UG_TRACE_END; + return pItem; +} + + +/****************************** +** Prototype : mf_ug_tab_bar_set_item_view +** Description : Samsung +** Input : Elm_Object_Item *it +** Evas_Object * view +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_tab_bar_set_item_view(Evas_Object *tab_layout, Evas_Object *view) +{ + UG_TRACE_BEGIN; + ug_mf_retm_if(tab_layout == NULL, "tab_layout is NULL"); + ug_mf_retm_if(view == NULL, "view is NULL"); + Evas_Object *layout = tab_layout; + Evas_Object *unset = elm_object_part_content_get(layout, "elm.swallow.content"); + if (unset) { + elm_object_part_content_unset(layout, "elm.swallow.content"); + evas_object_hide(unset); + } + + elm_object_part_content_set(layout, "elm.swallow.content", view); + UG_TRACE_END; +} + + +/****************************** +** Prototype : mf_ug_tab_bar_remove_item_by_label +** Description : Samsung +** Input : Evas_Object *pTabBar +** char *pTabLabel +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_tab_bar_remove_item_by_label(Evas_Object *pTabBar, char *pTabLabel) +{ + UG_TRACE_BEGIN; + Elm_Object_Item *pItem = NULL; + pItem = elm_toolbar_first_item_get(pTabBar); + + while(pItem) { + if (g_strcmp0(pTabLabel, elm_object_item_text_get(pItem)) == 0) { + elm_object_item_del(pItem); + return; + } + pItem = elm_toolbar_item_next_get(pItem); + } + UG_TRACE_END; +} + +/****************************** +** Prototype : mf_ug_tab_bar_remove_all_items +** Description : Samsung +** Input : Evas_Object *pTabBar +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_tab_bar_remove_all_items(Evas_Object *pTabBar) +{ + + UG_TRACE_BEGIN; + Elm_Object_Item *it = NULL; + Elm_Object_Item *pNext = NULL; + + it = elm_toolbar_first_item_get(pTabBar); + while(it) { + pNext = elm_toolbar_item_next_get(it); + elm_object_item_del(it); + it = pNext; + } + UG_TRACE_END; +} + + +/****************************** +** Prototype : mf_ug_tab_bar_set_selected_item +** Description : Samsung +** Input : Elm_Object_Item* pItem +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_tab_bar_set_selected_item(Elm_Object_Item *pItem) +{ + UG_TRACE_BEGIN; + elm_toolbar_item_selected_set(pItem, EINA_TRUE); + UG_TRACE_END; +} + + +/****************************** +** Prototype : mf_ug_tab_bar_set_item_disable +** Description : Samsung +** Input : Evas_Object *pTabBar +** Eina_Bool disable +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2010/12/10 +** Author : Samsung +** Modification : Created function +** +******************************/ +void mf_ug_tab_bar_set_item_disable(Evas_Object *pTabBar, Eina_Bool disable) +{ + Elm_Object_Item *pCurrentItem = NULL; + + if (pTabBar != NULL) { + + pCurrentItem = elm_toolbar_first_item_get(pTabBar); + while(pCurrentItem) { + elm_object_item_disabled_set(pCurrentItem, disable); + pCurrentItem = elm_toolbar_item_next_get(pCurrentItem); + } + } +} + +int mf_ug_tab_bar_items_count_get(Evas_Object *pTabBar) +{ + ug_mf_retvm_if(pTabBar == NULL, 0, "pTabBar is NULL"); + + Elm_Object_Item *pCurrentItem = NULL; + int count = 0; + + pCurrentItem = elm_toolbar_first_item_get(pTabBar); + while(pCurrentItem) { + count++; + pCurrentItem = elm_toolbar_item_next_get(pCurrentItem); + } + + return count; +} + +Elm_Object_Item *mf_ug_tab_bar_get_item_by_label(Evas_Object *pTabBar, char *pTabLabel) +{ + ug_mf_retvm_if(pTabBar == NULL, NULL, "pTabBar is NULL"); + ug_mf_retvm_if(pTabLabel == NULL, NULL, "pTabLabel is NULL"); + Elm_Object_Item *pItem = NULL; + + pItem = elm_toolbar_first_item_get(pTabBar); + while(pItem) { + if (g_strcmp0(pTabLabel, elm_object_item_text_get(pItem)) == 0) { + return pItem; + } + pItem = elm_toolbar_item_next_get(pItem); + } + return NULL; +} + |