summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCMakeLists.txt6
-rwxr-xr-xinclude/data.h55
-rwxr-xr-xinclude/define.h114
-rwxr-xr-xinclude/util/file-util.h19
-rwxr-xr-xinclude/util/fs-oper.h (renamed from include/util/fs-util.h)118
-rwxr-xr-xinclude/util/utils.h32
-rwxr-xr-xinclude/view/dialog_popup.h (renamed from include/util/dialog_popup.h)6
-rwxr-xr-xinclude/view/select_folder_view.h25
-rwxr-xr-xinclude/view/submenu_view.h35
-rwxr-xr-xres/edc/layout/default.edc36
-rwxr-xr-xres/edc/view/base.edc15
-rwxr-xr-xres/edc/view/dialog_popup.edc473
-rwxr-xr-xres/edc/widget/button.edc106
-rwxr-xr-xres/edc/widget/genlist.edc89
-rwxr-xr-xres/images/gengrid/00_check_activate.pngbin1380 -> 0 bytes
-rwxr-xr-xres/images/gengrid/00_check_bg.pngbin2886 -> 0 bytes
-rwxr-xr-xres/images/gengrid/00_check_bg_ef.pngbin2894 -> 0 bytes
-rwxr-xr-xres/images/gengrid/00_check_bg_line.pngbin2896 -> 0 bytes
-rwxr-xr-xres/images/gengrid/00_check_focus.pngbin1082 -> 0 bytes
-rwxr-xr-xres/images/gengrid/00_focus_01.#.pngbin2864 -> 0 bytes
-rwxr-xr-xres/images/gengrid/my_files_sd_card.pngbin1196 -> 0 bytes
-rwxr-xr-xres/images/gengrid/myfile_icon_video_play.pngbin3814 -> 0 bytes
-rwxr-xr-xres/images/icon_button_more.pngbin1251 -> 0 bytes
-rwxr-xr-xres/images/icon_button_more_rotation_default_2.pngbin0 -> 261 bytes
-rwxr-xr-xsrc/layout/default.c1041
-rwxr-xr-xsrc/util/dialog_popup.c223
-rwxr-xr-xsrc/util/file-attr.c388
-rwxr-xr-xsrc/util/file-util.c181
-rwxr-xr-xsrc/util/fs-oper.c801
-rwxr-xr-xsrc/util/fs-util.c337
-rwxr-xr-xsrc/util/utils.c707
-rwxr-xr-xsrc/view/base.c267
-rwxr-xr-xsrc/view/dialog_popup.c405
-rwxr-xr-xsrc/view/select_folder_view.c639
-rwxr-xr-xsrc/view/submenu_view.c229
35 files changed, 3707 insertions, 2640 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d8aa664..8228bb2 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,11 +61,13 @@ SET(SRCS
src/view/base.c
src/layout/default.c
src/util/utils.c
- src/util/dialog_popup.c
src/util/file-attr.c
- src/util/fs-util.c
+ src/util/fs-oper.c
src/util/file-util.c
src/util/file-error.c
+ src/view/submenu_view.c
+ src/view/select_folder_view.c
+ src/view/dialog_popup.c
)
SET(TARGET_EDJ "${PROJECT_NAME}.edj")
diff --git a/include/data.h b/include/data.h
index b661781..4c5731f 100755
--- a/include/data.h
+++ b/include/data.h
@@ -15,12 +15,10 @@
*/
#include <Elementary.h>
-#include <viewmgr.h>
-#include <inputmgr.h>
#include <layoutmgr.h>
-#include <app_debug.h>
-#include "util/fs-util.h"
+#include "util/fs-oper.h"
+#include "view/dialog_popup.h"
#ifndef __AIR_MYFILES_DATA_H__
#define __AIR_MYFILES_DATA_H__
@@ -32,32 +30,35 @@ typedef struct list_data {
Eina_List *file_list;
Eina_List *folder_list;
- int depth;
-
char *path;
} list_data_s ;
struct _priv {
const char* selected_folder;
char* selected_parent_path;
+ char* new_folder_name;
int same;
- int expanded;
+ int diff;
int list_index;
+ int after_input_folder_name;
+ int submenu_index;
+ int expanded_item_index;
Evas_Object *win;
Evas_Object *base;
Evas_Object *layout;
- Evas_Object *menu_btn;
- Evas_Object *view_btn;
+
Evas_Object *popup_win;
- Evas_Object *popup_base;
+ Evas_Object *popup_genlist;
+ Evas_Object *popup_layout;
- Evas_Object *icon1;
- Evas_Object *icon2;
+ Evas_Object *confirm_btn;
layoutmgr *lmgr;
Elm_Object_Item *item;
+
+ dialog_popup_info_t *popup_info;
};
typedef struct path_item_data {
@@ -74,32 +75,38 @@ typedef struct path_item_data {
} path_item_data_s;
typedef struct item_data {
- const char *last_path;
- char *selected_folder_path;
+ char *selected_item_fullpath;
char *parent_path;
char *name;
char *file_size;
+ char *time;
int index;
- int folder_count;
- int file_count;
- int is_home;
- int is_empty;
int expanded;
int level;
+ int flag;
Elm_Object_Item *item;
- Evas_Object *base;
- Evas_Object *layout;
-
Eina_List *child;
- Eina_List *child_file_size;
- Eina_List *file_list;
- Eina_List *folder_list;
fsNodeInfo *node;
fsFileType type;
} item_data_s;
+typedef struct util_item_data {
+ char *folder_name;
+ char *parent_path;
+ char *new_folder_name;
+
+ int index;
+ int expanded;
+ int level;
+
+ Elm_Object_Item *item;
+ Eina_List *child;
+
+ fsNodeInfo *node;
+} util_item_data_s;
+
#endif /* __AIR_MYFILES_DATA_H__ */
diff --git a/include/define.h b/include/define.h
index 1159946..0ea41ff 100755
--- a/include/define.h
+++ b/include/define.h
@@ -20,23 +20,21 @@
#include "layout/default.h"
/* Definitions for common */
-#define SOURCE_PROGRAM "program"
#define SOURCE_ELM "elm"
#define SOURCE_EDC "edc"
/* View ID */
#define VIEW_BASE "VIEW_BASE"
-/* Layout ID */
-#define LAYOUT_MYFILES "LAYOUT_MYFILES"
-
/* Group for EDC */
#define GRP_LAYOUT_BASE "grp.layout.base"
#define GRP_VIEW_SUBMENU "grp.view.submenu"
#define GRP_VIEW_SELECT_FOLDER "grp.view.select.folder"
-#define GRP_ACTION_MENU_CONTENTS "grp.action.menu.contents"
#define GRP_DIALOG_POPUP "grp.dialog.popup"
#define GRP_DIALOG_POPUP_NO_TITLE "grp.dialog.popup.notitle"
+#define GRP_DIALOG_POPUP_NO_TITLE_ONE_BTN "grp.dialog.popup.notitle.onebtn"
+#define GRP_DIALOG_POPUP_SETTING "grp.dialog.popup.setting"
+#define GRP_DIALOG_POPUP_DEL "grp.dialog.popup.del"
#define GRP_VIEW_DEFAULT "grp.view.default"
#define GRP_VIEW_SELECT "grp.view.select"
@@ -47,23 +45,6 @@
#define PART_TOP_TITLE_BG "part.top.title.bg"
#define PART_MENU "part.menu"
#define PART_CONFIRM "part.confirm"
-#define PART_SORT "part.sort"
-#define PART_GENGRID "part.gengrid"
-#define PART_APP_COUNT "part.app.count"
-#define PART_CONTENTS_TEXT "part.contents.text"
-#define PART_THUMB_BG "part.thumb.bg"
-#define PART_THUMB_ICON "part.thumb.icon"
-#define PART_TEXT_BG "part.text.bg"
-#define PART_THUMB_TEXT "part.thumb.text"
-#define PART_THUMB_TEXT_BROWSER "part.thumb.text.browser"
-#define PART_TOP_BTN "part.top.button"
-#define PART_FAVORITE "part.favorite"
-#define PART_NO_FAVORITE "part.no.favorite"
-#define PART_BUTTON1 "button1"
-#define PART_BUTTON2 "button2"
-#define PART_POPUP_TITLE "title,text"
-#define PART_ACTION_MENU "part.action.menu"
-
#define PART_FILE_PATH "part.file.path"
#define PART_FILE_PATH_BG "part.file.path.bg"
#define PART_CONTENT_AREA "part.content.area"
@@ -72,50 +53,16 @@
#define PART_FOLDER_LIST_BG "part.folder.list.bg"
#define PART_FILE_LIST "part.file.list"
#define PART_FILE_LIST_BG "part.file.list.bg"
-
-/* State for EDC */
-#define STATE_BROWSER "is_browser"
-#define STATE_NOT_BROWSER "not_browser"
-
-/* Style */
-#define STYLE_SORT_BTN "style.sort.button"
-#define STYLE_OPTION_BTN "style.option.button"
-#define STYLE_CTXPOPUP "style.ctxpopup"
-#define STYLE_MYAPP "style.myapp"
-#define STYLE_FAVORITE "style.favorite"
-#define STYLE_LIVETV_BTN "style.livetv.button"
-#define STYLE_MORE_BTN "style.more.button"
-#define STYLE_ACTION_MENU_FAV_BTN "style.action.menu.favorite.button"
-#define STYLE_ACTION_MENU_UNINSTALL_BTN "style.action.menu.uninstall.button"
-#define STYLE_TOAST "style.toast"
+#define PART_FILE_LIST_HOME "part.file.list.home"
+#define PART_FILE_LIST_NO_CONTENT "part.file.list.no.content"
/* Signal */
#define SIGNAL_FOCUSED "elm,action,focus"
#define SIGNAL_UNFOCUSED "elm,action,unfocus"
#define SIGNAL_DISABLED "elm,state,disabled"
#define SIGNAL_ITEM_SELECTED "item,selected"
-#define SIGNAL_ITEM_UNSELECTED "item,unselected"
-#define SIGNAL_NO_NOTIFICATION "signal.no_notification"
-#define SIGNAL_NOTIFICATION "signal.notification"
-#define SIGNAL_TOGGLE "elm,state,toggle"
-#define SIGNAL_UNTOGGLE "elm,state,untoggle"
-#define SIGNAL_CHILD_REMOVED "child,removed"
-#define SIGNAL_SHOW "show"
-#define SIGNAL_HIDE "hide"
-#define SIGNAL_HIDE_FINISHED "elm,action,hide,finished"
-
#define SIG_VISIBLE "visible"
#define SIG_INVISIBLE "invisible"
-#define SIG_UNSELECTED "unselected"
-#define SIG_TIMEOUT "timeout"
-
-/* Signal Source */
-#define SRC_MYAPPS "source.myapps"
-#define SRC_MENU_BTN "source.menu.btn"
-#define SRC_SORT_BTN "source.sort.btn"
-#define SRC_LIVETV_BTN "source.livetv.btn"
-#define SRC_ACTION_BTN "source.action.btn"
-#define SRC_FAVORITE_ICON "source.favorite.icon"
/* Font */
#define FONT_TIZENSANS_REGULAR "BreezeSans"
@@ -123,10 +70,6 @@
/* String */
#define STR_MYFILES "My Files"
-#define STR_APPSTORE "App Store"
-#define STR_RECENT "Recent"
-#define STR_A_TO_Z "A-Z"
-#define STR_Z_TO_A "Z-A"
#define STR_SELECT_TARGET_FOLDER "Select target folder"
#define STR_NEW_FOLDER "New Folder"
#define STR_MENU_COPY "Copy"
@@ -142,52 +85,9 @@
#define STR_NEW_FOLDER_ENTRY "Input folder name"
#define STR_RENAME_ENTRY "Input folder/file name"
+#define MF_HIDDEN_STATE "hiden_state"
+
/* Count */
#define MENU_COUNT 2
-#define SORT_COUNT 3
-#define ACTION_MENU_COUNT 2
-
-/* Size */
-#define SIZE_MYAPPS_GRID_WIDTH (212 + 26)
-#define SIZE_MYAPPS_GRID_HEIGHT (294 + 26)
-#define SIZE_FAVORITE_GRID_WIDTH (210 + 20)
-#define SIZE_FAVORITE_GRID_HEIGHT (292 + 20)
-#define SIZE_STR 1024
-#define SIZE_MENU_BOX_PAD_H (40 + 40)
-#define SIZE_MENU_BOX_PAD_V 0
-#define SIZE_ICON_MAX 100
-#define SIZE_ACTION_TABLE_BORDER 0
-#define SIZE_COL_MAX 4
-#define SIZE_TOAST_TIMEOUT 5.0
-#define SIZE_FAVORITE_COL_MAX 2
-#define SIZE_SCROLLER_STEP 312
-
-/* Image */
-#define DEFAULT_APP_ICON_PNG IMGDIR"/ico_default.png"
-#define FAVORITE_ICON_PNG "ic_thumbnail_favorite_01.png"
-#define BROWSER_ICON_PNG IMGDIR"/ic_apps_web.png"
-#define ARROW_ICON_UP_PNG "btn_option_arrow_nor.png"
-#define ARROW_ICON_UP_FOC_PNG "btn_option_arrow_foc_up.png"
-#define ARROW_ICON_SEL_PNG "btn_option_arrow_sel.png"
-#define ARROW_ICON_DISABLE_PNG "btn_option_arrow_dis.png"
-#define ACTION_FAV_NOR_PNG "btn_menu_favorite_nor.png"
-#define ACTION_FAV_FOC_PNG "btn_menu_favorite_foc.png"
-#define ACTION_FAV_SEL_PNG "btn_menu_favorite_sel.png"
-#define ACTION_FAV_DIS_PNG "btn_menu_favorite_dis.png"
-#define ACTION_UNFAV_NOR_PNG "btn_menu_remote_favorite_nor.png"
-#define ACTION_UNFAV_FOC_PNG "btn_menu_remote_favorite_foc.png"
-#define ACTION_UNINSTALL_NOR_PNG "btn_menu_del_nor.png"
-#define ACTION_UNINSTALL_FOC_PNG "btn_menu_del_foc.png"
-#define ACTION_UNINSTALL_SEL_PNG "btn_menu_del_sel.png"
-#define ACTION_UNINSTALL_DIS_PNG "btn_menu_del_dis.png"
-
-/* Transition */
-#define TRANSITION_FOCUS DECELERATE 0.20
-#define TRANSITION_CLICK DECELERATE 0
-#define TRANSITION_MENU_SHOW SIN 0.45
-#define TRANSITION_MENU_HIDE DECEL 0.3
-
-/* Color */
-#define COLOR_ITEM_FOCUS 0 119 246 255
#endif /* __AIR_MYFILES_DEFINE_H__ */
diff --git a/include/util/file-util.h b/include/util/file-util.h
index 6776a8a..ace07ec 100755
--- a/include/util/file-util.h
+++ b/include/util/file-util.h
@@ -25,7 +25,7 @@
#include <dirent.h>
#include <Elementary.h>
-#include "util/fs-util.h"
+#include "util/fs-oper.h"
#include "data.h"
typedef enum _MYFILE_CONTENT_TYPE MYFILE_CONTENT_TYPE;
@@ -39,6 +39,16 @@ enum _MYFILE_CONTENT_TYPE {
MYFILE_TYPE_MAX
};
+typedef enum _LAUNCH_TYPE LAUNCH_TYPE;
+enum _LAUNCH_TYPE {
+ LAUNCH_TYPE_FORK = 0,
+ LAUNCH_TYPE_FAKE,
+ LAUNCH_TYPE_FAIL,
+ LAUNCH_TYPE_DIR,
+ LAUNCH_TYPE_UNSUPPORT,
+ LAUNCH_TYPE_MAX
+};
+
const char* mf_file_get(const char path[]);
char* mf_dir_get(const char path[]);
int mf_file_exists(const char *path);
@@ -50,14 +60,15 @@ char *mf_strip_ext(const char *path);
int mf_file_unlink(const char *filename);
int mf_file_size(const char *filename);
int mf_file_rmdir(const char *filename);
-Eina_List *mf_file_ls(const char *dir);
+Eina_List *mf_file_ls(const char *dir, struct _priv *priv);
int mf_file_recursive_rm(const char *dir);
int mf_file_cp(const char *src, const char *dst);
int mf_file_mv(const char *src, const char *dst);
int mf_remove(const char *filename);
+int mf_util_get_hidden_state(int *value);
+void mf_util_set_hidden_state(int value);
void mf_util_free_eina_list_with_data(Eina_List **list, MYFILE_CONTENT_TYPE type);
-void util_free_item_data_s(item_data_s *id);
-void util_free_path_item_data_s(path_item_data_s *pid);
+int mf_launch_service(void *data, char *path);
#endif /*__mf_FILE_UTIL_H__*/
diff --git a/include/util/fs-util.h b/include/util/fs-oper.h
index b2f1ed7..4494b55 100755
--- a/include/util/fs-util.h
+++ b/include/util/fs-oper.h
@@ -66,13 +66,6 @@
} \
} while (0)
-#define SAFE_DEL_NAVI_ITEM(x) do {\
- if ((*x) != NULL) {\
- elm_object_item_del(*x); \
- (*x) = NULL;\
- } \
- } while (0)
-
#define SAFE_DEL_ECORE_TIMER(timer) do { \
if (timer) { \
ecore_timer_del(timer);\
@@ -148,17 +141,22 @@ static inline char *Get_Parent_Path(int storage_id)
#define MEMORY_FOLDER Get_Root_Path(STORAGE_TYPE_EXTERNAL)
#define PHONE_PARENT Get_Parent_Path(STORAGE_TYPE_INTERNAL)
#define STORAGE_PARENT Get_Parent_Path(STORAGE_TYPE_EXTERNAL)
-#define PHONE_NAME "content"
-#define MMC_NAME "2F72-0D21"
#define MYFILE_NAME_PATTERN "[\\<>:;*\"|?/]"
/* File system define default folder */
-#define DEFAULT_FOLDER_CAMERA_SHOTS "Camera shots"
+/*#define DEFAULT_FOLDER_CAMERA_SHOTS "Camera shots"
#define DEFAULT_FOLDER_DOWNLOADS "Downloads"
#define DEFAULT_FOLDER_IMAGE "Images"
#define DEFAULT_FOLDER_VIDEO "Videos"
-#define DEFAULT_FOLDER_MUSIC "Music"
+#define DEFAULT_FOLDER_MUSIC "Music"*/
+
+
+typedef enum __mf_list_type mf_list_type;
+enum __mf_list_type {
+ mf_list_recent_files = 0,
+ mf_list_normal,
+};
typedef enum _SORT_OPTION fsSortOption;
enum _SORT_OPTION {
@@ -251,14 +249,19 @@ enum __MF_SORT_BY_PRIORITY_SEQUENCE {
#define MF_ERROR_CHECK_DST_ARG_VALID 0x0002
#define MF_ERROR_CHECK_SRC_EXIST 0x0004
#define MF_ERROR_CHECK_DST_EXIST 0x0008
-#define MF_ERROR_CHECK_SRC_PATH_VALID 0x0010
-#define MF_ERROR_CHECK_DST_PATH_VALID 0x0020
+#define MF_ERROR_CHECK_SRC_PATH_VALID 0x0010
+#define MF_ERROR_CHECK_DST_PATH_VALID 0x0020
#define MF_ERROR_CHECK_SRC_PARENT_DIR_EXIST 0x0040
#define MF_ERROR_CHECK_DST_PARENT_DIR_EXIST 0x0080
#define MF_ERROR_CHECK_DUPLICATED 0x0100
-/* File system related callback definition */
-typedef int (*myfile_operation_cb) (const char *current_path, const char *destination, int copied_size, FILE * fSource, FILE * fDestination, void *data);
+typedef enum _file_hiden_state_e file_hiden_state_e;
+enum _file_hiden_state_e {
+ FILE_HIDDEN_NONE = 0,
+ FILE_HIDDEN_SHOW,
+ FILE_HIDDEN_HIDE,
+ FILE_HIDDEN_MAX
+};
typedef enum {
STORAGE_TYPE_NONE = 0,
@@ -292,8 +295,6 @@ typedef struct _node_info {
char *storage_uuid;
} node_info;
-#define GIGABYTE (1024.0*1024.0*1024.0)
-
typedef struct _FS_NODE_INFO fsNodeInfo;
struct _FS_NODE_INFO {
char *path;
@@ -310,52 +311,38 @@ struct _FS_NODE_INFO {
};
#ifndef DEFAULT_ICON
-#define DEFAULT_ICON "my_files_sd_card.png"
+#define DEFAULT_ICON "/icon/myfile_icon_folder.png"
#endif
-#define MF_ICON_FOLDER "icon/myfile_icon_folder.png"
-#define MF_ICON_IMAGE "icon/myfile_icon_images.png"
-#define MF_ICON_VIDEO "icon/myfile_icon_video.png"
-#define MF_ICON_MUSIC "icon/myfile_icon_music.png"
-#define MF_ICON_SOUND "icon/myfile_icon_amr.png"
-#define MF_ICON_PDF "icon/myfile_icon_pdf.png"
-#define MF_ICON_DOC "icon/myfile_icon_word.png"
-#define MF_ICON_PPT "icon/myfile_icon_ppt.png"
-#define MF_ICON_EXCEL "icon/myfile_icon_excel.png"
-#define MF_ICON_HTML "icon/myfile_icon_html.png"
-#define MF_ICON_FLASH "icon/myfile_icon_swf.png"
-#define MF_ICON_TXT "icon/myfile_icon_text.png"
-#define MF_ICON_VCONTACT "icon/myfile_icon_vcard.png"
-#define MF_ICON_VCALENDAR "icon/myfile_icon_vcalender.png"
-#define MF_ICON_VNOTE "icon/myfile_icon_vText.png"
-#define MF_ICON_RSS "icon/myfile_icon_rss.png"
-#define MF_ICON_JAVA "icon/myfile_icon_java.png"
-#define MF_ICON_MUSIC_PAUSE "icon/myfile_icon_control_pause.png"
-#define MF_ICON_VIDEO_PLAY "icon/myfile_icon_video_play.png"
-#define MF_ICON_TPK "icon/myfile_icon_tpk.png"
-#define MF_ICON_SNB "icon/myfile_icon_snb.png"
-#define MF_ICON_HWP "icon/myfile_icon_hwp.png"
-#define MF_ICON_GUL "icon/myfile_icon_etc.png"
-#define MF_ICON_EMAIL "icon/myfile_icon_email.png"
-#define MF_ICON_TASK "icon/myfile_icon_task.png"
-#define MF_ICON_ZIP "icon/myfile_icon_zip.png"
-#define MF_ICON_SVG "icon/myfile_icon_svg.png"
-
-typedef enum __mf_list_type mf_list_type;
-enum __mf_list_type {
- mf_list_recent_files = 0,
- mf_list_normal,
-};
-
-typedef enum __mf_thumbnail_type mf_thumbnail_type;
-enum __mf_thumbnail_type {
- MF_THUMBNAIL_TYPE_DEFAULT,
- MF_THUMBNAIL_TYPE_THUMBNAIL,
- MF_THUMBNAIL_TYPE_MAX
-};
+#define MF_ICON_FOLDER "/icon/myfile_icon_folder.png"
+#define MF_ICON_IMAGE "/icon/myfile_icon_images.png"
+#define MF_ICON_VIDEO "/icon/myfile_icon_video.png"
+#define MF_ICON_MUSIC "/icon/myfile_icon_music.png"
+#define MF_ICON_SOUND "/icon/myfile_icon_amr.png"
+#define MF_ICON_PDF "/icon/myfile_icon_pdf.png"
+#define MF_ICON_DOC "/icon/myfile_icon_word.png"
+#define MF_ICON_PPT "/icon/myfile_icon_ppt.png"
+#define MF_ICON_EXCEL "/icon/myfile_icon_excel.png"
+#define MF_ICON_HTML "/icon/myfile_icon_html.png"
+#define MF_ICON_FLASH "/icon/myfile_icon_swf.png"
+#define MF_ICON_TXT "/icon/myfile_icon_text.png"
+#define MF_ICON_VCONTACT "/icon/myfile_icon_vcard.png"
+#define MF_ICON_VCALENDAR "/icon/myfile_icon_vcalender.png"
+#define MF_ICON_VNOTE "/icon/myfile_icon_vText.png"
+#define MF_ICON_RSS "/icon/myfile_icon_rss.png"
+#define MF_ICON_JAVA "/icon/myfile_icon_java.png"
+#define MF_ICON_MUSIC_PAUSE "/icon/myfile_icon_control_pause.png"
+#define MF_ICON_VIDEO_PLAY "/icon/myfile_icon_video_play.png"
+#define MF_ICON_TPK "/icon/myfile_icon_tpk.png"
+#define MF_ICON_SNB "/icon/myfile_icon_snb.png"
+#define MF_ICON_HWP "/icon/myfile_icon_hwp.png"
+#define MF_ICON_GUL "/icon/myfile_icon_etc.png"
+#define MF_ICON_EMAIL "/icon/myfile_icon_email.png"
+#define MF_ICON_TASK "/icon/myfile_icon_task.png"
+#define MF_ICON_ZIP "/icon/myfile_icon_zip.png"
+#define MF_ICON_SVG "/icon/myfile_icon_svg.png"
/*---------- File Attribute Related ----------*/
-
void mf_file_attr_get_file_size_info(char **file_size, off_t src_size);
int mf_file_attr_get_file_stat(const char *filename, fsNodeInfo **node);
int mf_file_attr_get_file_category(const char *filepath, fsFileType *category);
@@ -366,18 +353,11 @@ int mf_file_attr_is_duplicated_name(const char *dir, const char *name);
int mf_file_attr_is_valid_name(const char *filename);
int mf_file_attr_is_right_dir_path(const char *dir_path);
int mf_file_attr_is_right_file_path(const char *file_path);
-int mf_file_attr_get_logical_path_by_full(const char *full_path, char **path);
int mf_file_attr_get_path_level(const char *fullpath, int *level);
-int mf_file_attr_is_system_dir(char *fullpath, bool *result);
-int mf_file_attr_is_disk_link(const char *fullpath, bool *result);
-int mf_file_attr_get_file_mdate(const char *filename, double *date);
-int mf_file_attr_media_has_video(const char *filename);
+char * mf_file_attr_get_file_mdate_time(const char *filename);
int mf_file_attr_get_file_size(const char *filename, off_t *size);
-int mf_file_attr_get_file_icon(const char *file_path, int *error_code, int view_type, char **thumbnail, media_info_h *media_info);
-const char *mf_file_attr_get_recent_default_icon_by_type(fsFileType ftype);
const char *mf_file_attr_get_default_icon_by_type(fsFileType ftype);
fsFileType mf_file_attr_get_file_type_by_mime(const char *file_path);
-fsFileType mf_file_attr_get_file_type(const char *mime);
bool __mf_add_storage_info_to_list(media_storage_h storage, void *data);
@@ -386,7 +366,7 @@ int mf_fs_oper_error(const char *src, const char *dst, int check_option);
int mf_fs_oper_read_dir(const char *path, Eina_List **dir_list, Eina_List **file_list);
int mf_fs_oper_create_dir(const char *dir);
int mf_fs_oper_rename_file(const char *src, const char *dst);
-/*void mf_fs_oper_sort_list(Eina_List **list, int sort_opt);
-int __mf_fs_oper_sort_by_name_cb_A2Z(const void *d1, const void *d2);*/
+void mf_fs_oper_sort_list(Eina_List **list, int sort_opt);
+int __mf_fs_oper_sort_by_name_cb_A2Z(const void *d1, const void *d2);
#endif /*_MYFILE_FILESYSTEM_UTIL_H_*/
diff --git a/include/util/utils.h b/include/util/utils.h
index d6ed044..488e6e5 100755
--- a/include/util/utils.h
+++ b/include/util/utils.h
@@ -23,27 +23,15 @@
Evas_Object *utils_add_window(const char *name);
Evas_Object *utils_add_layout(Evas_Object *parent, const char *group,
Eina_Bool win_resize);
-Evas_Object *utils_add_box(Evas_Object *parent, const char *part,
- Eina_Bool horizontal, Evas_Coord padding_h,
- Evas_Coord padding_v);
-Evas_Object *utils_add_button(Evas_Object *parent, const char *part,
- const char *text, const char *style);
-Evas_Object *utils_add_gengrid(Evas_Object *parent, Eina_Bool horizontal,
- int width, int height);
-Evas_Object *utils_add_table(Evas_Object *table, const char *part,
- int padding_x, int padding_y);
-Evas_Object *utils_add_notify(Evas_Object *parent, const char *text,
- const char *noti_style, const char *label_style,
- int timeout);
-Evas_Object *utils_add_popup(Evas_Object *parent, const char *style,
- const char *popup_title, const char *popup_text);
-Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id,
- const char **opt_text, input_handler *opt_handler, void *data);
-Evas_Object *utils_add_scroller(Evas_Object *parent, const char *part,
- Evas_Object *content);
-bool utils_launch_app(const char *appid, const char *key, const char *value);
-bool utils_uninstall_app(const char *pkgid, const char *pkgtype);
-void utils_show_submenu_popup(struct _priv *priv);
-void utils_show_select_folder_popup(struct _priv *priv);
+
+char *utils_get_combined_string(const char *first, const char *second, const char *third);
+char* utils_get_list_data_get(Eina_List *list, int index);
+
+void utils_show_dialog_popup(dialog_popup_type_e type, char *title,
+ char *content, char *btn1_text, char *btn2_text, struct _priv *priv);
+
+void util_free_item_data_s(item_data_s *id);
+void util_free_util_item_data_s(util_item_data_s *uid);
+void util_free_path_item_data_s(path_item_data_s *pid);
#endif /* __AIR_MYFILES_UTILS_H__ */
diff --git a/include/util/dialog_popup.h b/include/view/dialog_popup.h
index 791e55d..97e07a4 100755
--- a/include/util/dialog_popup.h
+++ b/include/view/dialog_popup.h
@@ -39,6 +39,8 @@ typedef enum _dialog_popup_type {
DIALOG_POPUP_TYPE_INPUT_NAME = 2,
DIALOG_POPUP_TYPE_CONFIGURATION = 3,
DIALOG_POPUP_TYPE_SUBMENU = 4,
+ DIALOG_POPUP_TYPE_NOTIFY = 5,
+ DIALOG_POPUP_TYPE_NOTIFY_NO_CLOSE = 6,
} dialog_popup_type_e;
typedef struct _dialog_popup_info_t {
@@ -48,11 +50,13 @@ typedef struct _dialog_popup_info_t {
char *button_1_text;
char *button_2_text;
void *data;
+
+ Evas_Object *entry;
/* Button event handler is required */
} dialog_popup_info_t;
/* Functions */
-Evas_Object *dialog_popup_create(/*Evas_Object *win, */dialog_popup_info_t *dialog_popup_info);
+Evas_Object *dialog_popup_create(dialog_popup_info_t *dialog_popup_info);
#endif /* __AIR_MYFILES_DIALOG_POPUP_VIEW_H__ */
diff --git a/include/view/select_folder_view.h b/include/view/select_folder_view.h
new file mode 100755
index 0000000..c4e4bd1
--- /dev/null
+++ b/include/view/select_folder_view.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <inputmgr.h>
+#include "data.h"
+
+#ifndef __AIR_MYFILES_VIEW_SELECT_FOLDER_VIEW_H__
+#define __AIR_MYFILES_VIEW_SELECT_FOLDER_VIEW_H__
+
+void utils_show_select_folder_popup(struct _priv *priv);
+
+#endif /*__AIR_MYFILES_VIEW_SELECT_FOLDER_VIEW_H__*/
diff --git a/include/view/submenu_view.h b/include/view/submenu_view.h
new file mode 100755
index 0000000..79a2bcd
--- /dev/null
+++ b/include/view/submenu_view.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <inputmgr.h>
+#include "data.h"
+
+#ifndef __AIR_MYFILES_VIEW_SUBMENU_VIEW_H__
+#define __AIR_MYFILES_VIEW_SUBMENU_VIEW_H__
+
+typedef enum _SUBMENU_TYPE SUBMENU_TYPE;
+enum _SUBMENU_TYPE {
+ SUBMENU_COPY = 1,
+ SUBMENU_MOVE,
+ SUBMENU_RENAME,
+ SUBMENU_NEW_FOLDER,
+ SUBMENU_DELETE,
+ SUBMENU_SETTING
+};
+
+void utils_show_submenu_popup(struct _priv *priv);
+
+#endif /*__AIR_MYFILES_VIEW_SUBMENU_VIEW_H__*/
diff --git a/res/edc/layout/default.edc b/res/edc/layout/default.edc
index ec98ce8..c722b3a 100755
--- a/res/edc/layout/default.edc
+++ b/res/edc/layout/default.edc
@@ -16,6 +16,8 @@
#include "../../../include/define.h"
+#define COLOR_TEXT_TITLE 51 51 51 255
+
group {
data.item: "focus_highlight" "on";
name: GRP_VIEW_DEFAULT;
@@ -135,5 +137,39 @@ group {
visible: 1;
}
}
+ part {
+ name: PART_FILE_LIST_HOME;
+ type: TEXT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ text {
+ font: FONT_TIZENSANS_LIGHT;
+ size: 36;
+ align: 0.5 0.5;
+ }
+ rel1.to: PART_FILE_LIST;
+ color: COLOR_TEXT_TITLE;
+ rel2.to: PART_FILE_LIST;
+ visible: 1;
+ }
+ }
+ part {
+ name: PART_FILE_LIST_NO_CONTENT;
+ type: TEXT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ text {
+ font: FONT_TIZENSANS_LIGHT;
+ size: 36;
+ align: 0.5 0.5;
+ }
+ rel1.to: PART_FILE_LIST;
+ color: COLOR_TEXT_TITLE;
+ rel2.to: PART_FILE_LIST;
+ visible: 1;
+ }
+ }
}
} \ No newline at end of file
diff --git a/res/edc/view/base.edc b/res/edc/view/base.edc
index f3fcc07..641a11a 100755
--- a/res/edc/view/base.edc
+++ b/res/edc/view/base.edc
@@ -70,21 +70,6 @@ group {
fixed: 1 1;
}
}
- /*part {
- name: PART_TOP_TITLE;
- type: SWALLOW;
- scale: 1;
- description {
- state: "default" 0.0;
- rel1.to: "padding.title.left";
- rel1.relative: 1.0 0.0;
- rel2.to_x: PART_MENU;
- rel2.to_y: PART_TOP_TITLE_BG;
- rel2.relative: 0.0 1.0;
- align: 0.5 0.5;
- visible: 1;
- }
- }*/
part {
name: PART_TOP_TITLE;
type: TEXT;
diff --git a/res/edc/view/dialog_popup.edc b/res/edc/view/dialog_popup.edc
index 5e8b3b7..602f52f 100755
--- a/res/edc/view/dialog_popup.edc
+++ b/res/edc/view/dialog_popup.edc
@@ -187,40 +187,276 @@ group {
align: 0.0 0.0;
}
}
-/* part {
- name: "padding.buttons.top";
- type: SPACER;
+ part {
+ name: "part_button_1";
+ type: SWALLOW;
scale: 1;
description {
state: "default" 0.0;
rel1 {
+ to: "padding.buttons";
relative: 0.0 0.0;
+ }
+ rel2 {
to: "padding.buttons";
+ relative: 0.5 1.0;
+ }
+ visible: 1;
+ align: 0.0 0.0;
+ }
+ }
+ part {
+ name: "part_button_2";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "part_button_1";
+ relative: 1.0 0.0;
}
rel2 {
- relative: 1.0 0.15;
to: "padding.buttons";
+ relative: 1.0 1.0;
}
+ visible: 1;
align: 0.0 0.0;
}
}
+ }
+}
+
+group {
+ name: GRP_DIALOG_POPUP_SETTING;
+ parts {
+ part {
+ name: "dimmed_bg";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 0 0;
+ color: 0 0 0 100;
+ visible: 1;
+ }
+ }
part {
- name: "padding.buttons.bottom";
+ name: "popup_bg";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 0 0;
+ color: 255 255 255 255;
+ visible: 1;
+ rel1 {
+ relative: 0.35 0.35;
+ to : "dimmed_bg";
+ }
+ rel2 {
+ relative: 0.65 0.65;
+ to : "dimmed_bg";
+ }
+ }
+ }
+ part {
+ name: "padding.title.left";
type: SPACER;
scale: 1;
description {
state: "default" 0.0;
rel1 {
- relative: 0.0 0.85;
- to: "padding.buttons";
+ relative: 0.0 0.0;
+ to: "popup_bg";
+ }
+ rel2 {
+ relative: 0.05 1.0;
+ to: "popup_bg";
+ }
+ align: 0.0 0.5;
+ }
+ }
+ part {
+ name: "padding.title.right";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ relative: 0.95 0.0;
+ to: "popup_bg";
}
rel2 {
relative: 1.0 1.0;
- to: "padding.buttons";
+ to: "popup_bg";
+ }
+ align: 0.0 0.0;
+ }
+ }
+ part {
+ name: "padding.title.top";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: 0 34;
+ rel1 {
+ relative: 0.0 0.0;
+ to: "popup_bg";
+ }
+ rel2 {
+ relative: 1.0 0.0;
+ to: "popup_bg";
+ }
+ align: 0.5 0.0;
+ fixed: 1 0;
+ }
+ }
+ part {
+ name: "part_title_label";
+ type: TEXT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to_x: "padding.title.left";
+ to_y: "padding.title.top";
+ relative: 1.0 1.0;
+ }
+ rel2 {
+ to_x: "padding.title.left";
+ to_y: "padding.title.top";
+ relative: 1.0 1.0;
+ }
+ text {
+ font: FONT_TIZENSANS_LIGHT;
+ text: "TITLE";
+ size: 28;
+ min: 1 1;
+ ellipsis: -1;
+ }
+ color: 51 51 51 255;
+ min: 0 28;
+ fixed: 1 1;
+ visible: 1;
+ align: 0.0 0.0;
+ }
+ }
+ part {
+ name: "part_content_swallow";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to_x: "padding.title.left";
+ to_y: "part_title_label";
+ relative: 1.4 3.4;
+ }
+ rel2 {
+ to_x: "padding.title.left";
+ to_y: "part_title_label";
+ relative: 1.7 3.8;
+ }
+ visible: 1;
+ }
+ }
+ part {
+ name: "part_content_text_bg";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to_x: "part_content_swallow";
+ to_y: "part_title_label";
+ relative: 1.0 1.0;
+ }
+ rel2 {
+ to_x: "padding.title.right";
+ to_y: "part_divider";
+ relative: 0.0 0.0;
+ }
+ visible: 0;
+ color: 0 119 246 255;
+ }
+ description {
+ state: "focused" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ part {
+ name: "part_content_text";
+ type: TEXT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to_x: "part_content_swallow";
+ to_y: "part_title_label";
+ relative: 1.0 1.0;
+ }
+ rel2 {
+ to_x: "padding.title.right";
+ to_y: "part_divider";
+ relative: 0.0 0.0;
+ }
+ text {
+ font: FONT_TIZENSANS_LIGHT;
+ text: "Show hidden files";
+ size: 28;
+ min: 1 1;
+ ellipsis: -1;
+ align: 0.0 0.5;
+ }
+ color: 51 51 51 255;
+ min: 0 28;
+ fixed: 1 1;
+ visible: 1;
+ }
+ description {
+ state: "focused" 0.0;
+ inherit: "default" 0.0;
+ color: 255 255 255 255;
+ }
+ }
+ part {
+ name: "part_divider";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "popup_bg";
+ relative: 0.0 0.80;
+ }
+ rel2 {
+ to: "popup_bg";
+ relative: 1.0 0.80;
+ }
+ min: 0 1;
+ color: 204 204 204 255;
+ visible: 1;
+ }
+ }
+ part {
+ name: "padding.buttons";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ relative: 0.0 0.0;
+ to: "part_divider";
+ }
+ rel2 {
+ relative: 1.0 1.0;
+ to: "popup_bg";
}
align: 0.0 0.0;
}
- }*/
+ }
part {
name: "part_button_1";
type: SWALLOW;
@@ -228,14 +464,10 @@ group {
description {
state: "default" 0.0;
rel1 {
- /*relative: 0.02 1.0;
- to: "padding.buttons.top";*/
to: "padding.buttons";
relative: 0.0 0.0;
}
rel2 {
- /*relative: 0.49 0.0;
- to: "padding.buttons.bottom";*/
to: "padding.buttons";
relative: 0.5 1.0;
}
@@ -250,14 +482,10 @@ group {
description {
state: "default" 0.0;
rel1 {
- /*relative: 0.51 1.0;
- to: "padding.buttons.top";*/
to: "part_button_1";
relative: 1.0 0.0;
}
rel2 {
- /*relative: 0.98 0.0;
- to: "padding.buttons.bottom";*/
to: "padding.buttons";
relative: 1.0 1.0;
}
@@ -266,6 +494,24 @@ group {
}
}
}
+ programs {
+ program {
+ name: "unfocused";
+ signal: "mouse,out";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: part_content_text_bg;
+ target: part_content_text;
+ }
+ program {
+ name: "focused";
+ signal: "mouse,in";
+ source: "elm";
+ action: STATE_SET "focused" 0.0;
+ target: part_content_text_bg;
+ target: part_content_text;
+ }
+ }
}
group {
@@ -373,7 +619,7 @@ group {
}
part {
name: "part_content_swallow";
- type: SWALLOW;
+ type: TEXT;
scale: 1;
description {
state: "default" 0.0;
@@ -387,6 +633,17 @@ group {
to_y: "padding.title.bottom";
relative: 0.0 0.0;
}
+ text {
+ font: FONT_TIZENSANS_LIGHT;
+ text: "Delete?";
+ size: 28;
+ min: 1 1;
+ ellipsis: -1;
+ align: 0.0 0.5;
+ }
+ color: 51 51 51 255;
+ min: 0 28;
+ fixed: 1 1;
visible: 1;
}
}
@@ -464,3 +721,183 @@ group {
}
}
}
+
+group {
+ name: GRP_DIALOG_POPUP_NO_TITLE_ONE_BTN;
+ parts {
+ part {
+ name: "dimmed_bg";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 0 0;
+ color: 0 0 0 100;
+ visible: 1;
+ }
+ }
+ part {
+ name: "popup_bg";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 0 0;
+ color: 255 255 255 255;
+ visible: 1;
+ rel1 {
+ relative: 0.35 0.375;
+ to : "dimmed_bg";
+ }
+ rel2 {
+ relative: 0.65 0.625;
+ to : "dimmed_bg";
+ }
+ }
+ }
+ part {
+ name: "padding.title.left";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ relative: 0.0 0.0;
+ to: "popup_bg";
+ }
+ rel2 {
+ relative: 0.05 1.0;
+ to: "popup_bg";
+ }
+ align: 0.0 0.5;
+ }
+ }
+ part {
+ name: "padding.title.right";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ relative: 0.95 0.0;
+ to: "popup_bg";
+ }
+ rel2 {
+ relative: 1.0 1.0;
+ to: "popup_bg";
+ }
+ align: 0.0 0.0;
+ }
+ }
+ part {
+ name: "padding.title.top";
+ type: SPACER;
+ scale: 1;
+ description {
+ min: 0 34;
+ state: "default" 0.0;
+ rel1 {
+ relative: 0.0 0.0;
+ to: "popup_bg";
+ }
+ rel2 {
+ relative: 1.0 0.0;
+ to: "popup_bg";
+ }
+ align: 0.5 0.0;
+ }
+ }
+ part {
+ name: "padding.title.bottom";
+ type: SPACER;
+ scale: 1;
+ description {
+ min: 0 34;
+ state: "default" 0.0;
+ rel1 {
+ relative: 0.0 0.0;
+ to: "part_divider";
+ }
+ rel2 {
+ relative: 1.0 0.0;
+ to: "part_divider";
+ }
+ align: 0.5 1.0;
+ }
+ }
+ part {
+ name: "part_content_swallow";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to_x: "padding.title.left";
+ to_y: "padding.title.top";
+ relative: 1.0 1.0;
+ }
+ rel2 {
+ to_x: "padding.title.right";
+ to_y: "padding.title.bottom";
+ relative: 0.0 0.0;
+ }
+ visible: 1;
+ }
+ }
+ part {
+ name: "part_divider";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "popup_bg";
+ relative: 0.0 0.80;
+ }
+ rel2 {
+ to: "popup_bg";
+ relative: 1.0 0.80;
+ }
+ min: 0 1;
+ color: 204 204 204 255;
+ visible: 1;
+ }
+ }
+ part {
+ name: "padding.buttons";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ relative: 0.0 0.0;
+ to: "part_divider";
+ }
+ rel2 {
+ relative: 1.0 1.0;
+ to: "popup_bg";
+ }
+ align: 0.0 0.0;
+ }
+ }
+ part {
+ name: "part_button_1";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "padding.buttons";
+ relative: 0.0 0.0;
+ }
+ rel2 {
+ to: "padding.buttons";
+ relative: 1.0 1.0;
+ }
+ visible: 1;
+ align: 0.0 0.0;
+ }
+ }
+ }
+}
+
diff --git a/res/edc/widget/button.edc b/res/edc/widget/button.edc
index 9374fce..3b46fa8 100755
--- a/res/edc/widget/button.edc
+++ b/res/edc/widget/button.edc
@@ -19,13 +19,14 @@
#define COLOR_TEXT_INDEX 77 77 77 255
#define COLOR_TEXT_FOCUS 255 255 255 255
- #include "../../../include/define.h"
+#include "../../../include/define.h"
group {
data.item: "focus_highlight" "on";
name: "elm/button/base/menu_btn";
images {
image: "icon_button_more_rotation.png" COMP;
+ image: "icon_button_more_rotation_default_2.png" COMP;
}
parts {
part {
@@ -38,12 +39,12 @@ group {
color: 0 119 246 255;
fixed: 1 1;
max: 46 46;
- visible: 1;
+ visible: 0;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- visible: 0;
+ visible: 1;
}
}
part {
@@ -52,21 +53,16 @@ group {
scale: 1;
description {
state: "default" 0.0;
- image.normal: "icon_button_more_rotation.png";
+ image.normal: "icon_button_more_rotation_default_2.png";
align: 0.0 0.0;
fixed: 1 1;
visible: 1;
}
- /*description {
- state: "disabled" 0.0;
- inherit: "default" 0.0;
- image.normal: "icon_button_more_rotation.png";
- }
description {
state: "focused" 0.0;
inherit: "default" 0.0;
image.normal: "icon_button_more_rotation.png";
- }*/
+ }
}
part {
name: "event";
@@ -78,21 +74,95 @@ group {
}
}
programs {
- /*program {
- name: "disabled";
- signal: SIGNAL_DISABLED;
+ program {
+ name: "focused";
+ signal: SIGNAL_FOCUSED;
source: SOURCE_ELM;
- action: STATE_SET "disabled" 0.0;
+ action: STATE_SET "focused" 0.0;
target: btn_bg;
- target: part_popup_down_btn;
+ target: part_menu_btn;
}
program {
+ name: "unfocused";
+ signal: SIGNAL_UNFOCUSED;
+ source: SOURCE_ELM;
+ action: STATE_SET "default" 0.0;
+ target: btn_bg;
+ target: part_menu_btn;
+ }
+ program {
+ name: "mouse_unclick_after";
+ signal: "mouse,clicked,1";
+ source: "event";
+ action: SIGNAL_EMIT "elm,action,click" "";
+ }
+ }
+}
+
+group {
+ data.item: "focus_highlight" "on";
+ name: "elm/button/base/menu_btn_text";
+ parts {
+ part {
+ name: "btn_bg";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ align: 0.0 0.0;
+ color: 0 119 246 255;
+ fixed: 1 1;
+ max: 46 46;
+ visible: 0;
+ }
+ description {
+ state: "focused" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ part {
+ name: "part_menu_btn_text";
+ type: TEXT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ text {
+ font: FONT_TIZENSANS_REGULAR;
+ text: "OK";
+ size: 20;
+ min: 1 1;
+ ellipsis: -1;
+ align: 0.5 0.5;
+ }
+ color: 51 51 51 255;
+ max: 46 46;
+ fixed: 1 1;
+ visible: 1;
+ }
+ description {
+ state: "focused" 0.0;
+ inherit: "default" 0.0;
+ color: 255 255 255 255;
+ }
+ }
+ part {
+ name: "event";
+ type: RECT;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ }
+ }
+ }
+ programs {
+ program {
name: "focused";
signal: SIGNAL_FOCUSED;
source: SOURCE_ELM;
action: STATE_SET "focused" 0.0;
target: btn_bg;
- target: part_popup_down_btn;
+ target: part_menu_btn_text;
}
program {
name: "unfocused";
@@ -100,8 +170,8 @@ group {
source: SOURCE_ELM;
action: STATE_SET "default" 0.0;
target: btn_bg;
- target: part_popup_down_btn;
- }*/
+ target: part_menu_btn_text;
+ }
program {
name: "mouse_unclick_after";
signal: "mouse,clicked,1";
diff --git a/res/edc/widget/genlist.edc b/res/edc/widget/genlist.edc
index 71a296d..f2e69f9 100755
--- a/res/edc/widget/genlist.edc
+++ b/res/edc/widget/genlist.edc
@@ -14,24 +14,18 @@
* limitations under the License.
*/
-#define SOURCE_EDC "edc"
-#define SIGNAL_ITEM_SELECTED "item,selected"
#define COLOR_TEXT_TITLE 51 51 51 255
#define COLOR_TEXT_FOCUS 255 255 255 255
-#define COLOR_TEXT_INFO 153 153 153 255
-#define COLOR_ITEM_DEFAULT 119 169 202 255
-#define COLOR_ITEM_FOCUS 0 119 246 255
-#define COLOR_ITEM_FOCUS_0 0 119 246 0
-#define COLOR_ITEM_BG 255 255 255 255
-#define COLOR_ITEM_BORDER 194 194 194 255
-#define FONT_REGULAR "BreezeSans"
+#define COLOR_BG_COLOR 0 119 246 255
+#define COLOR_BORDER_COLOR 204 204 204 255
+#define PADDING_LEFT 40
#include "../../../include/define.h"
group {
name: "elm/genlist/item/custom_folder/default";
data.item: "texts" "elm.text.folder";
- data.item: "contents" "elm.swallow.icon";
+ data.item: "contents" "elm.swallow.icon padding.top.left";
data.item: "focus_highlight" "on";
parts {
@@ -41,7 +35,7 @@ group {
scale: 1;
description {
state: "default" 0.0;
- color: 0 119 246 255;
+ color: COLOR_BG_COLOR;
min: 0 80;
visible: 0;
}
@@ -59,7 +53,7 @@ group {
rel1.relative: 0.0 1.0;
rel2.relative: 1.0 1.0;
align: 0.0 1.0;
- color: 204 204 204 255;
+ color: COLOR_BORDER_COLOR;
min: 0 1;
fixed: 1 1;
visible: 1;
@@ -67,14 +61,14 @@ group {
}
part {
name: "padding.top.left";
- type: SPACER;
+ type: SWALLOW;
scale: 1;
description {
state: "default" 0.0;
- rel2.relative: 0.0 0.0;
- min: 40 20;
- fixed: 1 1;
- align: 0.0 0.0;
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 0.0 1.0;
+ fixed: 1 0;
+ align: 0.0 0.5;
}
}
part {
@@ -97,11 +91,11 @@ group {
state : "default" 0.0;
rel1 {
to: "padding.top.left";
- relative: 1.0 1.0;
+ relative: 1.0 0.3;
}
rel2 {
to: "padding.top.left";
- relative: 1.0 1.0;
+ relative: 1.0 0.3;
}
min: 40 40;
align: 0.0 0.0;
@@ -144,13 +138,13 @@ group {
ellipsis: 1;
}
min: 0 40;
- color: 51 51 51 255;
+ color: COLOR_TEXT_TITLE;
visible: 1;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -211,7 +205,7 @@ group {
scale: 1;
description {
state: "default" 0.0;
- color: 0 119 246 255;
+ color: COLOR_BG_COLOR;
min: 0 80;
visible: 0;
}
@@ -229,7 +223,7 @@ group {
rel1.relative: 0.0 1.0;
rel2.relative: 1.0 1.0;
align: 0.0 1.0;
- color: 204 204 204 255;
+ color: COLOR_BORDER_COLOR;
min: 0 1;
fixed: 1 1;
visible: 1;
@@ -313,7 +307,7 @@ group {
rel1.relative: 1.0 1.0;
rel2.to: "padding.bottom.right";
rel2.relative: 0.0 0.0;
- color: 0 119 246 255;
+ color: COLOR_BG_COLOR;
visible: 0;
}
description {
@@ -339,13 +333,13 @@ group {
ellipsis: 1;
}
min: 0 40;
- color: 51 51 51 255;
+ color: COLOR_TEXT_TITLE;
visible: 1;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -365,13 +359,13 @@ group {
ellipsis: 1;
}
min: 0 24;
- color: 51 51 51 255;
+ color: COLOR_TEXT_TITLE;
visible: 1;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -391,13 +385,13 @@ group {
ellipsis: 1;
}
min: 0 24;
- color: 51 51 51 255;
+ color: COLOR_TEXT_TITLE;
visible: 1;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -470,7 +464,7 @@ group {
scale: 1;
description {
state: "default" 0.0;
- color: 0 119 246 255;
+ color: COLOR_BG_COLOR;
min: 0 80;
visible: 0;
}
@@ -488,7 +482,7 @@ group {
rel1.relative: 0.0 1.0;
rel2.relative: 1.0 1.0;
align: 0.0 1.0;
- color: 204 204 204 255;
+ color: COLOR_BORDER_COLOR;
min: 0 1;
fixed: 1 1;
visible: 1;
@@ -606,7 +600,7 @@ group {
rel1.relative: 1.0 1.0;
rel2.to: "padding.icon.text.right";
rel2.relative: 0.0 1.0;
- color: 0 119 246 255;
+ color: COLOR_BG_COLOR;
visible: 0;
}
description {
@@ -632,13 +626,13 @@ group {
ellipsis: 1;
}
min: 0 40;
- color: 51 51 51 255;
+ color: COLOR_TEXT_TITLE;
visible: 1;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -658,13 +652,13 @@ group {
ellipsis: 1;
}
min: 0 24;
- color: 51 51 51 255;
+ color: COLOR_TEXT_TITLE;
visible: 1;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -684,13 +678,13 @@ group {
ellipsis: 1;
}
min: 0 24;
- color: 51 51 51 255;
+ color: COLOR_TEXT_TITLE;
visible: 1;
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -754,7 +748,7 @@ group {
group {
name: "elm/genlist/item/custom_file_target/default";
data.item: "texts" "elm.text.file";
- data.item: "contents" "elm.swallow.icon elm.swallow.end";
+ data.item: "contents" "elm.swallow.icon elm.swallow.end padding.top.left";
data.item: "focus_highlight" "on";
parts {
@@ -764,7 +758,7 @@ group {
scale: 1;
description {
state: "default" 0.0;
- color: 0 119 246 255;
+ color: COLOR_BG_COLOR;
visible: 0;
min: 0 80;
}
@@ -783,19 +777,18 @@ group {
rel1.relative: 0.0 1.0;
rel2.relative: 1.0 1.0;
align: 0.0 1.0;
- color: 204 204 204 255;
+ color: COLOR_BORDER_COLOR;
min: 0 1;
visible: 1;
}
}
part {
name: "padding.top.left";
- type: SPACER;
+ type: SWALLOW;
scale: 1;
description {
state: "default" 0.0;
rel2.relative: 0.0 0.0;
- min: 40 20;
fixed: 1 1;
align: 0.0 0.0;
}
@@ -879,7 +872,7 @@ group {
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
@@ -972,7 +965,7 @@ group {
scale: 1;
description {
state: "default" 0.0;
- color: 0 119 246 255;
+ color: COLOR_BG_COLOR;
visible: 0;
}
description {
@@ -989,7 +982,7 @@ group {
rel1.relative: 0.0 1.0;
rel2.relative: 1.0 1.0;
align: 0.0 1.0;
- color: 204 204 204 255;
+ color: COLOR_BORDER_COLOR;
min: 0 3;
fixed: 1 1;
visible: 1;
@@ -1041,7 +1034,7 @@ group {
description {
state: "focused" 0.0;
inherit: "default" 0.0;
- color: 255 255 255 255;
+ color: COLOR_TEXT_FOCUS;
}
}
part {
diff --git a/res/images/gengrid/00_check_activate.png b/res/images/gengrid/00_check_activate.png
deleted file mode 100755
index ca4c15e..0000000
--- a/res/images/gengrid/00_check_activate.png
+++ /dev/null
Binary files differ
diff --git a/res/images/gengrid/00_check_bg.png b/res/images/gengrid/00_check_bg.png
deleted file mode 100755
index 3b901ab..0000000
--- a/res/images/gengrid/00_check_bg.png
+++ /dev/null
Binary files differ
diff --git a/res/images/gengrid/00_check_bg_ef.png b/res/images/gengrid/00_check_bg_ef.png
deleted file mode 100755
index cb49cdd..0000000
--- a/res/images/gengrid/00_check_bg_ef.png
+++ /dev/null
Binary files differ
diff --git a/res/images/gengrid/00_check_bg_line.png b/res/images/gengrid/00_check_bg_line.png
deleted file mode 100755
index 6cf7c07..0000000
--- a/res/images/gengrid/00_check_bg_line.png
+++ /dev/null
Binary files differ
diff --git a/res/images/gengrid/00_check_focus.png b/res/images/gengrid/00_check_focus.png
deleted file mode 100755
index 7f51d0f..0000000
--- a/res/images/gengrid/00_check_focus.png
+++ /dev/null
Binary files differ
diff --git a/res/images/gengrid/00_focus_01.#.png b/res/images/gengrid/00_focus_01.#.png
deleted file mode 100755
index e9a1206..0000000
--- a/res/images/gengrid/00_focus_01.#.png
+++ /dev/null
Binary files differ
diff --git a/res/images/gengrid/my_files_sd_card.png b/res/images/gengrid/my_files_sd_card.png
deleted file mode 100755
index 470b6fe..0000000
--- a/res/images/gengrid/my_files_sd_card.png
+++ /dev/null
Binary files differ
diff --git a/res/images/gengrid/myfile_icon_video_play.png b/res/images/gengrid/myfile_icon_video_play.png
deleted file mode 100755
index f9ecb0b..0000000
--- a/res/images/gengrid/myfile_icon_video_play.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_button_more.png b/res/images/icon_button_more.png
deleted file mode 100755
index 30730ac..0000000
--- a/res/images/icon_button_more.png
+++ /dev/null
Binary files differ
diff --git a/res/images/icon_button_more_rotation_default_2.png b/res/images/icon_button_more_rotation_default_2.png
new file mode 100755
index 0000000..98de26e
--- /dev/null
+++ b/res/images/icon_button_more_rotation_default_2.png
Binary files differ
diff --git a/src/layout/default.c b/src/layout/default.c
index ced9951..7992306 100755
--- a/src/layout/default.c
+++ b/src/layout/default.c
@@ -15,10 +15,9 @@
*/
#include <Elementary.h>
-#include <media_content.h>
#include <app_debug.h>
#include <app_contents.h>
-#include <inputmgr.h>
+#include <app_preference.h>
#include <layoutmgr.h>
#include <viewmgr.h>
#include <storage.h>
@@ -28,79 +27,64 @@
#include "view.h"
#include "data.h"
#include "util/utils.h"
-#include "util/dialog_popup.h"
-#include "util/fs-util.h"
+#include "util/fs-oper.h"
#include "util/fs-error.h"
#include "util/file-util.h"
+#include "view/dialog_popup.h"
-static char* _folder_list_label_get(void *data, Evas_Object *obj, const char *part);
-static Evas_Object* _folder_list_content_get(void *data, Evas_Object *obj, const char *part);
-static void _folder_list_del(void *data, Evas_Object *obj);
+typedef enum _file_list_type file_list_type;
+enum _file_list_type {
+ FILE_SELECT_MODE = 0,
+ FILE_OPERATE_MODE = 1,
+ FILE_ROOT_MODE,
+};
+
+#define DEFAULT_PAD 40
-static bool _draw_file_list(struct _priv *priv, int flag);
-static bool _draw_file_list_item_selected(struct _priv *priv, Eina_List *child);
-static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info);
+static char* _list_label_get(void *data, Evas_Object *obj, const char *part);
+static Evas_Object* _list_content_get(void *data, Evas_Object *obj, const char *part);
+static void _list_del(void *data, Evas_Object *obj);
-static void _set_folder_item_data(item_data_s *id, fsNodeInfo *node)
+static bool _draw_file_list(struct _priv *priv, int mode);
+static void _folder_item_selected_cb(void *data, Evas_Object *obj, void *event_info);
+
+static void _set_folder_item_data(item_data_s *id, fsNodeInfo *node, struct _priv *priv)
{
char *new_path = NULL;
char *temp_size = NULL;
- int buffer_size;
-
- if (node == NULL || node->path == NULL || node->name == NULL) {
- if (node->path == NULL) {
- _ERR("node->path is null.");
- id->parent_path = NULL;
- }
- else
- id->parent_path = strdup(node->path);
-
- if (node->name == NULL) {
- _ERR("node->name is null.");
- id->name = NULL;
- }
- else
- id->name = strdup(node->name);
-
- if (node == NULL) {
- _ERR("node is null.");
- id->node = NULL;
- }
- else
- id->node = node;
- id->file_size = NULL;
+ if (node == NULL)
return;
- }
- buffer_size = strlen(node->path) + strlen("/") + strlen(node->name);
- new_path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(new_path, buffer_size+1, "%s/%s", node->path, node->name);
+ id->node = node;
- id->child = mf_file_ls(new_path);
- SAFE_FREE_CHAR(new_path);
+ if (node->path != NULL)
+ id->parent_path = strdup(node->path);
+ if (node->name != NULL)
+ id->name = strdup(node->name);
- /* Below items should be duplicated by strdup */
- id->parent_path = strdup(node->path);
- id->name = strdup(node->name);
- id->node = node;
+ new_path = utils_get_combined_string(node->path, node->name, NULL);
+
+ if (new_path == NULL)
+ id->child = NULL;
+ else {
+ id->child = mf_file_ls(new_path, priv);
+ SAFE_FREE_CHAR(new_path);
+ }
mf_file_attr_get_file_size_info(&temp_size, node->size);
if (temp_size == NULL) {
_ERR("file size is null.");
- id->file_size = NULL;
- SAFE_FREE_CHAR(node->path);
- SAFE_FREE_CHAR(node->name);
-
- return;
+ goto out;
}
id->file_size = strdup(temp_size);
+ SAFE_FREE_CHAR(temp_size);
+out:
SAFE_FREE_CHAR(node->path);
SAFE_FREE_CHAR(node->name);
- SAFE_FREE_CHAR(temp_size);
return;
}
@@ -149,22 +133,33 @@ static Evas_Object* create_check(Evas_Object *parent, void *data)
return check;
}
-static char* _get_list_data_get(Eina_List *list, int index)
+static char * _get_file_time(char *path, char *name)
{
- char *data = NULL;
- Eina_List *list_local = NULL;
+ char *time = NULL;
- list_local = eina_list_nth_list(list, index);
+ if (path == NULL || name == NULL) {
+ _ERR("path or name is null. failed get file type.");
+ return time;
+ }
- if (list_local == NULL) {
- _ERR("list is null. failed get list data");
- mf_util_free_eina_list_with_data(&list_local, MYFILE_TYPE_CHAR);
- return NULL;
+ char *file_path = NULL;
+ file_path = utils_get_combined_string(path, name, NULL);
+
+ if (file_path == NULL) {
+ _ERR("file_path is null. failed to get_file_time");
+ return time;
}
- data = (char *)eina_list_data_get(list_local);
+ time = mf_file_attr_get_file_mdate_time(file_path);
- return data;
+ if (time == NULL) {
+ _ERR("failed get file date");
+ SAFE_FREE_CHAR(file_path);
+ return time;
+ }
+
+ SAFE_FREE_CHAR(file_path);
+ return time;
}
static fsFileType _get_file_type(char *path, char *name)
@@ -177,19 +172,20 @@ static fsFileType _get_file_type(char *path, char *name)
}
char *file_path = NULL;
- int buffer_size = 0;
-
- buffer_size = strlen(path)+strlen("/")+strlen(name);
- file_path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(file_path, buffer_size+1, "%s/%s", path, name);
+ file_path = utils_get_combined_string(path, name, NULL);
- if (mf_file_attr_is_dir(file_path)) {
- fType = FILE_TYPE_DIR;
- free(file_path);
+ if (file_path == NULL) {
+ _ERR("file_path is null. failed to _get_file_type");
return fType;
- }
+ } else {
+ if (mf_file_attr_is_dir(file_path)) {
+ fType = FILE_TYPE_DIR;
+ free(file_path);
+ return fType;
+ }
- fType = mf_file_attr_get_file_type_by_mime(file_path);
+ fType = mf_file_attr_get_file_type_by_mime(file_path);
+ }
SAFE_FREE_CHAR(file_path);
return fType;
@@ -202,22 +198,143 @@ static char* _get_file_size(char *path, char *file_name)
return NULL;
}
- int buffer_size, file_size;
+ int file_size;
char *file_path = NULL, *size = NULL;
- buffer_size = strlen(path)+strlen("/")+strlen(file_name);
- file_path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(file_path, buffer_size+1, "%s/%s", path, file_name);
+ file_path = utils_get_combined_string(path, file_name, NULL);
- file_size = mf_file_size(file_path);
- mf_file_attr_get_file_size_info(&size, file_size);
+ if (file_path == NULL) {
+ _ERR("file_path is null. failed to get_file_size");
+ return size;
+ } else {
+ file_size = mf_file_size(file_path);
+ mf_file_attr_get_file_size_info(&size, file_size);
+ }
SAFE_FREE_CHAR(file_path);
return size;
}
-static void _focus_set(struct _priv *priv, int flag)
+static char* _get_icon_full_path(const char* imgdir, const char* icon_path)
+{
+ char *full_path = NULL;
+
+ if (imgdir == NULL) {
+ _ERR("imgdir is null. failed get icon full path");
+ return full_path;
+ }
+
+ if (icon_path == NULL) {
+ _ERR("icon_path is null. failed get icon full path");
+ return full_path;
+ }
+
+ full_path = utils_get_combined_string(imgdir, icon_path, NULL);
+
+ return full_path;
+}
+
+static char* _list_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (data == NULL) {
+ _ERR("data is null. Failed to get label text");
+ return NULL;
+ }
+
+ char buf[256];
+ item_data_s *id = (item_data_s *)data;
+
+ if (id == NULL)
+ return NULL;
+
+ if (!strcmp("elm.text.folder", part)) {
+ if (id->name == NULL)
+ return NULL;
+ else
+ snprintf(buf, sizeof(buf), "%s", id->name);
+
+ return strdup(buf);
+ } else if (!strcmp("elm.text1", part)) {
+ if (id->name != NULL)
+ snprintf(buf, sizeof(buf), "%s", id->name);
+ else
+ return NULL;
+
+ return strdup(buf);
+ } else if (!strcmp("elm.text2", part)) {
+ if (id->file_size == NULL)
+ return NULL;
+ else
+ snprintf(buf, sizeof(buf), "%s", id->file_size);
+
+ return strdup(buf);
+ } else if (!strcmp("elm.text3", part)) {
+ if (id->time == NULL)
+ return NULL;
+ else
+ snprintf(buf, sizeof(buf), "%s", id->time);
+
+ return strdup(buf);
+ }
+
+ return NULL;
+}
+
+static Evas_Object*
+_list_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (data == NULL) {
+ _ERR("data is null. failed get content");
+ return NULL;
+ }
+
+ item_data_s *id = (item_data_s *)data;
+
+ if (!strcmp("elm.swallow.icon", part)) {
+ Evas_Object *icon = elm_image_add(obj);
+
+ const char *icon_path = mf_file_attr_get_default_icon_by_type(id->type);
+ char *full_path = _get_icon_full_path(IMGDIR, icon_path);
+
+ elm_image_file_set(icon, full_path, NULL);
+
+ SAFE_FREE_CHAR(full_path);
+ return icon;
+ } else if (!strcmp("padding.top.left", part)) {
+ Evas_Object *padding = evas_object_rectangle_add(evas_object_evas_get(obj));
+ evas_object_move(padding, 0, 0);
+
+ int minw;
+
+ if (id->level > 1) {
+ minw = DEFAULT_PAD + (20 * (id->level - 1));
+ evas_object_size_hint_min_set(padding, minw, 20);
+ evas_object_resize(padding, minw, 20);
+ } else {
+ evas_object_size_hint_min_set(padding, DEFAULT_PAD, 20);
+ evas_object_resize(padding, DEFAULT_PAD, 20);
+ }
+
+ evas_object_color_set(padding, 255, 255, 255, 0);
+ evas_object_show(padding);
+
+ return padding;
+ } else if (!strcmp("elm.swallow.end", part))
+ return create_check(obj, data);
+
+ return NULL;
+}
+
+static void
+_list_del(void *data, Evas_Object *obj)
+{
+ item_data_s *id = (item_data_s *)data;
+ util_free_item_data_s(id);
+ free(id);
+}
+
+static void _focus_set(struct _priv *priv, int mode)
{
if (priv == NULL) {
_ERR("priv is null. failed set focus");
@@ -230,13 +347,13 @@ static void _focus_set(struct _priv *priv, int flag)
file = elm_object_part_content_get(priv->layout, PART_FILE_LIST);
path = elm_object_part_content_get(priv->base, PART_FILE_PATH);
- if (flag == 1) {
+ if (mode == FILE_OPERATE_MODE) {
elm_object_focus_next_object_set(path, folder, ELM_FOCUS_DOWN);
elm_object_focus_next_object_set(folder, path, ELM_FOCUS_UP);
elm_object_focus_next_object_set(file, path, ELM_FOCUS_UP);
elm_object_focus_next_object_set(folder, file, ELM_FOCUS_RIGHT);
elm_object_focus_next_object_set(file, folder, ELM_FOCUS_LEFT);
- } else if (flag == 2) {
+ } else {
elm_object_focus_next_object_set(path, file, ELM_FOCUS_DOWN);
elm_object_focus_next_object_set(file, path, ELM_FOCUS_UP);
elm_object_focus_next_object_set(folder, file, ELM_FOCUS_RIGHT);
@@ -246,125 +363,179 @@ static void _focus_set(struct _priv *priv, int flag)
return;
}
-static void _check_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+static void _file_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
{
- int flag = (int)data;
- _DBG("rimikim, check_item_selected_cb, flag : %d", flag);
-
- if(flag != 2) {
+ if (event_info == NULL || data == NULL || obj == NULL) {
+ _ERR("parameters are null. failed to _file_item_selected_cb");
return;
}
- Evas_Object *check = NULL;
+ item_data_s *id = (item_data_s*)elm_object_item_data_get((Elm_Object_Item *)event_info);
- if (event_info == NULL) {
- _ERR("event_info is null");
+ if (id == NULL) {
+ _ERR("selected_item is null");
return;
}
- check = elm_object_item_part_content_get(event_info, "elm.swallow.end");
+ if (id->flag == FILE_OPERATE_MODE) {
+ char full_path[PATH_MAX] = { 0, };
- if (check == NULL) {
- _ERR("check box is null. Failed item_selected_cb");
- return;
- }
+ if (id->selected_item_fullpath == NULL || id->name == NULL) {
+ _ERR("path or name is null");
+ return;
+ }
+
+ snprintf(full_path, PATH_MAX, "%s/%s", id->selected_item_fullpath, id->name);
+ mf_launch_service(data, full_path);
+ } else {
+ Evas_Object *check = NULL;
+ Eina_List *total_list = NULL, *l = NULL;
+ Elm_Object_Item *selected_item = NULL, *item = NULL;
+
+ item = (Elm_Object_Item *)event_info;
+ total_list = elm_genlist_realized_items_get(obj);
+
+ EINA_LIST_FOREACH(total_list, l, selected_item) {
+ check = elm_object_item_part_content_get(selected_item, "elm.swallow.end");
+
+ if (check == NULL) {
+ _ERR("check box is null. Failed item_selected_cb");
+ return;
+ }
+
+ elm_check_state_set(check, EINA_FALSE);
+ }
+
+ elm_genlist_item_selected_set(item, EINA_TRUE);
+ check = elm_object_item_part_content_get(item, "elm.swallow.end");
+
+ if (check == NULL) {
+ _ERR("check box is null. Failed item_selected_cb");
+ return;
+ }
- if (elm_check_state_get(check))
- elm_check_state_set(check, EINA_FALSE);
- else
elm_check_state_set(check, EINA_TRUE);
+ }
return;
}
-static bool _draw_child_folder_list(Evas_Object *obj, item_data_s *id, struct _priv *priv)
+static bool _draw_folder_list(struct _priv *priv, Evas_Object *obj, int is_child)
{
- if (id == NULL) {
- _ERR("id is null. failed draw child folder list");
+ if (priv == NULL) {
+ _ERR("priv is null. failed draw folder list");
return false;
}
- Elm_Object_Item *parent = id->item;
- Elm_Object_Item *it = NULL;
+ Elm_Object_Item *parent = NULL;
- int i = 0, buffer_size, ret, count, level;
- char *new_path = NULL, *new_path2 = NULL, *data = NULL;
+ if (is_child) {
+ if (priv->item == NULL || obj == NULL) {
+ _ERR("parameters are wrong. failed draw child folder list");
+ return false;
+ }
+
+ parent = (Elm_Object_Item *)priv->item;
+ }
+
+ Evas_Object *genlist = NULL;
+ Elm_Object_Item *it = NULL;
+ item_data_s *id = NULL;
+ list_data_s *list_data = calloc(1, sizeof(list_data_s));
- item_data_s *id_local;
fsNodeInfo *node;
- count = eina_list_count(id->child);
+ int i = 0, ret, level;
+ char *new_path = NULL, *path = NULL;
+
+ if (!is_child) {
+ genlist = elm_genlist_add(priv->layout);
+ elm_object_focus_allow_set(genlist, EINA_TRUE);
+ }
Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
itc->item_style = "custom_folder";
- itc->func.text_get = _folder_list_label_get;
- itc->func.content_get = _folder_list_content_get;
- itc->func.del = _folder_list_del;
+ itc->func.text_get = _list_label_get;
+ itc->func.content_get = _list_content_get;
+ itc->func.del = _list_del;
- if (id->parent_path == NULL || id->name == NULL) {
- _ERR("parent_path or name is null. failed _draw_child_folder_list");
- return false;
+ if (!is_child)
+ path = Get_Root_Path(STORAGE_TYPE_INTERNAL);
+ else
+ path = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
+
+ if (path == NULL) {
+ _ERR("path is null. failed to get path to draw child folder list");
+ goto out;
}
- for (i = 0; i < count; i++) {
- Eina_List *temp_folder = NULL, *temp_file = NULL;
- data = _get_list_data_get(id->child, i);
+ ret = mf_fs_oper_read_dir(path, &list_data->folder_list, &list_data->file_list);
+ if (ret != MYFILE_ERR_NONE) {
+ _ERR("failed read dir. ret : %d", ret);
+ SAFE_FREE_CHAR(path);
+ mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
+ mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
+ goto out;
+ }
- if (data == NULL) {
- _ERR("data is null.");
- continue;
- }
+ list_data->file_count = eina_list_count(list_data->file_list);
+ list_data->folder_count = eina_list_count(list_data->folder_list);
- buffer_size = strlen(id->parent_path)+strlen("/")+strlen(id->name)+strlen("/")+strlen(data);
- new_path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(new_path, buffer_size+1, "%s/%s/%s", id->parent_path, id->name, data);
+ for (i = 0; i < list_data->folder_count; i++) {
+ id = calloc(1, sizeof(item_data_s));
+
+ id->index = i;
+ id->expanded = 0;
+
+ node = (fsNodeInfo *)eina_list_nth(list_data->folder_list, i);
+ _set_folder_item_data(id, node, priv);
- buffer_size = strlen(id->parent_path)+strlen("/")+strlen(id->name);
- new_path2 = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(new_path2, buffer_size+1, "%s/%s", id->parent_path, id->name);
+ if (!is_child) {
+ id->level = 1;
+ id->type = _get_file_type(id->parent_path, id->name);
- if (mf_is_dir(new_path)) {
+ it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _folder_item_selected_cb, priv);
+ } else {
+ new_path = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, id->name);
mf_file_attr_get_path_level(new_path, &level);
- id_local = calloc(1, sizeof(item_data_s));
- id_local->index = i;
-
- id_local->name = strdup(data);
- id_local->base = id->base;
- id_local->layout = id->layout;
- id_local->level = level;
-
- ret = mf_fs_oper_read_dir(new_path2, &temp_folder, &temp_file);
- if (ret != MYFILE_ERR_NONE) {
- _ERR("failed read dir. ret : %d", ret);
- SAFE_FREE_CHAR(new_path);
- SAFE_FREE_CHAR(new_path2);
- mf_util_free_eina_list_with_data(&temp_folder, MYFILE_TYPE_FSNODE);
- mf_util_free_eina_list_with_data(&temp_file, MYFILE_TYPE_FSNODE);
- free(id_local);
- id_local = NULL;
-
- continue;
- }
- node = (fsNodeInfo *)eina_list_nth(temp_folder, i);
- _set_folder_item_data(id_local, node);
+ id->level = level;
+ id->type = _get_file_type(path, id->name);
- /* TODO: creating and passing the private data (not id_local) as user data */
- /* TODO: Created private data should be handled during the gen_list item's life cycle */
- it = elm_genlist_item_insert_after(obj, itc, id_local, parent, parent, ELM_GENLIST_ITEM_NONE, _item_selected_cb, priv);
- id_local->item = it;
- elm_object_item_data_set(it, id_local);
+ it = elm_genlist_item_insert_after(obj, itc, id, parent, parent, ELM_GENLIST_ITEM_NONE, _folder_item_selected_cb, priv);
}
+ id->item = it;
+ elm_object_item_data_set(it, id);
}
elm_genlist_item_class_free(itc);
+ if (!is_child) {
+ elm_object_part_content_set(priv->layout, PART_FOLDER_LIST, genlist);
+ evas_object_show(genlist);
+
+ evas_object_smart_callback_add(genlist, "item,focused", _item_focus_cb, "item,focused");
+ evas_object_smart_callback_add(genlist, "item,unfocused", _item_focus_cb, "item,unfocused");
+ }
+
SAFE_FREE_CHAR(new_path);
- SAFE_FREE_CHAR(new_path2);
+ SAFE_FREE_CHAR(path);
+ mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
+ mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
+ free(list_data);
+ list_data = NULL;
+
return true;
+
+out:
+ free(list_data);
+ list_data = NULL;
+ elm_genlist_item_class_free(itc);
+
+ return false;
}
-static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+static void _folder_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
{
struct _priv *priv;
@@ -379,27 +550,27 @@ static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info)
}
priv = (struct _priv *)data;
- item_data_s *selected_item = (item_data_s *)elm_object_item_data_get(event_info);
+ item_data_s *selected_item_id = (item_data_s *)elm_object_item_data_get(event_info);
path_item_data_s *pid;
- int buffer_size, same = 0, level, flag = 0;
+ int level, same = 0, diff = 0, flag = 0;
char *new_path = NULL;
- if (selected_item == NULL) {
- _ERR("selected_item info is null.");
+ if (selected_item_id == NULL) {
+ _ERR("selected_item_id info is null.");
return;
}
- if (selected_item->expanded == 1) {
- selected_item->expanded = 0;
+ if (selected_item_id->expanded == 1) {
+ selected_item_id->expanded = 0;
elm_genlist_item_subitems_clear(event_info);
- elm_object_item_data_set(event_info, selected_item);
+ elm_object_item_data_set(event_info, selected_item_id);
flag = 1;
}
- Evas_Object *path_object = elm_object_part_content_get(selected_item->base, PART_FILE_PATH);
+ Evas_Object *path_object = elm_object_part_content_get(priv->base, PART_FILE_PATH);
if (path_object == NULL) {
_ERR("path_object is null.");
@@ -413,513 +584,193 @@ static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info)
return;
}
- selected_item->last_path = elm_object_item_part_text_get(gengrid, "elm.text");
+ const char* last_path = elm_object_item_part_text_get(gengrid, "elm.text");
- if (selected_item->last_path == NULL) {
+ if (last_path == NULL) {
_ERR("last_path is null.");
return;
}
- Elm_Object_Item *gengrid_item = elm_gengrid_last_item_get(path_object);
-
- if (gengrid_item == NULL) {
- _ERR("gengrid_item is null.");
- return;
- }
-
- pid = (path_item_data_s*)elm_object_item_data_get(gengrid_item);
+ pid = (path_item_data_s*)elm_object_item_data_get(gengrid);
if (pid == NULL) {
_ERR("pid is null.");
return;
}
- if (selected_item->parent_path == NULL || selected_item->name == NULL) {
+ if (selected_item_id->parent_path == NULL || selected_item_id->name == NULL) {
_ERR("parent_path or name is null.");
return;
}
- buffer_size = strlen(selected_item->parent_path)+strlen("/")+strlen(selected_item->name);
- new_path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(new_path, buffer_size+1, "%s/%s", selected_item->parent_path, selected_item->name);
+ new_path = utils_get_combined_string(selected_item_id->parent_path, selected_item_id->name, NULL);
- selected_item->child = mf_file_ls(new_path);
+ if (new_path == NULL) {
+ _ERR("new_path is null. failed to get selected_item_id->child");
+ selected_item_id->child = NULL;
+ } else
+ selected_item_id->child = mf_file_ls(new_path, priv);
- if (strcmp(selected_item->last_path, "Home")) {
+ if (strcmp(last_path, "Home")) {
mf_file_attr_get_path_level(new_path, &level);
if (pid->level == level)
same = 1;
else if (pid->level < level)
same = 0;
- else
- same = level - pid->level;
- }
-
- if (!flag) {
- if (selected_item->child != NULL && eina_list_count(selected_item->child)) {
- if (!_draw_child_folder_list(obj, selected_item, priv)) {
- _ERR("_draw_child_folder_list failed.");
- goto out;
- }
- selected_item->expanded = 1;
+ else {
+ same = 0;
+ diff = pid->level - level;
}
}
- priv->selected_parent_path = selected_item->parent_path;
- priv->selected_folder = selected_item->name;
+ priv->selected_parent_path = selected_item_id->parent_path;
+ priv->selected_folder = selected_item_id->name;
priv->same = same;
- priv->expanded = selected_item->expanded;
+ priv->diff = diff;
priv->list_index = elm_genlist_item_index_get(event_info);
+ priv->item = (Elm_Object_Item *)event_info;
- viewmgr_update_view(VIEW_BASE, UPDATE_PATH, priv);
-
- if (!_draw_file_list_item_selected(priv, selected_item->child)) {
- _ERR("_draw_file_list_item_selected failed.");
- goto out;
- }
-
-out:
- SAFE_FREE_CHAR(new_path);
- return;
-}
-
-static char*
-_file_list_label_get(void *data, Evas_Object *obj, const char *part)
-{
- if (data == NULL) {
- _ERR("data is null. Failed to get label");
- return NULL;
- }
-
- char buf[256];
- item_data_s *id = (item_data_s *)data;
-
- if (id == NULL)
- return NULL;
-
- if (!strcmp("elm.text1", part)) {
- if (id->is_empty) {
- if (id->index == 0)
- snprintf(buf, sizeof(buf), "%s", ".");
- else if (id->index == 1)
- snprintf(buf, sizeof(buf), "%s", "..");
- } else {
- if (id->name != NULL)
- snprintf(buf, sizeof(buf), "%s", id->name);
- else
- return NULL;
- }
- return strdup(buf);
- } else if (!strcmp("elm.text2", part)) {
- if (id->file_size == NULL)
- return NULL;
- else
- snprintf(buf, sizeof(buf), "%s", id->file_size);
-
- return strdup(buf);
- } else if (!strcmp("elm.text3", part)) {
- snprintf(buf, sizeof(buf), "2016/04/12");
- return strdup(buf);
- }
-
- return NULL;
-}
-
-
-static char*
-_folder_list_label_get(void *data, Evas_Object *obj, const char *part)
-{
- if (data == NULL) {
- _ERR("data is null. Failed to get label text");
- return NULL;
- }
+ if (!flag) {
+ if (selected_item_id->child != NULL && eina_list_count(selected_item_id->child)) {
+ Elm_Object_Item *parent = elm_genlist_item_parent_get(event_info);
+ int parent_index = elm_genlist_item_index_get(parent);
- char buf[256];
- item_data_s *id = (item_data_s *)data;
- Eina_List *list;
+ if (parent_index < 0) {
+ if (priv->expanded_item_index > 0) {
+ Elm_Object_Item *expanded_item = elm_genlist_nth_item_get(obj, priv->expanded_item_index-1);
- if (id == NULL)
- return NULL;
+ elm_genlist_item_subitems_clear(expanded_item);
+ item_data_s *ids = (item_data_s *)elm_object_item_data_get(expanded_item);
+ ids->expanded = 0;
- if (!strcmp("elm.text.folder", part)) {
- if (id->name == NULL)
- return NULL;
- else
- snprintf(buf, sizeof(buf), "%s", id->name);
+ elm_object_item_data_set(expanded_item, ids);
+ }
- return strdup(buf);
- } else if (!strcmp("elm.text1", part)) {
- if (eina_list_count(id->child) == 0 || id->is_home == 1) {
- if (id->index == 0)
- snprintf(buf, sizeof(buf), "%s", ".");
- else if (id->index == 1)
- snprintf(buf, sizeof(buf), "%s", "..");
- } else {
- list = eina_list_nth_list(id->child, id->index);
- char *data = (char *)eina_list_data_get(list);
+ priv->expanded_item_index = elm_genlist_item_index_get(event_info);
+ }
- if (data == NULL)
- return NULL;
- else
- snprintf(buf, sizeof(buf), "%s", data);
+ selected_item_id->expanded = 1;
+ if (!_draw_folder_list(priv, obj, 1)) {
+ _ERR("_draw_folder_list failed.");
+ goto out;
+ }
}
- return strdup(buf);
- } else if (!strcmp("elm.text2", part)) {
- if (id->file_size == NULL)
- return NULL;
- else
- snprintf(buf, sizeof(buf), "%s", id->file_size);
-
- return strdup(buf);
- } else if (!strcmp("elm.text3", part)) {
- snprintf(buf, sizeof(buf), "2016/04/12");
- return strdup(buf);
}
- return NULL;
-}
+ viewmgr_update_view(VIEW_BASE, UPDATE_PATH, priv);
-static Evas_Object*
-_folder_list_content_get(void *data, Evas_Object *obj, const char *part)
-{
- if (data == NULL) {
- _ERR("data is null. failed get content");
- return NULL;
+ if (!_draw_file_list(priv, FILE_OPERATE_MODE)) {
+ _ERR("_draw_file_list failed.");
+ goto out;
}
- item_data_s *id = (item_data_s *)data;
-
- if (!strcmp("elm.swallow.icon", part)) {
- Evas_Object *icon = elm_image_add(obj);
-
- if (id->type == FILE_TYPE_IMAGE)
- elm_image_file_set(icon, IMGDIR"/icon/myfile_icon_images.png", NULL);
- else
- elm_image_file_set(icon, IMGDIR"/icon/myfile_icon_folder.png", NULL);
-
- return icon;
- } else if (!strcmp("elm.swallow.end", part))
- return create_check(obj, data);
-
- return NULL;
-}
-
-static void
-_folder_list_del(void *data, Evas_Object *obj)
-{
-/* Unrealized callback can be called after this.
- * Accessing item_data_s can be dangerous on unrealized callback.
-*/
- item_data_s *id = (item_data_s *)data;
- util_free_item_data_s(id);
- free(id);
+out:
+ SAFE_FREE_CHAR(new_path);
+ return;
}
-static bool _draw_folder_list(struct _priv *priv)
+static bool _draw_file_list(struct _priv *priv, int mode)
{
if (priv == NULL) {
- _ERR("priv is null. failed draw folder list");
- return false;
- }
-
- Evas_Object *genlist = NULL;
-
- Elm_Object_Item *it = NULL;
- item_data_s *id;
- list_data_s *list_data = calloc(1, sizeof(list_data_s));
-
- fsNodeInfo *node = NULL;
-
- char *path = NULL;
-
- genlist = elm_genlist_add(priv->layout);
- elm_object_focus_allow_set(genlist, EINA_TRUE);
-
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- itc->item_style = "custom_folder";
- itc->func.text_get = _folder_list_label_get;
- itc->func.content_get = _folder_list_content_get;
- itc->func.del = _folder_list_del;
-
- path = Get_Root_Path(STORAGE_TYPE_INTERNAL);
- if (path == NULL) {
- _ERR("path is null. Failed to get root path.");
- free(list_data);
- list_data = NULL;
- elm_genlist_item_class_free(itc);
- return false;
- } else
- list_data->path = path;
-
- int ret = mf_fs_oper_read_dir(list_data->path, &list_data->folder_list, &list_data->file_list);
- if (ret != MYFILE_ERR_NONE) {
- _ERR("failed read dir. ret : %d", ret);
- SAFE_FREE_CHAR(path);
-
- mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
- mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
- free(list_data);
- list_data = NULL;
- elm_genlist_item_class_free(itc);
+ _ERR("id is null. failed _draw_file_list.");
return false;
}
- list_data->file_count = eina_list_count(list_data->file_list);
- list_data->folder_count = eina_list_count(list_data->folder_list);
-
- int i;
+ if (mode == FILE_ROOT_MODE) {
+ elm_object_part_text_set(priv->layout, PART_FILE_LIST_NO_CONTENT, "");
+ elm_object_part_text_set(priv->layout, PART_FILE_LIST_HOME, "Home directory");
- for (i = 0; i < list_data->folder_count; i++) {
- id = calloc(1, sizeof(item_data_s));
- id->index = i;
-
- id->base = priv->base;
- id->layout = priv->layout;
- id->expanded = 0;
- id->level = 1;
-
- node = (fsNodeInfo *)eina_list_nth(list_data->folder_list, i);
- _set_folder_item_data(id, node);
-
- it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _item_selected_cb, priv);
- id->item = it;
- elm_object_item_data_set(it, id);
- }
-
- elm_genlist_item_class_free(itc);
-
- elm_object_part_content_set(priv->layout, PART_FOLDER_LIST, genlist);
-
- evas_object_show(genlist);
-
- evas_object_smart_callback_add(genlist, "item,focused", _item_focus_cb, "item,focused");
- evas_object_smart_callback_add(genlist, "item,unfocused", _item_focus_cb, "item,unfocused");
-
- /* file list and folder list should be freed here */
- mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
- mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
- free(list_data);
- list_data = NULL;
- SAFE_FREE_CHAR(path);
-
- return true;
-}
-
-static bool _draw_file_list_item_selected(struct _priv *priv, Eina_List *child)
-{
- if (priv == NULL) {
- _ERR("id is null. failed _draw_file_list_item_selected.");
- return false;
+ return true;
}
Evas_Object *genlist = NULL;
+ elm_object_part_text_set(priv->layout, PART_FILE_LIST_HOME, "");
+ elm_object_part_text_set(priv->layout, PART_FILE_LIST_NO_CONTENT, "");
char *path = NULL;
+ int i, is_home = 0, total_count = 0;
- if (priv->selected_parent_path == NULL || priv->selected_folder == NULL) {
- _ERR("priv->selected_parent_path or priv->selected_folder is null. failed _draw_file_list_item_selected.");
- return false;
- }
+ if (mode == FILE_OPERATE_MODE) {
+ if (priv->selected_folder == NULL || !strcmp(priv->selected_folder, "Home")) {
+ is_home = 1;
- int buffer_size = strlen(priv->selected_parent_path)+strlen("/")+strlen(priv->selected_folder);
- path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(path, buffer_size+1, "%s/%s", priv->selected_parent_path, priv->selected_folder);
-
- genlist = elm_genlist_add(priv->layout);
- elm_object_focus_allow_set(genlist, EINA_TRUE);
-
- Elm_Object_Item *it = NULL;
- Elm_Genlist_Item_Class *itc = NULL;
-
- item_data_s *id_local = NULL;
-
- itc = elm_genlist_item_class_new();
- itc->item_style = "custom_file";
- itc->func.text_get = _file_list_label_get;
- itc->func.content_get = _folder_list_content_get;
- itc->func.del = _folder_list_del;
-
- int i, total_count = 0;
-
- if (child != NULL)
- total_count = eina_list_count(child);
-
- if (total_count == 0) {
- for (i = 0; i < 2; i++) {
- id_local = calloc(1, sizeof(item_data_s));
- id_local->index = i;
+ if (priv->selected_parent_path == NULL)
+ path = NULL;
+ else
+ path = strdup(priv->selected_parent_path);
+ } else {
+ is_home = 0;
- id_local->is_empty = 1;
+ if (priv->selected_parent_path == NULL)
+ path = NULL;
+ else {
+ path = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
- it = elm_genlist_item_append(genlist, itc, id_local, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- id_local->item = it;
+ if (!mf_file_attr_is_dir(path))
+ path = strdup(priv->selected_parent_path);
+ }
}
} else {
- for (i = 0; i < total_count; i++) {
- id_local = calloc(1, sizeof(item_data_s));
- id_local->index = i;
- id_local->is_empty = 0;
-
- id_local->name = _get_list_data_get(child, i);
- id_local->type = _get_file_type(path, id_local->name);
- id_local->file_size = _get_file_size(path, id_local->name);
-
- it = elm_genlist_item_append(genlist, itc, id_local, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- id_local->item = it;
+ if (priv->selected_parent_path == NULL || priv->selected_folder == NULL) {
+ _ERR("priv->selected_parent_path or priv->selected_folder is null. failed _draw_file_list.");
+ return false;
}
+ path = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
}
- elm_genlist_item_class_free(itc);
- elm_object_part_content_set(priv->layout, PART_FILE_LIST, genlist);
-
- evas_object_smart_callback_add(genlist, "item,focused", _item_focus_cb, "item,focused");
- evas_object_smart_callback_add(genlist, "item,unfocused", _item_focus_cb, "item,unfocused");
-
- _focus_set(priv, 1);
- SAFE_FREE_CHAR(path);
-
- return true;
-}
-
-static bool _draw_file_list_root(struct _priv *priv)
-{
- if (priv == NULL) {
- _ERR("priv is null. Failed _draw_file_list_root");
- return false;
- }
-
- Evas_Object *genlist = NULL;
-
- Elm_Object_Item *it = NULL;
- item_data_s *id;
- Elm_Genlist_Item_Class *itc;
-
- int i = 0;
+ Eina_List *child = mf_file_ls(path, priv);
genlist = elm_genlist_add(priv->layout);
elm_object_focus_allow_set(genlist, EINA_TRUE);
- itc = elm_genlist_item_class_new();
- itc->item_style = "custom_file";
-
- itc->func.text_get = _folder_list_label_get;
- itc->func.content_get = _folder_list_content_get;
- itc->func.del = _folder_list_del;
-
- for (i = 0; i < 2; i++) {
- id = calloc(1, sizeof(item_data_s));
- id->index = i;
- id->is_home = 1;
-
- elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- id->item = it;
- }
-
- elm_genlist_item_class_free(itc);
- elm_object_part_content_set(priv->layout, PART_FILE_LIST, genlist);
-
- evas_object_smart_callback_add(genlist, "item,focused", _item_focus_cb, "item,focused");
- evas_object_smart_callback_add(genlist, "item,unfocused", _item_focus_cb, "item,unfocused");
-
- return true;
-}
-
-static bool _draw_file_list(struct _priv *priv, int flag)
-{
- if (priv == NULL) {
- _ERR("priv is null. Failed draw file list");
- return false;
- }
-
- Evas_Object *genlist = NULL;
-
- item_data_s *id;
- Elm_Genlist_Item_Class *itc;
-
- Eina_List *list = NULL, *temp = NULL;
-
- int is_home = 0, buffer_size = 0;
- int i, total_count;
-
- char *path = NULL;
-
- if (priv->selected_folder == NULL) {
- is_home = 1;
-
- if (priv->selected_parent_path == NULL)
- path = NULL;
- else
- path = strdup(priv->selected_parent_path);
- } else {
- is_home = 0;
-
- if (priv->selected_parent_path == NULL)
- path = NULL;
- else {
- buffer_size = strlen(priv->selected_parent_path)+strlen("/")+strlen(priv->selected_folder);
- path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(path, buffer_size+1, "%s/%s", priv->selected_parent_path, priv->selected_folder);
- }
- }
+ Elm_Object_Item *it = NULL;
+ Elm_Genlist_Item_Class *itc = NULL;
- genlist = elm_genlist_add(priv->layout);
- elm_object_focus_allow_set(genlist, EINA_TRUE);
+ item_data_s *id = NULL;
+ itc = elm_genlist_item_class_new();
- if (flag == 2) {
- itc = elm_genlist_item_class_new();
+ if (mode == FILE_OPERATE_MODE)
+ itc->item_style = "custom_file";
+ else
itc->item_style = "custom_file_select";
- itc->func.text_get = _folder_list_label_get;
- itc->func.content_get = _folder_list_content_get;
- itc->func.del = _folder_list_del;
- } else {
- itc = elm_genlist_item_class_new();
- itc->item_style = "custom_file";
+ itc->func.text_get = _list_label_get;
+ itc->func.content_get = _list_content_get;
+ itc->func.del = _list_del;
- itc->func.text_get = _folder_list_label_get;
- itc->func.content_get = _folder_list_content_get;
- itc->func.del = _folder_list_del;
- }
+ if (child != NULL)
+ total_count = eina_list_count(child);
- if (path == NULL)
- total_count = 0;
+ if (total_count == 0)
+ elm_object_part_text_set(priv->layout, PART_FILE_LIST_NO_CONTENT, "No contents");
+ else if (is_home == 1)
+ elm_object_part_text_set(priv->layout, PART_FILE_LIST_HOME, "Home directory");
else {
- list = mf_file_ls(path);
- total_count = eina_list_count(list);
- }
-
- if (total_count == 0 || is_home == 1) {
- for (i = 0; i < 2; i++) {
- id = calloc(1, sizeof(item_data_s));
- id->index = i;
- id->is_home = is_home;
-
- elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _check_item_selected_cb, (void *)flag);
- }
- } else {
for (i = 0; i < total_count; i++) {
id = calloc(1, sizeof(item_data_s));
id->index = i;
- id->is_home = is_home;
- id->child = list;
- temp = eina_list_nth_list(list, i);
- id->name = (char *)eina_list_data_get(temp);
- id->file_size = _get_file_size(path, id->name);
+ id->name = utils_get_list_data_get(child, i);
id->type = _get_file_type(path, id->name);
+ id->file_size = _get_file_size(path, id->name);
+ id->time = _get_file_time(path, id->name);
+
+ id->selected_item_fullpath = strdup(path);
+ id->flag = mode;
- elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _check_item_selected_cb, (void *)flag);
+ it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _file_item_selected_cb, priv);
+ id->item = it;
+ elm_object_item_data_set(it, id);
}
}
elm_genlist_item_class_free(itc);
elm_object_part_content_set(priv->layout, PART_FILE_LIST, genlist);
- _focus_set(priv, flag);
-
evas_object_smart_callback_add(genlist, "item,focused", _item_focus_cb, "item,focused");
evas_object_smart_callback_add(genlist, "item,unfocused", _item_focus_cb, "item,unfocused");
+ _focus_set(priv, mode);
SAFE_FREE_CHAR(path);
return true;
@@ -927,16 +778,25 @@ static bool _draw_file_list(struct _priv *priv, int flag)
static void _draw_view_content(struct _priv *priv)
{
- if (!_draw_folder_list(priv)) {
+ if (!_draw_folder_list(priv, NULL, 0)) {
_ERR("Draw folder list failed.");
return;
}
- if (!_draw_file_list_root(priv)) {
+ if (!_draw_file_list(priv, FILE_ROOT_MODE)) {
_ERR("Draw file list failed.");
return;
}
}
+static void _set_preference(struct _priv *priv)
+{
+ bool existing;
+
+ preference_is_existing(MF_HIDDEN_STATE, &existing);
+
+ if (!existing)
+ preference_set_int(MF_HIDDEN_STATE, 1);
+}
static bool _create(layoutmgr *lmgr, void *data)
{
@@ -983,6 +843,8 @@ static bool _create(layoutmgr *lmgr, void *data)
layoutmgr_set_layout_data(lmgr, LAYOUT_DEFAULT, priv);
_draw_view_content(priv);
+ _set_preference(priv);
+
_focus_set(priv, 1);
return true;
@@ -1044,7 +906,7 @@ static void _update(void *layout_data, int update_type, void *data)
{
struct _priv *priv;
Elm_Object_Item *item = NULL;
- Evas_Object *genlist = NULL;
+ Evas_Object *genlist = NULL, *genlist_file = NULL;
if (!layout_data) {
_ERR("failed to get layout data");
@@ -1056,16 +918,17 @@ static void _update(void *layout_data, int update_type, void *data)
switch (update_type) {
case UPDATE_FILE:
elm_object_disabled_set(elm_object_part_content_get(priv->layout, PART_FOLDER_LIST), EINA_FALSE);
- _draw_file_list(priv, 1);
+ _draw_file_list(priv, FILE_OPERATE_MODE);
break;
case UPDATE_FILE_TO_SELECT:
elm_object_disabled_set(elm_object_part_content_get(priv->layout, PART_FOLDER_LIST), EINA_TRUE);
- _draw_file_list(priv, 2);
+ _draw_file_list(priv, FILE_SELECT_MODE);
break;
case UPDATE_FILE_LIST:
genlist = elm_object_part_content_get(priv->layout, PART_FOLDER_LIST);
+ genlist_file = elm_object_part_content_get(priv->layout, PART_FILE_LIST);
if (genlist == NULL) {
_ERR("genlist is null. failed to update file list");
@@ -1073,8 +936,8 @@ static void _update(void *layout_data, int update_type, void *data)
}
if (priv->list_index == 0) {
- _DBG("rimikim, this is home");
- /* add */
+ _draw_file_list(priv, FILE_ROOT_MODE);
+ elm_genlist_clear(genlist_file);
} else {
item = elm_genlist_nth_item_get(genlist, priv->list_index-1);
diff --git a/src/util/dialog_popup.c b/src/util/dialog_popup.c
deleted file mode 100755
index d746680..0000000
--- a/src/util/dialog_popup.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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 <app.h>
-#include <Elementary.h>
-#include <viewmgr.h>
-#include <inputmgr.h>
-#include <layoutmgr.h>
-#include <app_contents.h>
-#include <app_define.h>
-#include <app_debug.h>
-
-#include "define.h"
-#include "view.h"
-#include "data.h"
-#include "util/utils.h"
-#include "util/dialog_popup.h"
-
-#define STYLE_TARGET_BTN "target_btn"
-
-static void _down_btn_cb(void *data, Evas_Object *obj, void *event_info);
-static void _mouse_move(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Mouse_Move *ev);
-
-static input_handler focus_handler = {
- .mouse_move = _mouse_move
-};
-
-static void _mouse_move(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Mouse_Move *ev)
-{
- elm_object_focus_set(obj, EINA_TRUE);
-}
-
-static void _down_btn_cb(void *data, Evas_Object *obj, void *event_info)
-{
- evas_object_del((Evas_Object *)data);
-}
-
-Evas_Object *dialog_popup_create(dialog_popup_info_t *dialog_popup_info)
-{
- Evas_Object *dialog_popup = NULL;
- Evas_Object *window_layout = NULL;
- Evas_Object *button_1 = NULL, *button_2 = NULL;
- Evas_Object *content_label = NULL;
- Evas_Object *content_check = NULL;
- Evas_Object *content_entry = NULL;
- Evas *e = NULL;
- Ecore_Evas *ee = NULL;
- Eina_Bool result = EINA_FALSE;
-
- char *content = NULL;
- int screen_x = 0, screen_y = 0, screen_w = 0, screen_h = 0;
-
- if (dialog_popup_info == NULL) {
- _ERR("dialog_popup_info is null");
- goto out;
- }
-
- if (dialog_popup_info->data == NULL) {
- _ERR("dialog_popup_info->data is null");
- goto out;
- }
-
- struct _priv *priv;
- priv = dialog_popup_info->data;
-
- /* Creating a Notification Window */
- dialog_popup = elm_win_add(NULL, "dialog_popup", ELM_WIN_BASIC);
-
- if (dialog_popup == NULL) {
- _ERR("elm_win_add failed");
- goto out;
- }
-
- e = evas_object_evas_get(dialog_popup);
- if (!e) {
- _ERR("evas_object_evas_get failed");
- evas_object_del(dialog_popup);
- dialog_popup = NULL;
- goto out;
- }
-
- ee = ecore_evas_ecore_evas_get(e);
- if (!ee) {
- _ERR("ecore_evas_ecore_evas_get failed");
- evas_object_del(dialog_popup);
- dialog_popup = NULL;
- goto out;
- }
-
- priv->popup_win = dialog_popup;
-
- elm_win_alpha_set(dialog_popup, EINA_TRUE);
- elm_win_borderless_set(dialog_popup, EINA_TRUE);
- elm_win_autodel_set(dialog_popup, EINA_TRUE);
-
- elm_win_screen_size_get(dialog_popup, &screen_x, &screen_y, &screen_w, &screen_h);
- evas_object_resize(dialog_popup, screen_w, screen_h);
-
- /* Layout */
- window_layout = elm_layout_add(dialog_popup);
- if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_YES_OR_CANCEL)
- result = elm_layout_file_set(window_layout, EDJEFILE, GRP_DIALOG_POPUP_NO_TITLE);
- else
- result = elm_layout_file_set(window_layout, EDJEFILE, GRP_DIALOG_POPUP);
-
- _DBG("Layout elm_layout_file_set for [%s] returns [%d]", EDJEFILE, result);
- evas_object_resize(window_layout, screen_w, screen_h);
- evas_object_show(window_layout);
-
- if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_INPUT_NAME) {
- content_entry = elm_entry_add(window_layout);
-
- if (dialog_popup_info->title)
- elm_object_part_text_set(window_layout, "part_title_label", dialog_popup_info->title);
-
- if (content_entry == NULL) {
- _ERR("elm_entry_add failed");
- goto out;
- }
-
- elm_object_part_content_set(window_layout, "part_content_swallow", content_entry);
- elm_entry_single_line_set(content_entry, EINA_TRUE);
- elm_entry_editable_set(content_entry, EINA_TRUE);
- elm_object_part_text_set(content_entry, "guide", "Input folder/file name");
-
- if (dialog_popup_info->content)
- elm_object_text_set(content_entry, dialog_popup_info->content);
-
- evas_object_show(content_entry);
- } else if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_CONFIGURATION) {
- if (dialog_popup_info->title)
- elm_object_part_text_set(window_layout, "part_title_label", dialog_popup_info->title);
-
- content_check = elm_check_add(window_layout);
- if (content_check == NULL) {
- _ERR("elm_check_add failed");
- goto out;
- }
-
- if (dialog_popup_info->content)
- elm_object_text_set(content_check, dialog_popup_info->content);
-
- elm_object_part_content_set(window_layout, "part_content_swallow", content_check);
- evas_object_show(content_check);
- } else {
- int content_len = 0;
- int buffer_size = 0;
- const char *start_tag = "<font=BreezeSans:style=Light color=#686868 align=left left_margin=20 font_size=28>";
- const char *end_tag = "</font>";
-
- content_label = elm_label_add(window_layout);
-
- if (content_label == NULL) {
- _ERR("elm_label_add failed");
- goto out;
- }
-
- if (dialog_popup_info->content) {
- content_len = strlen(dialog_popup_info->content);
- buffer_size = strlen(start_tag) + content_len + strlen(end_tag);
- content = (char*)calloc(buffer_size + 1, sizeof(char));
- snprintf(content, buffer_size+1, "%s%s%s", start_tag, dialog_popup_info->content, end_tag);
- elm_object_text_set(content_label, content);
- }
- elm_object_part_content_set(window_layout, "part_content_swallow", content_label);
- elm_object_scale_set(content_label, 1/edje_scale_get());
- evas_object_show(content_label);
- }
-
- button_1 = elm_button_add(window_layout);
- elm_object_focus_allow_set(button_1, EINA_TRUE);
- elm_object_part_content_set(window_layout, "part_button_1", button_1);
- elm_object_style_set(button_1, STYLE_TARGET_BTN);
- if (dialog_popup_info->button_1_text)
- elm_object_part_text_set(button_1, "part_popup_btn_text", dialog_popup_info->button_1_text);
- else
- elm_object_part_text_set(button_1, "part_popup_btn_text", "OK");
-
- evas_object_show(button_1);
-
- button_2 = elm_button_add(window_layout);
- elm_object_focus_allow_set(button_2, EINA_TRUE);
- elm_object_part_content_set(window_layout, "part_button_2", button_2);
- elm_object_style_set(button_2, STYLE_TARGET_BTN);
- if (dialog_popup_info->button_2_text)
- elm_object_part_text_set(button_2, "part_popup_btn_text", dialog_popup_info->button_2_text);
- else
- elm_object_part_text_set(button_2, "part_popup_btn_text", "Cancel");
-
- evas_object_show(button_2);
-
- inputmgr_add_callback(button_1, 0, &focus_handler, dialog_popup);
- inputmgr_add_callback(button_2, 0, &focus_handler, dialog_popup);
-
- evas_object_smart_callback_add(button_2, "clicked", _down_btn_cb, dialog_popup);
-
- evas_object_show(dialog_popup);
- elm_win_activate(dialog_popup);
-
-out:
- if (content != NULL)
- free(content);
-
- free(dialog_popup_info);
- dialog_popup_info = NULL;
-
- return dialog_popup;
-}
diff --git a/src/util/file-attr.c b/src/util/file-attr.c
index 8070eb3..e0490f9 100755
--- a/src/util/file-attr.c
+++ b/src/util/file-attr.c
@@ -26,7 +26,7 @@
#include <app_debug.h>
#include "data.h"
-#include "util/fs-util.h"
+#include "util/fs-oper.h"
#include "util/fs-error.h"
#include "util/file-util.h"
@@ -36,18 +36,6 @@
#define MF_PHONE_DEFAULT_LEVEL 3 /*the phone path is /opt/usr/media, it consists of opt and media two parts*/
#define MF_MMC_DEFAULT_LEVEL 3 /*the mmc path is /opt/storage/sdcard, it consists of opt and storage and sdcard three parts*/
-typedef struct __mf_filter_s mf_filter_s;
-struct __mf_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*/
-};
-#define CONDITION_LENGTH 200
-#define MF_CONDITION_IMAGE_VIDEO "(MEDIA_TYPE=0 OR MEDIA_TYPE=1 OR MEDIA_TYPE=2 OR MEDIA_TYPE=3)"
struct _ftype_by_mime {
const char *mime;
@@ -593,27 +581,23 @@ int mf_file_attr_get_file_category(const char *filepath, fsFileType * category)
}
}
-/*********************
-**Function name: mf_file_attr_get_file_stat
-**Parameter:
-** const char *filename: file name
-** fsNodeInfo **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_file_attr_get_file_mdate(const char *filename, double *date)
+char * mf_file_attr_get_file_mdate_time(const char *filename)
{
+ char *result = NULL;
struct stat statbuf;
if (stat(filename, &statbuf) == -1)
- return MYFILE_ERR_GET_STAT_FAIL;
+ return result;
time_t tempdate = statbuf.st_mtime;
- *date = (double) tempdate * MF_UDATE_NUM;
- return MYFILE_ERR_NONE;
+
+ struct tm tm;
+ char buf[256];
+
+ localtime_r(&tempdate, &tm);
+
+ strftime(buf, sizeof(buf), "%Y/%m/%d", &tm);
+
+ return strdup(buf);
}
@@ -627,7 +611,18 @@ int mf_file_attr_get_file_size(const char *filename, off_t *size)
return MYFILE_ERR_NONE;
}
-
+/*********************
+**Function name: mf_file_attr_get_file_stat
+**Parameter:
+** const char *filename: file name
+** fsNodeInfo **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_file_attr_get_file_stat(const char *filename, fsNodeInfo **node)
{
struct stat statbuf;
@@ -907,189 +902,6 @@ int mf_file_attr_get_parent_path(const char *path, char **parent_path)
return MYFILE_ERR_NONE;
}
-/*********************
-**Function name: mf_file_attr_get_logical_path_by_full
-**Parameter:
-** const char *full_path: the full path
-** char *path: logic path of output parameter
-**
-**Return value:
-** error code
-**
-**Action:
-** get logic path by full path
-**
-*********************/
-int mf_file_attr_get_logical_path_by_full(const char *full_path, char **path)
-{
- assert(full_path);
- assert(path);
- MF_STORAGE store_type = 0;
- int root_len = 0;
-
- int err = mf_file_attr_get_store_type_by_full(full_path, &store_type);
- if (err != MYFILE_ERR_NONE) {
- _ERR("get store type by path %s failed.", full_path);
- return MYFILE_ERR_STORAGE_TYPE_ERROR;
- }
-
- *path = g_strdup(full_path);
- if (*path == NULL)
- return MYFILE_ERR_ALLOCATE_MEMORY_FAIL;
-
- memset(*path, 0, strlen(*path));
- switch (store_type) {
- case MYFILE_PHONE:
- root_len = strlen(PHONE_FOLDER);
- break;
- case MYFILE_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) {
- SAFE_FREE_CHAR(*path);
- *path = g_strdup("/");
- }
-
- return MYFILE_ERR_NONE;
-}
-
-
-typedef struct __mf_transfer_data_s mf_transfer_data_s;
-
-struct __mf_transfer_data_s {
- const char *file_path;
- char *thumb_path;
- media_info_h *media;
-};
-/*
-static bool __mf_local_data_get_media_thumbnail_cb(media_info_h media, void *data)
-{
-// mf_retvm_if(data == NULL, -1, "filter is NULL");
- mf_transfer_data_s *tmp_data = (mf_transfer_data_s *)data;
-
-
- media_info_clone(tmp_data->media, media);
- int retcode = media_info_get_thumbnail_path(media, &(tmp_data->thumb_path));
- if (retcode != MEDIA_CONTENT_ERROR_NONE) {
-// mf_debug("Get media thumbnail path failed!![%d]", retcode);
- }
-
- return false;
-}
-*/
-int mf_file_attr_get_file_icon(const char *file_path, int *error_code, int view_type, char **thumbnail, media_info_h *media_info)
-{
- int index = 0;
- char *icon_path = g_strdup(DEFAULT_ICON);
- fsFileType ftype = FILE_TYPE_NONE;
- fsFileType ftype_by_mime = FILE_TYPE_NONE;
- char *mime = NULL;
- int thumbnail_type = MF_THUMBNAIL_TYPE_DEFAULT;
- int retcode = -1;
- char *ext = NULL;
-
- if (file_path == NULL) {
- _ERR("file_path is NULL");
- return thumbnail_type;
- }
-
- int ret = mf_file_attr_get_file_category(file_path, &ftype);
- ftype_by_mime = ftype;
- if (ret != MYFILE_ERR_NONE || ftype == FILE_TYPE_NONE || ftype == FILE_TYPE_ETC) {
- int err_code = mf_file_attr_get_file_ext(file_path, &ext);
- if (err_code != MYFILE_ERR_NONE || ext == NULL) {
- _ERR("Fail to get file extension");
- return thumbnail_type;
- }
- retcode = mime_type_get_mime_type(ext, &mime);
- if ((mime == NULL) || (retcode != MIME_TYPE_ERROR_NONE)) {
- _ERR("Fail to get mime type, set etc icon");
- SAFE_FREE_CHAR(ext);
- return thumbnail_type;
- }
-
- for (index = 0; mime_type[index].mime; index++) {
- if (strncmp(mime, mime_type[index].mime, strlen(mime)) == 0) {
- ftype_by_mime = mime_type[index].ftype;
- break;
- }
- }
- }
-
- ftype = ftype_by_mime;
-
- SAFE_FREE_CHAR(icon_path);
- SAFE_FREE_CHAR(ext);
-
- switch (ftype) {
- case FILE_TYPE_IMAGE:
- case FILE_TYPE_VIDEO:
- case FILE_TYPE_MUSIC:
- case FILE_TYPE_SOUND: {
- thumbnail_type = MF_THUMBNAIL_TYPE_DEFAULT;
- /*int err = 0;
- mf_transfer_data_s tmp_data;
- memset(&tmp_data, 0x00, sizeof(mf_transfer_data_s));
- tmp_data.file_path = file_path;
- tmp_data.media = media_info;
- //err = mf_file_attr_get_thumbnail(&tmp_data);
- char *condition = NULL;
- condition = g_strdup_printf("%s and MEDIA_PATH=\"%s\"", MF_CONDITION_IMAGE_VIDEO, tmp_data.file_path);
- err = mf_media_content_data_get(&tmp_data, condition, __mf_local_data_get_media_thumbnail_cb);
- if (err == 0) {
- if (tmp_data.thumb_path && mf_file_exists(tmp_data.thumb_path)) {
- SAFE_FREE_CHAR(icon_path);
- icon_path = g_strdup(tmp_data.thumb_path);
- thumbnail_type = MF_THUMBNAIL_TYPE_THUMBNAIL;
- } else {
- icon_path = g_strdup(mf_file_attr_get_default_icon_by_type(ftype));
- thumbnail_type = MF_THUMBNAIL_TYPE_DEFAULT;
- *error_code = 1;
- }
- } else {
- if (error_code) {
- *error_code = err;
- }
-
- icon_path = g_strdup(mf_file_attr_get_default_icon_by_type(ftype));
- thumbnail_type = MF_THUMBNAIL_TYPE_DEFAULT;
- }
- SAFE_FREE_CHAR(tmp_data.thumb_path);*/
- }
- break;
- default:
- icon_path = g_strdup(mf_file_attr_get_default_icon_by_type(ftype));
- thumbnail_type = MF_THUMBNAIL_TYPE_DEFAULT;
- break;
- }
-
- *thumbnail = icon_path;
- SAFE_FREE_CHAR(mime);
- return thumbnail_type;
-}
-
-fsFileType mf_file_attr_get_file_type(const char *mime)
-{
- int index;
- fsFileType ftype = FILE_TYPE_NONE;
- 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;
-
-}
-
fsFileType mf_file_attr_get_file_type_by_mime(const char *file_path)
{
int index;
@@ -1199,156 +1011,6 @@ int mf_file_attr_get_path_level(const char *fullpath, int *level)
}
-/*********************
-**Function name: mf_file_attr_is_in_system_folder
-**Parameter:
-** const char *file_fullpath: the full path
-** int* level: level which the specified path under
-** bool* result: output parameter for the result
-**
-**Return value:
-** error code
-**
-**Action:
-** check if the specified path is under system folder
-**
-*********************/
-int mf_file_attr_is_in_system_folder(char *fullpath, int level, bool * result)
-{
- if (fullpath == NULL)
- return MYFILE_ERR_SRC_ARG_INVALID;
-
- MF_STORAGE storage_t = 0;
- int error_code = mf_file_attr_get_store_type_by_full(fullpath, &storage_t);
-
- if (error_code != 0)
- return error_code;
-
- const char *name = NULL;
- name = mf_file_get(fullpath);
- char *parent_path = NULL;
- error_code = mf_file_attr_get_parent_path(fullpath, &parent_path);
-
- if (error_code != 0)
- return error_code;
-
- if (storage_t == MYFILE_PHONE || storage_t == MYFILE_MMC) {
- if (level == 1) {
- if ((strlen(name) == strlen(DEFAULT_FOLDER_CAMERA_SHOTS)) && strcmp(name, DEFAULT_FOLDER_CAMERA_SHOTS) == 0)
- *result = true;
- else if ((strlen(name) == strlen(DEFAULT_FOLDER_IMAGE)) && strcmp(name, DEFAULT_FOLDER_IMAGE) == 0)
- *result = true;
- else if ((strlen(name) == strlen(DEFAULT_FOLDER_VIDEO)) && strcmp(name, DEFAULT_FOLDER_VIDEO) == 0)
- *result = true;
- else if ((strlen(name) == strlen(DEFAULT_FOLDER_MUSIC)) && strcmp(name, DEFAULT_FOLDER_MUSIC) == 0)
- *result = true;
- else if ((strlen(name) == strlen(DEFAULT_FOLDER_DOWNLOADS)) && strcmp(name, DEFAULT_FOLDER_DOWNLOADS) == 0)
- *result = true;
- else {
- *result = false;
- /*if (storage_t == MYFILE_PHONE) {
- if ((strlen(name) == strlen(DEFAULT_FOLDER_ALERTS_AND_RINGTONES)) && strcmp(name, DEFAULT_FOLDER_ALERTS_AND_RINGTONES) == 0) {
- *result = true;
- } else if ((strlen(name) == strlen(DEFAULT_FOLDER_BOOKMARK)) && strcmp(name, DEFAULT_FOLDER_BOOKMARK) == 0) {
- *result = true;
- } else if ((strlen(name) == strlen(DEFAULT_FOLDER_RSS)) && strcmp(name, DEFAULT_FOLDER_RSS) == 0) {
- *result = true;
- } else {
- *result = false;
- }
- } else {
- *result = false;
- }*/
- }
- } else if (level == 2) {
- const char *parent_name = NULL;
- parent_name = mf_file_get(parent_path);
- if (storage_t == MYFILE_PHONE) {
- if (!g_strcmp0(parent_name, DEFAULT_FOLDER_IMAGE) /*&& !g_strcmp0(name, SUB_FODER_WALLPAPER)*/) {
- *result = true;
- /*} else if (!g_strcmp0(parent_name, DEFAULT_FOLDER_ALERTS_AND_RINGTONES)
- && (!g_strcmp0(name, SUB_FODER_ALERTS) || !g_strcmp0(name, SUB_FODER_RINGTONES))) {
- *result = true;
- } else if (!g_strcmp0(parent_name, DEFAULT_FOLDER_MUSIC)
- && (!g_strcmp0(name, SUB_FODER_FM) || !g_strcmp0(name, SUB_FODER_VOICE_RECORD))) {
- *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;
-}
-
-/*********************
-**Function name: mf_file_attr_is_system_dir
-**Parameter:
-** const char *file_fullpath: the full path
-** bool* result: output parameter for the result
-**
-**Return value:
-** error code
-**
-**Action:
-** check if the specified path is system folder
-**
-*********************/
-int mf_file_attr_is_system_dir(char *fullpath, bool * result)
-{
- if (fullpath == NULL) {
- _ERR("source argument invalid");
- return MYFILE_ERR_SRC_ARG_INVALID;
- }
-
- if (mf_file_attr_is_dir(fullpath) == 0) {
- _ERR("source is not exist");
- return MYFILE_ERR_SRC_NOT_EXIST;
- }
-
- int level = 0;
- int error_code = 0;
-
- error_code = mf_file_attr_get_path_level(fullpath, &level);
- if (error_code != 0) {
- _ERR("Fail to get path level");
- return error_code;
- }
-
- if (level >= 3 || level <= 0) {
- *result = false;
- _ERR("Path Level is wrong");
- return MYFILE_ERR_NONE;
- }
- error_code = mf_file_attr_is_in_system_folder(fullpath, level, result);
-
- if (error_code != 0) {
- _ERR("Fail .. is in system folder err :: %d", error_code);
- return error_code;
- }
-
- return MYFILE_ERR_NONE;
-}
-
void mf_file_attr_get_file_size_info(char **file_size, off_t src_size)
{
if (file_size == NULL) {
diff --git a/src/util/file-util.c b/src/util/file-util.c
index c1e5132..404d455 100755
--- a/src/util/file-util.c
+++ b/src/util/file-util.c
@@ -15,8 +15,16 @@
*
*/
#include <app_debug.h>
+#include <app_preference.h>
+#include <app_preference_internal.h>
+#include <app_control.h>
+#include <app.h>
+#include <glib.h>
#include "util/file-util.h"
+#include "util/fs-oper.h"
+#include "util/fs-error.h"
+#include "define.h"
#define PATH_MAX_SIZE 256
#define BUF_MAX 16384
@@ -187,7 +195,7 @@ int mf_file_rmdir(const char *filename)
return 1;
}
-Eina_List *mf_file_ls(const char *dir)
+Eina_List *mf_file_ls(const char *dir, struct _priv *priv)
{
char *f;
DIR *dirp = NULL;
@@ -195,12 +203,19 @@ Eina_List *mf_file_ls(const char *dir)
struct dirent *dp = NULL;
Eina_List *list = NULL;
+ int hidden_state = 0;
+ mf_util_get_hidden_state(&hidden_state);
+
dirp = opendir(dir);
if (!dirp)
return NULL;
while ((readdir_r(dirp, &ent_struct, &dp) == 0) && dp) {
if ((strcmp(dp->d_name , ".")) && (strcmp(dp->d_name , ".."))) {
+ if (hidden_state == FILE_HIDDEN_HIDE) {
+ if (strncmp(dp->d_name, ".", strlen(".")) == 0)
+ continue;
+ }
f = strdup(dp->d_name);
list = eina_list_append(list, f);
}
@@ -208,7 +223,6 @@ Eina_List *mf_file_ls(const char *dir)
closedir(dirp);
list = eina_list_sort(list, eina_list_count(list), EINA_COMPARE_CB(strcoll));
-
return list;
}
@@ -249,17 +263,9 @@ int mf_file_cp(const char *src, const char *dst)
FILE *f1 = NULL;
FILE *f2 = NULL;
char buf[BUF_MAX] = {0,};
- char realpath1[PATH_MAX_SIZE] = {0,};
- char realpath2[PATH_MAX_SIZE] = {0,};
size_t num;
int ret = 1;
- if (!realpath(src, realpath1))
- return 0;
-
- if (realpath(dst, realpath2) && !strcmp(realpath1, realpath2))
- return 0;
-
f1 = fopen(src, "rb");
if (!f1)
return 0;
@@ -315,20 +321,13 @@ int mf_remove(const char *filename)
void mf_util_free_eina_list_with_data(Eina_List **list, MYFILE_CONTENT_TYPE type)
{
- if (list == NULL || *list == NULL) {
+ if (list == NULL || *list == NULL)
return;
- }
void *pNode = NULL;
Eina_List *l = NULL;
switch (type) {
-/* case MYFILE_TYPE_GSTRING:
- EINA_LIST_FOREACH(*list, l, pNode) {
- GString *node = (GString *)pNode;
- SAFE_FREE_GSTRING(node);
- }
- break;*/
case MYFILE_TYPE_CHAR:
EINA_LIST_FOREACH(*list, l, pNode) {
char *node = (char *)pNode;
@@ -348,12 +347,6 @@ void mf_util_free_eina_list_with_data(Eina_List **list, MYFILE_CONTENT_TYPE type
}
}
break;
-/* case MYFILE_TYPE_ITEM_DATA:
- EINA_LIST_FOREACH(*list, l, pNode) {
- mfItemData_s *Node = (mfItemData_s *)pNode;
- mf_util_normal_item_data_free(&Node);
- }
- break;*/
default:
break;
}
@@ -364,26 +357,140 @@ void mf_util_free_eina_list_with_data(Eina_List **list, MYFILE_CONTENT_TYPE type
return;
}
-void util_free_item_data_s(item_data_s *id)
+int mf_util_get_hidden_state(int *value)
{
- if (id == NULL)
- return;
+ int ret = MYFILE_ERR_NONE;
+
+ ret = preference_get_int(MF_HIDDEN_STATE, value);
+ if (ret < 0) {
+ _ERR("fail to get preference value");
+ ret = preference_set_int(MF_HIDDEN_STATE, FILE_HIDDEN_HIDE);
+ *value = FILE_HIDDEN_HIDE;
+ } else {
+ if (*value < FILE_HIDDEN_SHOW || *value > FILE_HIDDEN_HIDE) {
+ _ERR("fail to get preference value", *value);
+ ret = preference_set_int(MF_HIDDEN_STATE, FILE_HIDDEN_HIDE);
+ *value = FILE_HIDDEN_HIDE;
+ }
+ }
+
+ if (ret != MYFILE_ERR_NONE) {
+ ret = MYFILE_ERR_STORAGE_GET_FAILED;
+ _ERR("MYFILE_ERR_STORAGE_GET_FAILED");
+ }
- SAFE_FREE_CHAR(id->selected_folder_path);
- SAFE_FREE_CHAR(id->parent_path);
- SAFE_FREE_CHAR(id->name);
- SAFE_FREE_CHAR(id->file_size);
+ return ret;
+}
+
+void mf_util_set_hidden_state(int value)
+{
+ int ret = -1;
+
+ if (value <= FILE_HIDDEN_NONE || value >= FILE_HIDDEN_MAX) {
+ ret = preference_set_int(MF_HIDDEN_STATE, FILE_HIDDEN_HIDE);
+ _ERR("invaild hiden by type[%d], set it default : %d", value, ret);
+ } else {
+ ret = preference_set_int("hidden_state", value);
+ _DBG("value is [%d] [%d]", value, ret);
+ }
return;
}
-void util_free_path_item_data_s(path_item_data_s *pid)
+void result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
{
- if (pid == NULL)
- return;
+ _DBG("===================== result is [%d]", result);
+}
+
+int mf_launch_service(void *data, char *path)
+{
+ if (data == NULL || path == NULL) {
+ _ERR("Invalid parameter");
+ return LAUNCH_TYPE_FAIL;
+ }
- SAFE_FREE_CHAR(pid->full_path);
- SAFE_FREE_CHAR(pid->parent_path);
+ _DBG("path is [%s]", path);
+ struct appdata *ap = (struct appdata *)data;
+ fsFileType category = FILE_TYPE_NONE;
+ int ret = 0;
- return;
+ if (mf_file_get(path) == NULL) {
+ _ERR("mf_file_get failed");
+ return LAUNCH_TYPE_FAIL;
+ }
+ if (mf_file_attr_is_dir(path)) {
+ _ERR("mf_file_attr_is_dir failed");
+ return LAUNCH_TYPE_DIR;
+ }
+
+ app_control_h app_control;
+
+ ret = app_control_create(&app_control);
+
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ _DBG("app_control_create()... [0x%x]", ret);
+ goto END;
+ }
+
+ mf_file_attr_get_file_category(path, &category);
+
+ if (category == FILE_TYPE_HTML || category == FILE_TYPE_TPK) {
+ char *html_path = g_strconcat("file://", path, NULL);
+ ret = app_control_set_uri(app_control, html_path);
+ _ERR("uri is [%s]", html_path);
+ SAFE_FREE_CHAR(html_path);
+ } else if (category == FILE_TYPE_IMAGE) {
+ _DBG("category is image");
+ app_control_add_extra_data(app_control, "View By", "All");
+ app_control_add_extra_data(app_control, "Media type", "Image");
+ ret = app_control_set_uri(app_control, path);
+ app_control_set_mime(app_control, "image/*");
+ app_control_add_extra_data(app_control, "Path", path);
+ app_control_set_launch_mode(app_control, APP_CONTROL_LAUNCH_MODE_GROUP);
+ } else if (category == FILE_TYPE_SOUND ||
+ category == FILE_TYPE_MUSIC ||
+ category == FILE_TYPE_VOICE) {
+
+ _DBG("category is sound");
+ app_control_add_extra_data(app_control, "View By", "All");
+ app_control_add_extra_data(app_control, "Media type", "Audio");
+ ret = app_control_set_uri(app_control, path);
+ app_control_set_mime(app_control, "audio/*");
+ } else if (category == FILE_TYPE_VIDEO) {
+ app_control_add_extra_data(app_control, "View By", "All");
+ app_control_add_extra_data(app_control, "Media type", "Video");
+ ret = app_control_set_uri(app_control, path);
+ app_control_set_mime(app_control, "video/*");
+ } else {
+ app_control_add_extra_data(app_control, "launching_application", "myfiles");
+ ret = app_control_set_uri(app_control, path);
+ }
+
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ _DBG("app_control_set_uri()... [0x%x]", ret);
+ goto END;
+ }
+ ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ _DBG("app_control_set_operation()... [0x%x]", ret);
+ goto END;
+ }
+ ret = app_control_enable_app_started_result_event(app_control);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ _DBG("app_control_enable_app_started_result_event()... [0x%x]", ret);
+ goto END;
+ }
+ ret = app_control_send_launch_request(app_control, result_cb, ap);
+
+ if (ret == APP_CONTROL_ERROR_APP_NOT_FOUND)
+ _ERR("APP_CONTROL_ERROR_APP_NOT_FOUND");
+ else if (ret != APP_CONTROL_ERROR_NONE)
+ _ERR("app_control_send_launch_request returns [%d]", ret);
+ else
+ _DBG("app_control_send_launch_request returns APP_CONTROL_ERROR_NONE");
+END:
+ if (app_control)
+ app_control_destroy(app_control);
+
+ return LAUNCH_TYPE_FORK;
}
diff --git a/src/util/fs-oper.c b/src/util/fs-oper.c
new file mode 100755
index 0000000..1f7614a
--- /dev/null
+++ b/src/util/fs-oper.c
@@ -0,0 +1,801 @@
+#include <libgen.h>
+#include <glib.h>
+#include <errno.h>
+#include <sys/statvfs.h>
+#include <app_debug.h>
+
+#include "util/fs-oper.h"
+#include "util/fs-error.h"
+#include "util/file-util.h"
+
+#define DEBUG_FOLDER "SLP_debug"
+
+static int __mf_fs_oper_sort_by_date_cb_O2R(const void *d1, const void *d2);
+static int __mf_fs_oper_sort_by_type_cb_A2Z(const void *d1, const void *d2);
+static int __mf_fs_oper_sort_by_size_cb_S2L(const void *d1, const void *d2);
+static int __mf_fs_oper_sort_by_name_cb_Z2A(const void *d1, const void *d2);
+static int __mf_fs_oper_sort_by_date_cb_R2O(const void *d1, const void *d2);
+static int __mf_fs_oper_sort_by_type_cb_Z2A(const void *d1, const void *d2);
+static int __mf_fs_oper_sort_by_size_cb_L2S(const void *d1, const void *d2);
+
+/*********************
+**Function name: __mf_fm_svc_wrapper_COMESFROM
+**Parameter:
+** GString* fullpath: fullpath to check the location
+**
+**Return value:
+** location of the path
+**
+**Action:
+** get storage type by fullpath
+*********************/
+static int __mf_fm_svc_wrapper_COMESFROM(const char *fullpath)
+{
+ int len_phone = strlen(PHONE_FOLDER);
+ int len_memory = strlen(MEMORY_FOLDER);
+
+ if (strncmp(fullpath, PHONE_FOLDER, len_phone) == 0)
+ return MYFILE_PHONE;
+ else if (strncmp(fullpath, MEMORY_FOLDER, len_memory) == 0)
+ return MYFILE_MMC;
+ else
+ return MYFILE_ERR_STORAGE_TYPE_ERROR;
+}
+
+int mf_fm_svc_wrapper_get_location(const char *fullpath)
+{
+ return __mf_fm_svc_wrapper_COMESFROM(fullpath);
+}
+
+/*********************
+**Function name: mf_fs_oper_get_file
+**Parameter:
+** const char *path: full path to get file name
+**
+**Return value:
+** const char*: file name
+**
+**Action:
+** get file name from full path
+**
+*********************/
+static const char *mf_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;
+}
+
+
+/*********************
+**Function name: mf_fs_oper_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
+**
+*********************/
+int mf_fs_oper_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_DST_ARG_VALID) && (dst == NULL))
+ return MYFILE_ERR_DST_ARG_INVALID;
+
+
+ if ((check_option & MF_ERROR_CHECK_SRC_EXIST) && (!mf_file_exists(src)))
+ return MYFILE_ERR_SRC_NOT_EXIST;
+
+ if ((check_option & MF_ERROR_CHECK_DST_EXIST) && (!mf_file_exists(dst)))
+ return MYFILE_ERR_DST_NOT_EXIST;
+
+
+ if (check_option & MF_ERROR_CHECK_SRC_PATH_VALID) {
+ if (!mf_is_dir(src)) {
+ if (mf_file_attr_is_right_file_path(src))
+ return MYFILE_ERR_INVALID_FILE_PATH;
+ } else {
+ if (mf_file_attr_is_right_dir_path(src))
+ return MYFILE_ERR_INVALID_DIR_PATH;
+ }
+ }
+ if (check_option & MF_ERROR_CHECK_DST_PATH_VALID) {
+ if (!mf_is_dir(dst)) {
+ int ret = mf_file_attr_is_right_file_path(dst);
+ if (ret != 0)
+ return ret;
+ } else {
+ int ret = mf_file_attr_is_right_dir_path(dst);
+ if (ret != 0)
+ return ret;
+ }
+ }
+
+ if (check_option & MF_ERROR_CHECK_SRC_PARENT_DIR_EXIST) {
+ char *parent_path = NULL;
+ if (mf_file_attr_get_parent_path(src, &parent_path)) {
+ if (!mf_file_exists(parent_path)) {
+ SAFE_FREE_CHAR(parent_path);
+ return MYFILE_ERR_DIR_NOT_FOUND;
+ }
+ }
+ SAFE_FREE_CHAR(parent_path);
+ }
+
+ if (check_option & MF_ERROR_CHECK_DST_PARENT_DIR_EXIST) {
+ char *parent_path = NULL;
+ if (mf_file_attr_get_parent_path(dst, &parent_path)) {
+ if (!mf_file_exists(parent_path)) {
+ SAFE_FREE_CHAR(parent_path);
+ return MYFILE_ERR_DIR_NOT_FOUND;
+ }
+ }
+ SAFE_FREE_CHAR(parent_path);
+ }
+
+ if (check_option & MF_ERROR_CHECK_DUPLICATED) {
+ char *parent_path = NULL;
+
+ if (!mf_file_attr_get_parent_path(dst, &parent_path)) {
+ if (mf_file_attr_is_duplicated_name(parent_path, mf_fs_oper_get_file(dst))) {
+ SAFE_FREE_CHAR(parent_path);
+ return MYFILE_ERR_DUPLICATED_NAME;
+ }
+ SAFE_FREE_CHAR(parent_path);
+ } else {
+ SAFE_FREE_CHAR(parent_path);
+ return MYFILE_ERR_GET_PARENT_PATH_FAIL;
+ }
+ }
+
+ return MYFILE_ERR_NONE;
+}
+
+/*********************
+**Function name: mf_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_fs_oper_read_dir(const char *path, Eina_List ** dir_list, Eina_List ** file_list)
+{
+ DIR *pDir = NULL;
+ struct dirent ent_struct;
+ struct dirent *ent;
+
+ if (path == NULL) {
+ _ERR("path is null");
+ return MYFILE_ERR_INVALID_ARG;
+ }
+
+ if (dir_list == NULL) {
+ _ERR("dir_list is null");
+ return MYFILE_ERR_INVALID_ARG;
+ }
+
+ if (file_list == NULL) {
+ _ERR("file_list is null");
+ return MYFILE_ERR_INVALID_ARG;
+ }
+
+ int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_SRC_EXIST | MF_ERROR_CHECK_SRC_PATH_VALID;
+ int storage_type = mf_fm_svc_wrapper_get_location(path);
+ int ret = mf_fs_oper_error(path, NULL, option);
+ if (ret != MYFILE_ERR_NONE)
+ return ret;
+
+ pDir = opendir(path);
+
+ if (pDir == NULL)
+ return MYFILE_ERR_DIR_OPEN_FAIL;
+
+ while ((readdir_r(pDir, &ent_struct, &ent) == 0) && ent) {
+ GString *childpath = NULL;
+ fsNodeInfo *pNode = NULL;
+
+ int len = strlen(ent->d_name);
+ if ((len == 1 && strncmp(ent->d_name, ".", strlen(".")) == 0) || (len == 2 && strncmp(ent->d_name, "..", strlen("..")) == 0))
+ continue;
+
+ int hidden_state = 0;
+ mf_util_get_hidden_state(&hidden_state);
+
+ if (hidden_state == FILE_HIDDEN_HIDE) {
+ if (strncmp(ent->d_name, ".", strlen(".")) == 0 || strncmp(ent->d_name, "..", strlen("..")) == 0)
+ continue;
+ }
+
+ if ((ent->d_type & DT_DIR) == 0 && (ent->d_type & DT_REG) == 0)
+ continue;
+
+ 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;
+ }
+
+ pNode = (fsNodeInfo *) malloc(sizeof(fsNodeInfo));
+
+ if (pNode == NULL)
+ continue;
+
+ memset(pNode, 0, sizeof(fsNodeInfo));
+
+ pNode->path = g_strdup(path);
+ pNode->name = g_strdup(ent->d_name);
+ pNode->storage_type = storage_type;
+ pNode->list_type = mf_list_normal;
+
+ if (ent->d_type & DT_DIR)
+ pNode->type = FILE_TYPE_DIR;
+ else if (ent->d_type & DT_REG)
+ mf_file_attr_get_file_category(ent->d_name, &(pNode->type));
+
+ childpath = g_string_new(path);
+ if (childpath == NULL) {
+ SAFE_FREE_CHAR(pNode->path);
+ SAFE_FREE_CHAR(pNode->name);
+ SAFE_FREE_CHAR(pNode);
+ continue;
+ }
+ g_string_append_printf(childpath, "/%s", ent->d_name);
+ mf_file_attr_get_file_stat(childpath->str, &pNode);
+ if (pNode->type == FILE_TYPE_DIR)
+ *dir_list = eina_list_append(*dir_list, pNode);
+ else {
+ ret = mf_file_attr_get_file_ext(childpath->str, &pNode->ext);
+ if (ret != MYFILE_ERR_NONE) {
+ pNode->ext = NULL;
+ pNode->type = mf_file_attr_get_file_type_by_mime(childpath->str);
+ }
+ *file_list = eina_list_append(*file_list, pNode);
+ }
+ g_string_free(childpath, TRUE);
+ }
+ closedir(pDir);
+
+ return MYFILE_ERR_NONE;
+}
+
+
+/*********************
+**Function name: mf_fs_oper_create_dir
+**Parameter:
+** const char *file: dir need to be operation
+**
+**Return value:
+** error code
+**
+**Action:
+** create dir
+*********************/
+int mf_fs_oper_create_dir(const char *dir)
+{
+ int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_DUPLICATED;
+ int ret = mf_fs_oper_error(dir, dir, option);
+
+ if (ret != 0)
+ return ret;
+
+ ret = mf_file_attr_is_right_dir_path(dir);
+
+ if (ret != 0)
+ return ret;
+
+ errno = 0;
+ if (!mf_mkpath(dir)) {
+ ret = mf_error_erron_to_mferror(errno);
+ if (ret == MYFILE_ERR_NONE)
+ return MYFILE_ERR_DIR_CREATE_FAIL;
+ else
+ return ret;
+ }
+ sync();
+ return MYFILE_ERR_NONE;
+}
+
+
+/*********************
+**Function name: mf_fs_oper_rename_file
+**Parameter:
+** const char *src: source file need to rename
+** const char *dst: destination file which is to be renamed
+
+**
+**Return value:
+** error code
+**
+**Action:
+** rename a file
+*********************/
+int mf_fs_oper_rename_file(const char *src, const char *dst)
+{
+ int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_DST_ARG_VALID |
+ MF_ERROR_CHECK_SRC_EXIST | MF_ERROR_CHECK_DST_PATH_VALID |
+ MF_ERROR_CHECK_SRC_PATH_VALID | MF_ERROR_CHECK_SRC_PATH_VALID | MF_ERROR_CHECK_DST_PARENT_DIR_EXIST | MF_ERROR_CHECK_DUPLICATED;
+ int ret = mf_fs_oper_error(src, dst, option);
+
+ if (ret != 0)
+ return ret;
+
+ if (rename(src, dst))
+ return MYFILE_ERR_RENAME_FAIL;
+ else
+ return MYFILE_ERR_NONE;
+}
+
+
+static int __mf_fs_oper_sort_by_priority(const void *d1, const void *d2, int sequence_type)
+{
+ int ret = 0;
+ switch (sequence_type) {
+ case MF_SORT_BY_PRIORITY_TYPE_A2Z:
+ ret = __mf_fs_oper_sort_by_date_cb_O2R(d1, d2);
+ if (ret == 0) {
+ ret = __mf_fs_oper_sort_by_size_cb_S2L(d1, d2);
+ if (ret == 0)
+ ret = __mf_fs_oper_sort_by_name_cb_A2Z(d1, d2);
+ }
+ break;
+ case MF_SORT_BY_PRIORITY_TYPE_Z2A:
+ ret = __mf_fs_oper_sort_by_date_cb_R2O(d1, d2);
+ if (ret == 0) {
+ ret = __mf_fs_oper_sort_by_size_cb_L2S(d1, d2);
+ if (ret == 0)
+ ret = __mf_fs_oper_sort_by_name_cb_Z2A(d1, d2);
+ }
+ break;
+ case MF_SORT_BY_PRIORITY_DATE_O2R:
+ ret = __mf_fs_oper_sort_by_name_cb_A2Z(d1, d2);
+ break;
+ case MF_SORT_BY_PRIORITY_DATE_R2O:
+ ret = __mf_fs_oper_sort_by_name_cb_Z2A(d1, d2);
+ break;
+ case MF_SORT_BY_PRIORITY_SIZE_S2L:
+ ret = __mf_fs_oper_sort_by_name_cb_A2Z(d1, d2);
+ break;
+ case MF_SORT_BY_PRIORITY_SIZE_L2S:
+ ret = __mf_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
+
+**
+*********************/
+int __mf_fs_oper_sort_by_name_cb_A2Z(const void *d1, const void *d2)
+{
+ fsNodeInfo *txt1 = (fsNodeInfo *) d1;
+ fsNodeInfo *txt2 = (fsNodeInfo *) d2;
+ gchar *name1 = NULL;
+ gchar *name2 = NULL;
+ int result = 0;
+
+ if (!txt1 || !txt1->name)
+ return (1);
+
+ if (!txt2 || !txt2->name)
+ 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_fs_oper_sort_by_date_cb_O2R(const void *d1, const void *d2)
+{
+ int ret = 0;
+ fsNodeInfo *time1 = (fsNodeInfo *) d1;
+ fsNodeInfo *time2 = (fsNodeInfo *) 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_fs_oper_sort_by_priority(d1, d2, MF_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_fs_oper_sort_by_type_cb_A2Z(const void *d1, const void *d2)
+{
+ fsNodeInfo *type1 = (fsNodeInfo *) d1;
+ fsNodeInfo *type2 = (fsNodeInfo *) 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_fs_oper_sort_by_priority(d1, d2, MF_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_fs_oper_sort_by_size_cb_S2L(const void *d1, const void *d2)
+{
+ int ret = 0;
+ fsNodeInfo *size1 = (fsNodeInfo *) d1;
+ fsNodeInfo *size2 = (fsNodeInfo *) 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_fs_oper_sort_by_priority(d1, d2, MF_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_fs_oper_sort_by_name_cb_Z2A(const void *d1, const void *d2)
+{
+ fsNodeInfo *txt1 = (fsNodeInfo *) d1;
+ fsNodeInfo *txt2 = (fsNodeInfo *) d2;
+
+ int result = 0;
+
+ if (!txt1 || !txt1->name)
+ return (1);
+
+ if (!txt2 || !txt2->name)
+ 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_fs_oper_sort_by_date_cb_R2O(const void *d1, const void *d2)
+{
+ int ret = 0;
+ fsNodeInfo *time1 = (fsNodeInfo *) d1;
+ fsNodeInfo *time2 = (fsNodeInfo *) 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_fs_oper_sort_by_priority(d1, d2, MF_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_fs_oper_sort_by_type_cb_Z2A(const void *d1, const void *d2)
+{
+ fsNodeInfo *type1 = (fsNodeInfo *) d1;
+ fsNodeInfo *type2 = (fsNodeInfo *) 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_fs_oper_sort_by_priority(d1, d2, MF_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_fs_oper_sort_by_size_cb_L2S(const void *d1, const void *d2)
+{
+ int ret = 0;
+ fsNodeInfo *size1 = (fsNodeInfo *) d1;
+ fsNodeInfo *size2 = (fsNodeInfo *) 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_fs_oper_sort_by_priority(d1, d2, MF_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_fs_oper_sort_list(Eina_List **list, int sort_opt)
+{
+ Eina_Compare_Cb sort_func = NULL;
+
+ _DBG("mf_fs_oper_sort_list");
+
+ if (!(*list))
+ return;
+
+ switch (sort_opt) {
+ case MYFILE_SORT_BY_NAME_A2Z:
+ sort_func = __mf_fs_oper_sort_by_name_cb_A2Z;
+ break;
+ case MYFILE_SORT_BY_TYPE_A2Z:
+ sort_func = __mf_fs_oper_sort_by_type_cb_A2Z;
+ break;
+ case MYFILE_SORT_BY_SIZE_S2L:
+ sort_func = __mf_fs_oper_sort_by_size_cb_S2L;
+ break;
+ case MYFILE_SORT_BY_DATE_O2R:
+ sort_func = __mf_fs_oper_sort_by_date_cb_O2R;
+ break;
+ case MYFILE_SORT_BY_NAME_Z2A:
+ sort_func = __mf_fs_oper_sort_by_name_cb_Z2A;
+ break;
+ case MYFILE_SORT_BY_TYPE_Z2A:
+ sort_func = __mf_fs_oper_sort_by_type_cb_Z2A;
+ break;
+ case MYFILE_SORT_BY_SIZE_L2S:
+ sort_func = __mf_fs_oper_sort_by_size_cb_L2S;
+ break;
+ case MYFILE_SORT_BY_DATE_R2O:
+ sort_func = __mf_fs_oper_sort_by_date_cb_R2O;
+ break;
+ default:
+ sort_func = __mf_fs_oper_sort_by_type_cb_A2Z;
+ break;
+ }
+
+ *list = eina_list_sort(*list, eina_list_count(*list), sort_func);
+}
diff --git a/src/util/fs-util.c b/src/util/fs-util.c
deleted file mode 100755
index 71c9e71..0000000
--- a/src/util/fs-util.c
+++ /dev/null
@@ -1,337 +0,0 @@
-#include <glib.h>
-#include <app_debug.h>
-
-#include "util/fs-util.h"
-#include "util/fs-error.h"
-#include "util/file-util.h"
-
-#define DEBUG_FOLDER "SLP_debug"
-
-/*********************
-**Function name: __mf_fm_svc_wrapper_COMESFROM
-**Parameter:
-** GString* fullpath: fullpath to check the location
-**
-**Return value:
-** location of the path
-**
-**Action:
-** get storage type by fullpath
-*********************/
-static int __mf_fm_svc_wrapper_COMESFROM(const char *fullpath)
-{
- int len_phone = strlen(PHONE_FOLDER);
- int len_memory = strlen(MEMORY_FOLDER);
-
- if (strncmp(fullpath, PHONE_FOLDER, len_phone) == 0)
- return MYFILE_PHONE;
- else if (strncmp(fullpath, MEMORY_FOLDER, len_memory) == 0)
- return MYFILE_MMC;
- else
- return MYFILE_ERR_STORAGE_TYPE_ERROR;
-}
-
-int mf_fm_svc_wrapper_get_location(const char *fullpath)
-{
- return __mf_fm_svc_wrapper_COMESFROM(fullpath);
-}
-
-/*********************
-**Function name: mf_fs_oper_get_file
-**Parameter:
-** const char *path: full path to get file name
-**
-**Return value:
-** const char*: file name
-**
-**Action:
-** get file name from full path
-**
-*********************/
-static const char *mf_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;
-}
-
-
-/*********************
-**Function name: mf_fs_oper_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
-**
-*********************/
-int mf_fs_oper_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_DST_ARG_VALID) && (dst == NULL))
- return MYFILE_ERR_DST_ARG_INVALID;
-
-
- if ((check_option & MF_ERROR_CHECK_SRC_EXIST) && (!mf_file_exists(src)))
- return MYFILE_ERR_SRC_NOT_EXIST;
-
- if ((check_option & MF_ERROR_CHECK_DST_EXIST) && (!mf_file_exists(dst)))
- return MYFILE_ERR_DST_NOT_EXIST;
-
-
- if (check_option & MF_ERROR_CHECK_SRC_PATH_VALID) {
- if (!mf_is_dir(src)) {
- if (mf_file_attr_is_right_file_path(src))
- return MYFILE_ERR_INVALID_FILE_PATH;
- } else {
- if (mf_file_attr_is_right_dir_path(src))
- return MYFILE_ERR_INVALID_DIR_PATH;
- }
- }
- if (check_option & MF_ERROR_CHECK_DST_PATH_VALID) {
- if (!mf_is_dir(dst)) {
- int ret = mf_file_attr_is_right_file_path(dst);
- if (ret != 0)
- return ret;
- } else {
- int ret = mf_file_attr_is_right_dir_path(dst);
- if (ret != 0)
- return ret;
- }
- }
-
- if (check_option & MF_ERROR_CHECK_SRC_PARENT_DIR_EXIST) {
- char *parent_path = NULL;
- if (mf_file_attr_get_parent_path(src, &parent_path)) {
- if (!mf_file_exists(parent_path)) {
- SAFE_FREE_CHAR(parent_path);
- return MYFILE_ERR_DIR_NOT_FOUND;
- }
- }
- SAFE_FREE_CHAR(parent_path);
- }
-
- if (check_option & MF_ERROR_CHECK_DST_PARENT_DIR_EXIST) {
- char *parent_path = NULL;
- if (mf_file_attr_get_parent_path(dst, &parent_path)) {
- if (!mf_file_exists(parent_path)) {
- SAFE_FREE_CHAR(parent_path);
- return MYFILE_ERR_DIR_NOT_FOUND;
- }
- }
- SAFE_FREE_CHAR(parent_path);
- }
-
- if (check_option & MF_ERROR_CHECK_DUPLICATED) {
- char *parent_path = NULL;
-
- if (!mf_file_attr_get_parent_path(dst, &parent_path)) {
- if (mf_file_attr_is_duplicated_name(parent_path, mf_fs_oper_get_file(dst))) {
- SAFE_FREE_CHAR(parent_path);
- return MYFILE_ERR_DUPLICATED_NAME;
- }
- SAFE_FREE_CHAR(parent_path);
- } else {
- SAFE_FREE_CHAR(parent_path);
- return MYFILE_ERR_GET_PARENT_PATH_FAIL;
- }
- }
-
- return MYFILE_ERR_NONE;
-}
-
-/*********************
-**Function name: mf_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_fs_oper_read_dir(const char *path, Eina_List ** dir_list, Eina_List ** file_list)
-{
- DIR *pDir = NULL;
- struct dirent ent_struct;
- struct dirent *ent;
-
- if (path == NULL) {
- _ERR("path is null");
- return MYFILE_ERR_INVALID_ARG;
- }
-
- if (dir_list == NULL) {
- _ERR("dir_list is null");
- return MYFILE_ERR_INVALID_ARG;
- }
-
- if (file_list == NULL) {
- _ERR("file_list is null");
- return MYFILE_ERR_INVALID_ARG;
- }
-
- int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_SRC_EXIST | MF_ERROR_CHECK_SRC_PATH_VALID;
- int storage_type = mf_fm_svc_wrapper_get_location(path);
- int ret = mf_fs_oper_error(path, NULL, option);
- if (ret != MYFILE_ERR_NONE)
- return ret;
-
- pDir = opendir(path);
-
- if (pDir == NULL)
- return MYFILE_ERR_DIR_OPEN_FAIL;
-
- while ((readdir_r(pDir, &ent_struct, &ent) == 0) && ent) {
- GString *childpath = NULL;
- fsNodeInfo *pNode = NULL;
-
- int len = strlen(ent->d_name);
- if ((len == 1 && strncmp(ent->d_name, ".", strlen(".")) == 0) || (len == 2 && strncmp(ent->d_name, "..", strlen("..")) == 0))
- continue;
-
- /*int hiden_state = 0;
- mf_util_get_pref_value(PREF_TYPE_HIDEN_STATE, &hiden_state);
- if (hiden_state == MF_HIDEN_HIDE) {
- if (strncmp(ent->d_name, ".", strlen(".")) == 0 || strncmp(ent->d_name, "..", strlen("..")) == 0) {
- continue;
- }
- }*/
-
- if ((ent->d_type & DT_DIR) == 0 && (ent->d_type & DT_REG) == 0)
- continue;
-
- 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;
- }
-
- pNode = (fsNodeInfo *) malloc(sizeof(fsNodeInfo));
-
- if (pNode == NULL)
- continue;
-
- memset(pNode, 0, sizeof(fsNodeInfo));
-
- pNode->path = g_strdup(path);
- pNode->name = g_strdup(ent->d_name);
- pNode->storage_type = storage_type;
- pNode->list_type = mf_list_normal;
-
- if (ent->d_type & DT_DIR)
- pNode->type = FILE_TYPE_DIR;
- else if (ent->d_type & DT_REG)
- mf_file_attr_get_file_category(ent->d_name, &(pNode->type));
-
- childpath = g_string_new(path);
- if (childpath == NULL) {
- SAFE_FREE_CHAR(pNode->path);
- SAFE_FREE_CHAR(pNode->name);
- SAFE_FREE_CHAR(pNode);
- continue;
- }
- g_string_append_printf(childpath, "/%s", ent->d_name);
- mf_file_attr_get_file_stat(childpath->str, &pNode);
- if (pNode->type == FILE_TYPE_DIR)
- *dir_list = eina_list_append(*dir_list, pNode);
- else {
- ret = mf_file_attr_get_file_ext(childpath->str, &pNode->ext);
- if (ret != MYFILE_ERR_NONE) {
- pNode->ext = NULL;
- pNode->type = mf_file_attr_get_file_type_by_mime(childpath->str);
- }
- *file_list = eina_list_append(*file_list, pNode);
- }
- g_string_free(childpath, TRUE);
- }
- closedir(pDir);
-
- return MYFILE_ERR_NONE;
-}
-
-
-/*********************
-**Function name: mf_fs_oper_create_dir
-**Parameter:
-** const char *file: dir need to be operation
-**
-**Return value:
-** error code
-**
-**Action:
-** create dir
-*********************/
-int mf_fs_oper_create_dir(const char *dir)
-{
- int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_DUPLICATED;
- int ret = mf_fs_oper_error(dir, dir, option);
-
- if (ret != 0)
- return ret;
-
- ret = mf_file_attr_is_right_dir_path(dir);
-
- if (ret != 0)
- return ret;
-
- errno = 0;
- if (!mf_mkpath(dir)) {
- ret = mf_error_erron_to_mferror(errno);
- if (ret == MYFILE_ERR_NONE)
- return MYFILE_ERR_DIR_CREATE_FAIL;
- else
- return ret;
- }
- sync();
- return MYFILE_ERR_NONE;
-}
-
-
-/*********************
-**Function name: mf_fs_oper_rename_file
-**Parameter:
-** const char *src: source file need to rename
-** const char *dst: destination file which is to be renamed
-
-**
-**Return value:
-** error code
-**
-**Action:
-** rename a file
-*********************/
-int mf_fs_oper_rename_file(const char *src, const char *dst)
-{
- int option = MF_ERROR_CHECK_SRC_ARG_VALID | MF_ERROR_CHECK_DST_ARG_VALID |
- MF_ERROR_CHECK_SRC_EXIST | MF_ERROR_CHECK_DST_PATH_VALID |
- MF_ERROR_CHECK_SRC_PATH_VALID | MF_ERROR_CHECK_SRC_PATH_VALID | MF_ERROR_CHECK_DST_PARENT_DIR_EXIST | MF_ERROR_CHECK_DUPLICATED;
- int ret = mf_fs_oper_error(src, dst, option);
-
- if (ret != 0)
- return ret;
-
- if (rename(src, dst))
- return MYFILE_ERR_RENAME_FAIL;
- else
- return MYFILE_ERR_NONE;
-}
diff --git a/src/util/utils.c b/src/util/utils.c
index e6738e8..a8c608a 100755
--- a/src/util/utils.c
+++ b/src/util/utils.c
@@ -15,306 +15,79 @@
*/
#include <Elementary.h>
-#include <app_control.h>
#include <app_debug.h>
-#include <inputmgr.h>
-#include <viewmgr.h>
-#include <package_manager.h>
-#include <storage.h>
-#include <media_content.h>
-
-#include "define.h"
-#include "view.h"
-#include "data.h"
+
#include "util/utils.h"
-#include "util/dialog_popup.h"
-#include "util/fs-util.h"
-#include "util/fs-error.h"
#include "util/file-util.h"
+#include "view/dialog_popup.h"
-#define STYLE_TARGET_BTN "target_btn"
-
-typedef struct util_item_data {
- int index;
- Elm_Object_Item *item;
-
- char *folder_name;
-} util_item_data_s;
-
-static char* _folder_list_label_get(void *data, Evas_Object *obj, const char *part);
-static Evas_Object* _folder_list_content_get(void *data, Evas_Object *obj, const char *part);
-static void _folder_list_del(void *data, Evas_Object *obj);
-
-static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Up *ev);
-
-static void _down_btn_cb(void *data, Evas_Object *obj, void *event_info);
-
-static void _selected(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
-static void _focused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
-static void _unfocused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
-
-static input_handler popup_handler = {
- .key_up = _key_up_cb,
- .selected = _selected
-};
-
-static input_handler genlist_handler = {
- .key_up = _key_up_cb
-};
-
-static input_handler focus_handler = {
- .focused = _focused,
- .unfocused = _unfocused
-};
-/*
-static Eina_Bool ecore_timer_cb(void *data)
-{
- Evas_Object * genlist = (Evas_Object *)data;
- Elm_Object_Item * it = elm_genlist_selected_item_get(genlist);
- elm_genlist_item_selected_set(it, EINA_FALSE);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void
-check_changed_item_cb(void *data, Evas_Object *obj, void *event_info)
+void utils_show_dialog_popup(dialog_popup_type_e type, char *title,
+ char *content, char *btn1_text, char *btn2_text, struct _priv *priv)
{
- Evas_Object * genlist = (Evas_Object *)data;
- ecore_timer_add(0.1, ecore_timer_cb, genlist);
-}
-*/
-static fsNodeInfo* _get_fsNodeInfo(Eina_List *list, int index)
-{
- fsNodeInfo *node = NULL;
-
- if (list == NULL)
- return node;
+ dialog_popup_info_t *info = calloc(1, sizeof(dialog_popup_info_t));
- node = (fsNodeInfo *)eina_list_nth(list, index);
-
- return node;
-}
-
-static void _selected(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
-{
- if (data == NULL) {
- _ERR("data is null. failed select popup menu");
+ if (info == NULL) {
+ _ERR("info is NULL. failed to allocate memory");
return;
}
- struct _priv *priv;
- priv = (struct _priv *)data;
+ info->dialog_popup_type = type;
- if (item == NULL) {
- _ERR("item is null. failed select popup menu");
- return;
- }
+ if (title != NULL)
+ info->title = title;
- int index = elm_genlist_item_index_get(item);
- inputmgr_remove_callback(priv->popup_win, &popup_handler);
- evas_object_del(priv->popup_win);
+ if (content != NULL)
+ info->content = content;
- if (index == 1 || index == 2)
- viewmgr_update_view(VIEW_BASE, UPDATE_FILE_TO_SELECT, priv);
- else if (index == 4) {
- dialog_popup_info_t *info = calloc(1, sizeof(dialog_popup_info_t));
+ if (btn1_text != NULL)
+ info->button_1_text = btn1_text;
- info->dialog_popup_type = DIALOG_POPUP_TYPE_INPUT_NAME;
- info->title = "New Folder";
- info->content = "Input folder name to create.";
- info->button_1_text = "OK";
- info->button_2_text = "Cancel";
- info->data = priv;
-
- dialog_popup_create(info);
- }
- else if (index == 3) {
- dialog_popup_info_t *info = calloc(1, sizeof(dialog_popup_info_t));
-
- info->dialog_popup_type = DIALOG_POPUP_TYPE_INPUT_NAME;
- info->title = "Rename";
- info->content = "Input new name to change.";
- info->button_1_text = "OK";
- info->button_2_text = "Cancel";
- info->data = priv;
-
- dialog_popup_create(info);
- } else if (index == 5) {
- dialog_popup_info_t *info = calloc(1, sizeof(dialog_popup_info_t));
-
- info->dialog_popup_type = DIALOG_POPUP_TYPE_YES_OR_CANCEL;
- info->content = "Delete?";
- info->button_1_text = "OK";
- info->button_2_text = "Cancel";
- info->data = priv;
-
- dialog_popup_create(info);
- } else if (index == 6) {
- dialog_popup_info_t *info = calloc(1, sizeof(dialog_popup_info_t));
-
- info->dialog_popup_type = DIALOG_POPUP_TYPE_CONFIGURATION;
- info->title = "Setting";
- info->content = "Show hidden files";
- info->button_1_text = "OK";
- info->button_2_text = "Cancel";
- info->data = priv;
-
- dialog_popup_create(info);
- }
-
- return;
-}
+ if (btn2_text != NULL)
+ info->button_2_text = btn2_text;
+ info->data = priv;
-
-static void _focused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
-{
- elm_object_item_signal_emit(item, "mouse,in", "elm");
- elm_genlist_item_update(item);
-}
-
-static void _unfocused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
-{
- elm_object_item_signal_emit(item, "mouse,out", "elm");
- elm_genlist_item_update(item);
+ dialog_popup_create(info);
}
-static void _item_focus_cb(void *data, Evas_Object *obj, void *event_info)
+char* utils_get_list_data_get(Eina_List *list, int index)
{
- if (data == NULL)
- return;
+ char *data = NULL;
+ Eina_List *list_local = NULL;
- char *signal = NULL;
- signal = (char *)data;
+ list_local = eina_list_nth_list(list, index);
- if (!strcmp(signal, "item,focused"))
- elm_object_item_signal_emit(event_info, "mouse,in", "elm");
- else if (!strcmp(signal, "item,unfocused"))
- elm_object_item_signal_emit(event_info, "mouse,out", "elm");
-
- return;
-}
-
-static Evas_Object* create_check(Evas_Object *parent, void *data)
-{
- Evas_Object *check;
- check = elm_check_add(parent);
-// evas_object_smart_callback_add(check, "changed", check_changed_item_cb, data);
- evas_object_propagate_events_set(check, EINA_FALSE);
- return check;
-}
-
-static char*
-_folder_list_label_get(void *data, Evas_Object *obj, const char *part)
-{
- if (data == NULL) {
- _ERR("data is null. Failed get label");
+ if (list_local == NULL) {
+ _ERR("list is null. failed get list data");
return NULL;
}
- char buf[256];
- util_item_data_s *id = (util_item_data_s *)data;
-
- if (!strcmp("elm.text.file", part)) {
- if (id->folder_name == NULL)
- return NULL;
+ data = (char *)eina_list_data_get(list_local);
- snprintf(buf, sizeof(buf), "%s", id->folder_name);
- } else {
- if (id->index == 0)
- snprintf(buf, sizeof(buf), "Copy");
- else if (id->index == 1)
- snprintf(buf, sizeof(buf), "Move");
- else if (id->index == 2)
- snprintf(buf, sizeof(buf), "Rename");
- else if (id->index == 3)
- snprintf(buf, sizeof(buf), "New folder");
- else if (id->index == 4)
- snprintf(buf, sizeof(buf), "Delete");
- else if (id->index == 5)
- snprintf(buf, sizeof(buf), "Setting");
- else
- return NULL;
- }
-
- return strdup(buf);
-}
-
-static Evas_Object*
-_folder_list_content_get(void *data, Evas_Object *obj, const char *part)
-{
- if (!strcmp("elm.swallow.icon", part)) {
- Evas_Object *icon = elm_image_add(obj);
-
- elm_image_file_set(icon, IMGDIR"/icon/myfile_icon_folder.png", NULL);
- return icon;
- } else if (!strcmp("elm.swallow.end", part)) {
- return create_check(obj, data);
- }
-
- return NULL;
-}
-
-static void
-_folder_list_del(void *data, Evas_Object *obj)
-{
- /* Unrealized callback can be called after this. */
- /* Accessing item_data_s can be dangerous on unrealized callback. */
- util_item_data_s *id = (util_item_data_s *)data;
- free(id);
-}
-
-static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Up *ev)
-{
- if (!data)
- return;
-
- struct _priv *priv;
- priv = (struct _priv *)data;
-
- if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_ESC)) {
- inputmgr_remove_callback(priv->popup_win, &popup_handler);
- evas_object_del(priv->popup_win);
- }
-}
-
-static void _down_btn_cb(void *data, Evas_Object *obj, void *event_info)
-{
- if (!data)
- return;
-
- struct _priv *priv;
- priv = (struct _priv *)data;
-
- viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
- evas_object_del(priv->popup_win);
+ return data;
}
-static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+char *utils_get_combined_string(const char *first, const char *second, const char *third)
{
- Evas_Object *check = NULL;
+ int buffer_size;
+ char *result = NULL;
- if (event_info == NULL) {
- _ERR("event_info is null");
- return;
+ if (first == NULL || second == NULL) {
+ _ERR("parameters are wrong. failed utils_get_combined_string");
+ return result;
}
- check = elm_object_item_part_content_get(event_info, "elm.swallow.end");
-
- if (check == NULL) {
- _ERR("check box is null. Failed item_selected_cb");
- return;
+ if (third == NULL) {
+ buffer_size = strlen(first)+strlen("/")+strlen(second);
+ result = (char *)calloc(buffer_size+1, sizeof(char));
+ snprintf(result, buffer_size+1, "%s/%s", first, second);
+ } else {
+ buffer_size = strlen(first)+strlen("/")+strlen(second)+strlen("/")+strlen(third);
+ result = (char *)calloc(buffer_size+1, sizeof(char));
+ snprintf(result, buffer_size+1, "%s/%s/%s", first, second, third);
}
- if (elm_check_state_get(check))
- elm_check_state_set(check, EINA_FALSE);
- else
- elm_check_state_set(check, EINA_TRUE);
-
- return;
+ return result;
}
Evas_Object *utils_add_window(const char *name)
@@ -367,401 +140,39 @@ Evas_Object *utils_add_layout(Evas_Object *parent, const char *group,
return layout;
}
-Evas_Object *utils_add_box(Evas_Object *parent, const char *part,
- Eina_Bool horizontal, Evas_Coord padding_h,
- Evas_Coord padding_v)
+void util_free_item_data_s(item_data_s *id)
{
- Evas_Object *box;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- box = elm_box_add(parent);
- if (!box) {
- _ERR("elm_box_add failed.");
- return NULL;
- }
-
- elm_box_horizontal_set(box, horizontal);
- elm_box_padding_set(box, ELM_SCALE_SIZE(padding_h),
- ELM_SCALE_SIZE(padding_v));
-
- evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- if (part)
- elm_object_part_content_set(parent, part, box);
- else
- elm_object_content_set(parent, box);
-
- evas_object_show(box);
-
- return box;
-}
-
-Evas_Object *utils_add_button(Evas_Object *parent, const char *part,
- const char *text, const char *style)
-{
- Evas_Object *btn;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- btn = elm_button_add(parent);
- if (!btn) {
- _ERR("elm_button_add failed.");
- return NULL;
- }
-
- if (part)
- elm_object_part_content_set(parent, part, btn);
- if (text)
- elm_object_text_set(btn, text);
- if (style)
- elm_object_style_set(btn, style);
-
- evas_object_show(btn);
-
- return btn;
-}
-
-Evas_Object *utils_add_gengrid(Evas_Object *parent, Eina_Bool horizontal,
- int width, int height)
-{
- Evas_Object *grid;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- grid = elm_gengrid_add(parent);
- if (!grid) {
- _ERR("elm_gengrid_add failed.");
- return NULL;
- }
-
- evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- elm_gengrid_multi_select_set(grid, EINA_FALSE);
- elm_gengrid_horizontal_set(grid, horizontal);
- elm_gengrid_align_set(grid, 0.0, 0.0);
- elm_gengrid_select_mode_set(grid, ELM_OBJECT_SELECT_MODE_ALWAYS);
- elm_gengrid_item_size_set(grid, ELM_SCALE_SIZE(width),
- ELM_SCALE_SIZE(height));
- elm_scroller_policy_set(grid, ELM_SCROLLER_POLICY_OFF,
- ELM_SCROLLER_POLICY_OFF);
-
- return grid;
-}
-
-Evas_Object *utils_add_table(Evas_Object *parent, const char *part,
- int padding_x, int padding_y)
-{
- Evas_Object *table;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- table = elm_table_add(parent);
- if (!table) {
- _ERR("elm_table_add failed.");
- return NULL;
- }
-
- elm_table_padding_set(table, ELM_SCALE_SIZE(padding_x),
- ELM_SCALE_SIZE(padding_y));
- evas_object_show(table);
-
- if (part)
- elm_object_part_content_set(parent, part, table);
-
- return table;
-}
-
-static void _notify_timeout_cb(void *data, Evas_Object *obj, void *ei)
-{
- if (!obj)
+ if (id == NULL)
return;
- evas_object_del(obj);
-}
-
-Evas_Object *utils_add_notify(Evas_Object *parent, const char *text,
- const char *noti_style, const char *label_style, int timeout)
-{
- Evas_Object *notify, *lbl;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- notify = elm_notify_add(parent);
- if (!notify) {
- _ERR("elm_notify_add failed.");
- return NULL;
- }
-
- evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_notify_align_set(notify, 0.0, 1.0);
- elm_notify_timeout_set(notify, timeout);
-
- if (noti_style)
- elm_object_style_set(notify, noti_style);
-
- lbl = elm_label_add(notify);
- if (!lbl) {
- _ERR("elm_label_add failed.");
- evas_object_del(notify);
- return NULL;
- }
-
- elm_object_content_set(notify, lbl);
- evas_object_show(lbl);
-
- if (label_style)
- elm_object_style_set(lbl, label_style);
-
- if (text)
- elm_object_text_set(lbl, text);
+ SAFE_FREE_CHAR(id->selected_item_fullpath);
+ SAFE_FREE_CHAR(id->parent_path);
+ SAFE_FREE_CHAR(id->name);
+ SAFE_FREE_CHAR(id->file_size);
+ SAFE_FREE_CHAR(id->time);
- evas_object_smart_callback_add(notify, SIG_TIMEOUT,
- _notify_timeout_cb, NULL);
- evas_object_show(notify);
-
- return notify;
+ return;
}
-void utils_show_submenu_popup(struct _priv *priv)
+void util_free_util_item_data_s(util_item_data_s *uid)
{
- if (priv == NULL) {
- _ERR("priv is null. failed to show submenu popup");
+ if (uid == NULL)
return;
- }
-
- Evas_Object *notification_popup;
- Evas_Object *window_layout = NULL;
- Evas_Object *genlist;
-
- util_item_data_s *id;
-
- Evas *e = NULL;
- Ecore_Evas *ee = NULL;
- Eina_Bool result = EINA_FALSE;
- int screen_x, screen_y, screen_w, screen_h;
-
- notification_popup = elm_win_add(NULL, "notification_popup", ELM_WIN_BASIC);
- priv->popup_win = notification_popup;
-
- if (notification_popup == NULL) {
- _ERR("elm_win_add failed");
- goto out;
- }
-
- e = evas_object_evas_get(notification_popup);
- if (!e) {
- _ERR("evas_object_evas_get failed");
- evas_object_del(notification_popup);
- notification_popup = NULL;
- goto out;
- }
-
- ee = ecore_evas_ecore_evas_get(e);
- if (!ee) {
- _ERR("ecore_evas_ecore_evas_get failed");
- evas_object_del(notification_popup);
- notification_popup = NULL;
- goto out;
- }
-
- elm_win_alpha_set(notification_popup, EINA_TRUE);
- elm_win_borderless_set(notification_popup, EINA_TRUE);
- elm_win_autodel_set(notification_popup, EINA_TRUE);
- elm_win_screen_size_get(notification_popup, &screen_x, &screen_y, &screen_w, &screen_h);
+ SAFE_FREE_CHAR(uid->folder_name);
+ SAFE_FREE_CHAR(uid->parent_path);
+ SAFE_FREE_CHAR(uid->new_folder_name);
- window_layout = elm_layout_add(notification_popup);
- result = elm_layout_file_set(window_layout, EDJEFILE, GRP_VIEW_SUBMENU);
- _DBG("Layout elm_layout_file_set for [%s] returns [%d]", EDJEFILE, result);
- evas_object_resize(window_layout, screen_w, screen_h);
- evas_object_show(window_layout);
-
- genlist = elm_genlist_add(window_layout);
- elm_object_part_content_set(window_layout, "submenu_genlist", genlist);
- elm_object_scale_set(genlist, 1/edje_scale_get());
- elm_object_focus_allow_set(genlist, EINA_TRUE);
-
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- itc->item_style = "custom_1text";
- itc->func.text_get = _folder_list_label_get;
- itc->func.del = _folder_list_del;
-
- int i;
- for (i = 0; i < 6; i++) {
- id = calloc(1, sizeof(util_item_data_s));
- id->index = i;
-
- elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- }
-
- elm_genlist_item_class_free(itc);
- evas_object_show(genlist);
-
- elm_object_item_focus_set(elm_genlist_first_item_get(genlist), EINA_TRUE);
- evas_object_smart_callback_add(genlist, "item,focused", _item_focus_cb, "item,focused");
- evas_object_smart_callback_add(genlist, "item,unfocused", _item_focus_cb, "item,unfocused");
- inputmgr_add_callback(genlist, 0, &popup_handler, priv);
-
- evas_object_show(notification_popup);
- elm_win_activate(notification_popup);
-
-out:
- return;
+ return;
}
-void utils_show_select_folder_popup(struct _priv *priv)
+void util_free_path_item_data_s(path_item_data_s *pid)
{
- if (priv == NULL) {
- _ERR("priv is null. Failed to show select folder popup");
+ if (pid == NULL)
return;
- }
-
- Evas_Object *notification_popup;
- Evas_Object *window_layout = NULL;
- Evas_Object *ok_btn, *cancel_btn, *new_folder_btn;
- Evas_Object *genlist;
-
- Elm_Object_Item *it = NULL;
-
- util_item_data_s *id;
- list_data_s *list_data = calloc(1, sizeof(list_data_s));
-
- char *path = NULL;
- fsNodeInfo *node = NULL;
-
- int screen_x, screen_y, screen_w, screen_h;
-
- notification_popup = elm_win_add(NULL, "notification_popup", ELM_WIN_BASIC);
- priv->popup_win = notification_popup;
-
- elm_win_screen_size_get(notification_popup, &screen_x, &screen_y, &screen_w, &screen_h);
-
- elm_win_alpha_set(notification_popup, EINA_TRUE);
- elm_win_borderless_set(notification_popup, EINA_TRUE);
- elm_win_autodel_set(notification_popup, EINA_TRUE);
-
- window_layout = elm_layout_add(notification_popup);
- elm_layout_file_set(window_layout, EDJEFILE, GRP_VIEW_SELECT_FOLDER);
- evas_object_resize(window_layout, screen_w, screen_h);
- evas_object_show(window_layout);
-
- ok_btn = elm_button_add(window_layout);
- elm_object_style_set(ok_btn, STYLE_TARGET_BTN);
- elm_object_focus_allow_set(ok_btn, EINA_TRUE);
- elm_object_part_content_set(window_layout, "select_folder_ok_btn", ok_btn);
- elm_object_part_text_set(ok_btn, "part_popup_btn_text", "OK");
- evas_object_show(ok_btn);
-
- cancel_btn = elm_button_add(window_layout);
- elm_object_style_set(cancel_btn, STYLE_TARGET_BTN);
- elm_object_focus_allow_set(cancel_btn, EINA_TRUE);
- elm_object_part_content_set(window_layout, "select_folder_cancel_btn", cancel_btn);
- elm_object_part_text_set(cancel_btn, "part_popup_btn_text", "Cancel");
- evas_object_show(cancel_btn);
-
- new_folder_btn = elm_button_add(window_layout);
- elm_object_style_set(new_folder_btn, STYLE_TARGET_BTN);
- elm_object_focus_allow_set(new_folder_btn, EINA_TRUE);
- elm_object_part_content_set(window_layout, "select_folder_newfolder_btn", new_folder_btn);
- elm_object_part_text_set(new_folder_btn, "part_popup_btn_text", "New Folder");
- evas_object_show(new_folder_btn);
-
- elm_object_focus_next_object_set(ok_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(cancel_btn, ok_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, new_folder_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(new_folder_btn, cancel_btn, ELM_FOCUS_LEFT);
-
- genlist = elm_genlist_add(window_layout);
- elm_object_part_content_set(window_layout, "select_folder_genlist", genlist);
- elm_object_scale_set(genlist, 1/edje_scale_get());
- elm_object_focus_allow_set(genlist, EINA_TRUE);
-
- path = Get_Root_Path(STORAGE_TYPE_INTERNAL);
- if (path == NULL)
- list_data->path = NULL;
- else
- list_data->path = path;
-
- int ret = mf_fs_oper_read_dir(list_data->path, &list_data->folder_list, &list_data->file_list);
- if (ret != MYFILE_ERR_NONE) {
- _ERR("failed read dir. ret : %d", ret);
- SAFE_FREE_CHAR(path);
- mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
- mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
- free(list_data);
- list_data = NULL;
-
- evas_object_del(notification_popup);
- notification_popup = NULL;
- return;
- }
-
- list_data->file_count = eina_list_count(list_data->file_list);
- list_data->folder_count = eina_list_count(list_data->folder_list);
-
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- itc->item_style = "custom_file_target";
- itc->func.text_get = _folder_list_label_get;
- itc->func.content_get = _folder_list_content_get;
- itc->func.del = _folder_list_del;
-
- int i;
- for (i = 0; i < list_data->folder_count; i++) {
- id = calloc(1, sizeof(util_item_data_s));
- id->index = i;
-
- node = _get_fsNodeInfo(list_data->folder_list, id->index);
- if (node->name == NULL)
- id->folder_name = NULL;
- else
- id->folder_name = strdup(node->name);
-
- SAFE_FREE_CHAR(node->name);
- it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _item_selected_cb, NULL);
- id->item = it;
- }
-
- elm_genlist_item_class_free(itc);
- evas_object_show(genlist);
-
- inputmgr_add_callback(notification_popup, 0, &popup_handler, priv);
-
- inputmgr_add_callback(genlist, 0, &genlist_handler, priv);
- evas_object_smart_callback_add(genlist, "item,focused", _item_focus_cb, "item,focused");
- evas_object_smart_callback_add(genlist, "item,unfocused", _item_focus_cb, "item,unfocused");
-
- inputmgr_add_callback(ok_btn, 0, &focus_handler, priv);
- inputmgr_add_callback(cancel_btn, 0, &focus_handler, priv);
- inputmgr_add_callback(new_folder_btn, 0, &focus_handler, priv);
-
- evas_object_smart_callback_add(cancel_btn, "clicked", _down_btn_cb, priv);
-
- evas_object_show(notification_popup);
- elm_win_activate(notification_popup);
- mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
- mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
- free(list_data);
- list_data = NULL;
+ SAFE_FREE_CHAR(pid->full_path);
+ SAFE_FREE_CHAR(pid->parent_path);
return;
}
diff --git a/src/view/base.c b/src/view/base.c
index 163c66c..472c51f 100755
--- a/src/view/base.c
+++ b/src/view/base.c
@@ -19,8 +19,6 @@
#include <viewmgr.h>
#include <inputmgr.h>
#include <layoutmgr.h>
-#include <app_contents.h>
-#include <app_define.h>
#include <app_debug.h>
#include "define.h"
@@ -28,12 +26,12 @@
#include "layout.h"
#include "data.h"
#include "util/utils.h"
-#include "util/dialog_popup.h"
#include "util/file-util.h"
-#include "util/fs-util.h"
-#include "util/fs-error.h"
+#include "view/submenu_view.h"
+#include "view/select_folder_view.h"
#define STYLE_MENU_BTN "menu_btn"
+#define STYLE_MENU_BTN_TEXT "menu_btn_text"
struct _menu_item {
const char *name;
@@ -49,59 +47,75 @@ static struct _menu_item g_menu_item[E_LAYOUT_MAX] = {
}
};
-static void
-gengrid_it_cb(void *data, Evas_Object *obj, void *event_info)
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev)
{
- if (event_info == NULL) {
- _ERR("event_info is null. failed gengrid_it_cb");
+ if (data == NULL) {
+ _ERR("data is null. failed to _key_up_cb.");
return;
}
- if (obj == NULL) {
- _ERR("obj is null. failed gengrid_it_cb");
- return;
+
+ struct _priv *priv = (struct _priv *)data;
+
+ if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_ESC)) {
+ if (evas_object_visible_get(priv->confirm_btn) == EINA_TRUE)
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
+ else
+ ui_app_exit();
}
- if (data == NULL) {
- _ERR("data is null. failed gengrid_it_cb");
+
+ return;
+}
+
+static input_handler _menu_input_handler = {
+ .key_up = _key_up_cb
+};
+
+static void
+_path_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (event_info == NULL || obj == NULL || data == NULL) {
+ _ERR("parameters are wrong. failed _path_item_selected_cb");
return;
}
struct _priv *priv = (struct _priv *)data;
+ if (evas_object_visible_get(priv->confirm_btn) == EINA_TRUE)
+ return;
+
int index, count, i;
- Elm_Object_Item *next_it = NULL, *deleted_it = NULL;
+ Elm_Object_Item *deleted_it = NULL;
Elm_Object_Item *selected_it = (Elm_Object_Item *)event_info;
path_item_data_s *pid = (path_item_data_s *)elm_object_item_data_get(selected_it);
+ path_item_data_s *pid_del = NULL;
priv->list_index = pid->list_index;
count = elm_gengrid_items_count(obj);
- if (count == 1) {
- layoutmgr_update_layout(priv->lmgr, g_menu_item[E_LAYOUT_DEFAULT].layout_id,
- UPDATE_FILE_LIST, priv);
- return;
- }
-
index = elm_gengrid_item_index_get(selected_it);
- next_it = elm_gengrid_item_next_get(selected_it);
- deleted_it = next_it;
- if (deleted_it == NULL) {
- return;
- }
+ if (count == 1)
+ goto out;
for (i = 0; i < count-index; i++) {
- next_it = elm_gengrid_item_next_get(deleted_it);
+ deleted_it = elm_gengrid_last_item_get(obj);
+ pid_del = (path_item_data_s *)elm_object_item_data_get(deleted_it);
+ if (pid_del != NULL) {
+ util_free_path_item_data_s(pid_del);
+ free(pid_del);
+ pid_del = NULL;
+ }
elm_object_item_del(deleted_it);
- deleted_it = next_it;
}
+out:
layoutmgr_update_layout(priv->lmgr, g_menu_item[E_LAYOUT_DEFAULT].layout_id,
UPDATE_FILE_LIST, priv);
return;
}
-static char*
-_gengrid_text_get_cb(void *data, Evas_Object *obj, const char *part)
+static char* _path_text_get_cb(void *data, Evas_Object *obj, const char *part)
{
if (data == NULL) {
_ERR("data is null. failed get text");
@@ -118,8 +132,7 @@ _gengrid_text_get_cb(void *data, Evas_Object *obj, const char *part)
if (pid->selected_folder == NULL) {
_ERR("pid->selected_folder is null.");
return NULL;
- }
- else
+ } else
snprintf(buf, 1023, "%s", pid->selected_folder);
}
@@ -129,11 +142,10 @@ _gengrid_text_get_cb(void *data, Evas_Object *obj, const char *part)
return NULL;
}
-static Evas_Object*
-create_gengrid(struct _priv *priv)
+static Evas_Object* create_path(struct _priv *priv)
{
if (priv == NULL) {
- _ERR("priv is null. failed to create_gengrid");
+ _ERR("priv is null. failed to create_path");
return NULL;
}
@@ -158,24 +170,23 @@ create_gengrid(struct _priv *priv)
priv->selected_parent_path = Get_Root_Path(STORAGE_TYPE_INTERNAL);
if (priv->selected_parent_path == NULL) {
- _ERR("priv->selected_parent_path is null. failed to create_gengrid");
+ _ERR("priv->selected_parent_path is null. failed to create_path");
return NULL;
}
gic = elm_gengrid_item_class_new();
gic->item_style = "custom_1text";
-
- gic->func.text_get = _gengrid_text_get_cb;
+ gic->func.text_get = _path_text_get_cb;
pid = calloc(1, sizeof(path_item_data_s));
pid->index = 0;
pid->parent_path = strdup(priv->selected_parent_path);
- pid->selected_folder = "HOME";
- pid->full_path = strdup(priv->selected_parent_path);
+ pid->selected_folder = "Home";
pid->list_index = 0;
+ pid->level = 0;
- item = elm_gengrid_item_append(gengrid, gic, pid, gengrid_it_cb, priv);
+ item = elm_gengrid_item_append(gengrid, gic, pid, _path_item_selected_cb, priv);
if (item == NULL) {
_ERR("item is null. Failed elm_gengrid_item_append");
@@ -186,8 +197,6 @@ create_gengrid(struct _priv *priv)
}
pid->item = item;
- mf_file_attr_get_path_level(pid->parent_path, &pid->level);
-
elm_object_item_data_set(item, pid);
evas_object_show(gengrid);
@@ -196,8 +205,7 @@ create_gengrid(struct _priv *priv)
return gengrid;
}
-static void
-update_gengrid(void *data)
+static void update_path(void *data)
{
if (data == NULL) {
_ERR("data is null, failed to update gengrid");
@@ -211,7 +219,6 @@ update_gengrid(void *data)
Elm_Gengrid_Item_Class *gic = NULL;
Elm_Object_Item *item = NULL, *delete = NULL;
- int buffer_size;
char *new_path;
Evas_Object *file_path = NULL;
@@ -227,18 +234,10 @@ update_gengrid(void *data)
return;
}
- if (priv->selected_parent_path == NULL || priv->selected_folder == NULL) {
- _ERR("selected_parent_path or selected_folder is null. failed to update gengrid");
- return;
- }
+ new_path = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
- buffer_size = strlen(priv->selected_parent_path)+strlen("/")+strlen(priv->selected_folder);
- new_path = (char *)calloc(buffer_size+1, sizeof(char));
- snprintf(new_path, buffer_size+1, "%s/%s", priv->selected_parent_path, priv->selected_folder);
-
- if(new_path == NULL) {
+ if (new_path == NULL) {
_ERR("new_path is null. failed to update gengrid");
- SAFE_FREE_CHAR(new_path);
return;
}
@@ -254,10 +253,9 @@ update_gengrid(void *data)
elm_object_item_del(delete);
}
- } else if (priv->same < 0) {
+ } else if (priv->same == 0 && priv->diff != 0) {
int i;
- int num = priv->same * (-1);
- for (i = 0; i <= num; i++) {
+ for (i = 0; i <= priv->diff; i++) {
delete = elm_gengrid_last_item_get(file_path);
if (delete != NULL) {
pid_del = (path_item_data_s *)elm_object_item_data_get(delete);
@@ -273,11 +271,15 @@ update_gengrid(void *data)
gic = elm_gengrid_item_class_new();
gic->item_style = "custom_1text";
-
- gic->func.text_get = _gengrid_text_get_cb;
+ gic->func.text_get = _path_text_get_cb;
pid = calloc(1, sizeof(path_item_data_s));
- pid->selected_folder = priv->selected_folder;
+ if (pid == NULL) {
+ _ERR("pid is NULL. failed to allocate memory.");
+ return;
+ }
+
+ pid->selected_folder = strdup(priv->selected_folder);
pid->parent_path = strdup(priv->selected_parent_path);
pid->index = elm_gengrid_items_count(file_path);
pid->full_path = strdup(new_path);
@@ -288,19 +290,18 @@ update_gengrid(void *data)
util_free_path_item_data_s(pid);
free(pid);
pid = NULL;
- SAFE_FREE_CHAR(new_path);
- return;
+ goto out;
}
mf_file_attr_get_path_level(pid->full_path, &pid->level);
- item = elm_gengrid_item_append(file_path, gic, pid, gengrid_it_cb, priv);
+
+ item = elm_gengrid_item_append(file_path, gic, pid, _path_item_selected_cb, priv);
if (item == NULL) {
_ERR("item is null. Failed elm_gengrid_item_append");
util_free_path_item_data_s(pid);
free(pid);
pid = NULL;
- SAFE_FREE_CHAR(new_path);
- return;
+ goto out;
}
pid->item = item;
@@ -308,10 +309,7 @@ update_gengrid(void *data)
evas_object_show(file_path);
elm_gengrid_item_class_free(gic);
- if (pid_del != NULL) {
- free(pid_del);
- pid_del = NULL;
- }
+out:
SAFE_FREE_CHAR(new_path);
return;
}
@@ -326,6 +324,9 @@ static void _menu_cb(void *data, Evas_Object *obj, void *event_info)
struct _priv *priv = (struct _priv *)data;
+ if (evas_object_visible_get(priv->confirm_btn) == EINA_TRUE)
+ return;
+
Elm_Object_Item *item = NULL;
if (priv->base == NULL) {
@@ -362,7 +363,7 @@ static void _menu_cb(void *data, Evas_Object *obj, void *event_info)
utils_show_submenu_popup(priv);
}
-static void _menu_cb2(void *data, Evas_Object *obj, void *event_info)
+static void _confirm_cb(void *data, Evas_Object *obj, void *event_info)
{
if (data == NULL) {
_ERR("data is null. failed menu_cb2");
@@ -370,10 +371,56 @@ static void _menu_cb2(void *data, Evas_Object *obj, void *event_info)
}
struct _priv *priv = (struct _priv *)data;
- priv->popup_base = obj;
Elm_Object_Item *item;
+ Evas_Object *file_list_obj = elm_object_part_content_get(priv->layout, PART_FILE_LIST);
+ Eina_List *total_list = NULL;
+ Eina_List *l = NULL;
+ Elm_Object_Item *selected_item = NULL;
+ item_data_s *selected_id = NULL;
+
+ if (file_list_obj == NULL) {
+ _ERR("file_list_obj is null. failed to _confirm_cb");
+ return;
+ }
+
+ total_list = elm_genlist_realized_items_get(file_list_obj);
+
+ EINA_LIST_FOREACH(total_list, l, selected_item) {
+ if (elm_genlist_item_selected_get(selected_item)) {
+ selected_id = (item_data_s *)elm_object_item_data_get(selected_item);
+ break;
+ }
+ }
+
+ if (selected_id == NULL) {
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_NOTIFY_NO_CLOSE, NULL, "Please select item.", "OK", NULL, priv);
+
+ return;
+ }
+
+ priv->selected_folder = selected_id->name;
+ priv->selected_parent_path = selected_id->selected_item_fullpath;
+
+ switch (priv->submenu_index) {
+ case SUBMENU_COPY:
+ case SUBMENU_MOVE:
+ utils_show_select_folder_popup(priv);
+ return;
+ case SUBMENU_RENAME:
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_INPUT_NAME, "Rename", "rename1", "OK", "Cancel", priv);
+ return;
+ case SUBMENU_DELETE:
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_YES_OR_CANCEL, NULL, "Delete?", "OK", "Cancel", priv);
+ return;
+ case SUBMENU_NEW_FOLDER:
+ case SUBMENU_SETTING:
+ break;
+ default:
+ return;
+ }
+
Evas_Object *file_path = elm_object_part_content_get(priv->base, PART_FILE_PATH);
item = elm_gengrid_last_item_get(file_path);
@@ -389,78 +436,64 @@ static void _menu_cb2(void *data, Evas_Object *obj, void *event_info)
else
priv->selected_parent_path = pid->parent_path;
+ priv->after_input_folder_name = 0;
utils_show_select_folder_popup(priv);
}
-static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Up *ev)
-{
- if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_ESC))
- ui_app_exit();
-
- return;
-}
-
-static input_handler _menu_input_handler = {
- .key_up = _key_up_cb
-};
-
-static bool _draw_menu(struct _priv *priv)
+static bool _draw_menu_btn(struct _priv *priv)
{
if (priv == NULL) {
_ERR("priv is null. failed draw menu");
return false;
}
- Evas_Object *icon = elm_button_add(priv->base);
+ Evas_Object *menu_btn = elm_button_add(priv->base);
- elm_object_style_set(icon, STYLE_MENU_BTN);
- elm_object_part_content_set(priv->base, PART_MENU, icon);
- evas_object_resize(icon, 46, 46);
- evas_object_show(icon);
- elm_object_focus_allow_set(icon, EINA_TRUE);
+ elm_object_style_set(menu_btn, STYLE_MENU_BTN);
+ elm_object_part_content_set(priv->base, PART_MENU, menu_btn);
+ evas_object_resize(menu_btn, 46, 46);
+ evas_object_show(menu_btn);
+ elm_object_focus_allow_set(menu_btn, EINA_TRUE);
- Evas_Object *icon2 = elm_button_add(priv->base);
+ Evas_Object *confirm_btn = elm_button_add(priv->base);
- elm_object_style_set(icon2, STYLE_MENU_BTN);
- elm_object_part_content_set(priv->base, PART_CONFIRM, icon2);
- evas_object_resize(icon2, 46, 46);
- elm_object_focus_allow_set(icon2, EINA_TRUE);
+ elm_object_style_set(confirm_btn, STYLE_MENU_BTN_TEXT);
+ elm_object_part_content_set(priv->base, PART_CONFIRM, confirm_btn);
+ evas_object_resize(confirm_btn, 46, 46);
+ elm_object_focus_allow_set(confirm_btn, EINA_TRUE);
- priv->icon1 = icon;
- priv->icon2 = icon2;
+ priv->confirm_btn = confirm_btn;
- evas_object_smart_callback_add(icon, "clicked", _menu_cb, priv);
- evas_object_smart_callback_add(icon2, "clicked", _menu_cb2, priv);
+ evas_object_smart_callback_add(menu_btn, "clicked", _menu_cb, priv);
+ evas_object_smart_callback_add(confirm_btn, "clicked", _confirm_cb, priv);
Evas_Object *path = elm_object_part_content_get(priv->base, PART_FILE_PATH);
- elm_object_focus_next_object_set(path, icon, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(icon, path, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(icon, icon2, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(icon2, icon, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(path, menu_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(menu_btn, path, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(menu_btn, confirm_btn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(confirm_btn, menu_btn, ELM_FOCUS_RIGHT);
return true;
}
static bool _draw_file_path(struct _priv *priv)
{
- Evas_Object *gengrid = NULL;
+ Evas_Object *file_path = NULL;
if (priv == NULL) {
_ERR("priv is null. failed draw file path");
return false;
}
- gengrid = create_gengrid(priv);
+ file_path = create_path(priv);
- if (gengrid == NULL) {
- _ERR("gengrid is null. failed draw file path");
+ if (file_path == NULL) {
+ _ERR("file_path is null. failed draw file path");
return false;
}
- evas_object_show(gengrid);
- elm_object_part_content_set(priv->base, PART_FILE_PATH, gengrid);
+ evas_object_show(file_path);
+ elm_object_part_content_set(priv->base, PART_FILE_PATH, file_path);
return true;
}
@@ -474,7 +507,7 @@ static bool _draw_view_content(struct _priv *priv)
_ERR("Draw file path failed.");
return false;
}
- if (!_draw_menu(priv)) {
+ if (!_draw_menu_btn(priv)) {
_ERR("Draw menu failed.");
return false;
}
@@ -594,7 +627,7 @@ static void _update(void *view_data, int update_type, void *data)
break;
case UPDATE_PATH:
- update_gengrid(priv);
+ update_path(priv);
break;
default:
@@ -614,8 +647,12 @@ static void _destroy(void *data)
}
priv = data;
+ if (priv->win)
+ evas_object_del(priv->win);
if (priv->base)
evas_object_del(priv->base);
+ if (priv->layout)
+ evas_object_del(priv->layout);
free(priv);
}
diff --git a/src/view/dialog_popup.c b/src/view/dialog_popup.c
new file mode 100755
index 0000000..161749e
--- /dev/null
+++ b/src/view/dialog_popup.c
@@ -0,0 +1,405 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <Elementary.h>
+#include <viewmgr.h>
+#include <inputmgr.h>
+#include <layoutmgr.h>
+#include <app_debug.h>
+
+#include "define.h"
+#include "view.h"
+#include "data.h"
+#include "util/utils.h"
+#include "util/file-util.h"
+#include "util/fs-error.h"
+#include "view/select_folder_view.h"
+#include "view/dialog_popup.h"
+#include "view/submenu_view.h"
+
+#define STYLE_TARGET_BTN "target_btn"
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev);
+static input_handler popup_handler = {
+ .key_up = _key_up_cb
+};
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev)
+{
+ if (!data)
+ return;
+
+ struct _priv *priv;
+ priv = (struct _priv *)data;
+
+ if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_ESC)) {
+ inputmgr_remove_callback(priv->popup_win, &popup_handler);
+ evas_object_del(priv->popup_win);
+
+ if (priv->popup_info)
+ free(priv->popup_info);
+ }
+}
+static void _item_focus_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (data == NULL)
+ return;
+
+ char *signal = NULL;
+ signal = (char *)data;
+
+ if (!strcmp(signal, "item,focused"))
+ elm_object_item_signal_emit(event_info, "mouse,in", "elm");
+ else if (!strcmp(signal, "item,unfocused"))
+ elm_object_item_signal_emit(event_info, "mouse,out", "elm");
+
+ return;
+}
+
+static void _rename_file(struct _priv *priv)
+{
+ if (priv == NULL) {
+ _ERR("priv is null. failed to rename file");
+ return;
+ }
+
+ char *src = NULL, *dst = NULL, *dst_f = NULL, *ext = NULL;
+
+ src = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
+ dst = utils_get_combined_string(priv->selected_parent_path, priv->new_folder_name, NULL);
+
+ mf_file_attr_get_file_ext(src, &ext);
+
+ if (strcmp(src, ext))
+ dst_f = utils_get_combined_string(dst, ext, NULL);
+
+ if (mf_fs_oper_rename_file(src, dst_f) != MYFILE_ERR_NONE) {
+ _ERR("error is occured. failed to rename file");
+ goto out;
+ }
+
+out:
+ SAFE_FREE_CHAR(src);
+ SAFE_FREE_CHAR(dst);
+ SAFE_FREE_CHAR(dst_f);
+ SAFE_FREE_CHAR(ext);
+
+ return;
+}
+
+static void _down_btn1_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (data == NULL) {
+ _ERR("data is null. failed select popup menu");
+ return;
+ }
+
+ struct _priv *priv;
+ priv = (struct _priv *)data;
+
+ if (priv->popup_info == NULL)
+ return;
+
+ if (priv->popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_INPUT_NAME) {
+ const char *entry_content = NULL;
+ entry_content = elm_entry_entry_get(priv->popup_info->entry);
+
+ if (entry_content == NULL)
+ _ERR("entry is null");
+ else {
+ priv->new_folder_name = strdup(entry_content);
+ priv->after_input_folder_name = 1;
+ }
+
+ if (priv->submenu_index == SUBMENU_RENAME) {
+ _rename_file(priv);
+ goto out;
+ }
+ } else if (priv->popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_CONFIGURATION) {
+ Evas_Object *check = elm_object_part_content_get(priv->popup_layout, "part_content_swallow");
+ Eina_Bool state = elm_check_state_get(check);
+
+ if (state == EINA_TRUE)
+ mf_util_set_hidden_state(FILE_HIDDEN_SHOW);
+ else
+ mf_util_set_hidden_state(FILE_HIDDEN_HIDE);
+ } else if (priv->popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_NOTIFY_NO_CLOSE)
+ goto out_2;
+ else {
+ if (priv->submenu_index == SUBMENU_DELETE) {
+ char *full_path = NULL;
+
+ full_path = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
+
+ if (mf_remove(full_path))
+ _DBG("file is deleted");
+ else {
+ dialog_popup_info_t *info = calloc(1, sizeof(dialog_popup_info_t));
+
+ info->dialog_popup_type = DIALOG_POPUP_TYPE_NOTIFY;
+ info->content = "Failed to delete file.";
+ info->button_1_text = "OK";
+ info->data = priv;
+
+ dialog_popup_create(info);
+ _ERR("Failed to delete file.");
+ }
+ SAFE_FREE_CHAR(full_path);
+ }
+ }
+
+out:
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
+
+out_2:
+ if (priv->popup_info)
+ free(priv->popup_info);
+
+ evas_object_del(priv->popup_win);
+ evas_object_del(priv->popup_layout);
+
+ return;
+}
+
+static void _down_btn2_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!data)
+ return;
+
+ struct _priv *priv;
+ priv = (struct _priv *)data;
+
+ evas_object_del(priv->popup_win);
+
+ if (priv->submenu_index >= SUBMENU_RENAME && priv->submenu_index <= SUBMENU_SETTING)
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
+
+ if (priv->popup_info)
+ free(priv->popup_info);
+}
+
+Evas_Object *dialog_popup_create(dialog_popup_info_t *dialog_popup_info)
+{
+ Evas_Object *dialog_popup = NULL;
+ Evas_Object *window_layout = NULL;
+ Evas_Object *button_1 = NULL, *button_2 = NULL;
+ Evas_Object *content_label = NULL;
+ Evas_Object *content_check = NULL;
+ Evas_Object *content_entry = NULL;
+ Evas *e = NULL;
+ Ecore_Evas *ee = NULL;
+ Eina_Bool result = EINA_FALSE;
+
+ char *content = NULL;
+ int screen_x = 0, screen_y = 0, screen_w = 0, screen_h = 0;
+
+ if (dialog_popup_info == NULL) {
+ _ERR("dialog_popup_info is null");
+ goto out;
+ }
+
+ if (dialog_popup_info->data == NULL) {
+ _ERR("dialog_popup_info->data is null");
+ goto out;
+ }
+
+ struct _priv *priv;
+ priv = (struct _priv *)dialog_popup_info->data;
+
+ /* Creating a Notification Window */
+ dialog_popup = elm_win_add(NULL, "dialog_popup", ELM_WIN_BASIC);
+
+ if (dialog_popup == NULL) {
+ _ERR("elm_win_add failed");
+ goto out;
+ }
+
+ e = evas_object_evas_get(dialog_popup);
+ if (!e) {
+ _ERR("evas_object_evas_get failed");
+ evas_object_del(dialog_popup);
+ dialog_popup = NULL;
+ goto out;
+ }
+
+ ee = ecore_evas_ecore_evas_get(e);
+ if (!ee) {
+ _ERR("ecore_evas_ecore_evas_get failed");
+ evas_object_del(dialog_popup);
+ dialog_popup = NULL;
+ goto out;
+ }
+
+ priv->popup_win = dialog_popup;
+
+ elm_win_alpha_set(dialog_popup, EINA_TRUE);
+ elm_win_borderless_set(dialog_popup, EINA_TRUE);
+ elm_win_autodel_set(dialog_popup, EINA_TRUE);
+
+ elm_win_screen_size_get(dialog_popup, &screen_x, &screen_y, &screen_w, &screen_h);
+ evas_object_resize(dialog_popup, screen_w, screen_h);
+
+ /* Layout */
+ window_layout = elm_layout_add(dialog_popup);
+ if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_YES_OR_CANCEL)
+ result = elm_layout_file_set(window_layout, EDJEFILE, GRP_DIALOG_POPUP_NO_TITLE);
+ else if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_NOTIFY ||
+ dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_NOTIFY_NO_CLOSE)
+ result = elm_layout_file_set(window_layout, EDJEFILE, GRP_DIALOG_POPUP_NO_TITLE_ONE_BTN);
+ else if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_CONFIGURATION)
+ result = elm_layout_file_set(window_layout, EDJEFILE, GRP_DIALOG_POPUP_SETTING);
+ else
+ result = elm_layout_file_set(window_layout, EDJEFILE, GRP_DIALOG_POPUP);
+
+ _DBG("Layout elm_layout_file_set for [%s] returns [%d]", EDJEFILE, result);
+ evas_object_resize(window_layout, screen_w, screen_h);
+ evas_object_show(window_layout);
+
+ priv->popup_layout = window_layout;
+
+ if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_INPUT_NAME) {
+ content_entry = elm_entry_add(window_layout);
+
+ if (dialog_popup_info->title)
+ elm_object_part_text_set(window_layout, "part_title_label", dialog_popup_info->title);
+
+ if (content_entry == NULL) {
+ _ERR("elm_entry_add failed");
+ goto out;
+ }
+
+ elm_object_part_content_set(window_layout, "part_content_swallow", content_entry);
+ elm_entry_single_line_set(content_entry, EINA_TRUE);
+ elm_entry_editable_set(content_entry, EINA_TRUE);
+
+ if (dialog_popup_info->content)
+ elm_object_part_text_set(content_entry, "guide", dialog_popup_info->content);
+
+ dialog_popup_info->entry = content_entry;
+ evas_object_show(content_entry);
+ } else if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_CONFIGURATION) {
+ if (dialog_popup_info->title)
+ elm_object_part_text_set(window_layout, "part_title_label", dialog_popup_info->title);
+
+ content_check = elm_check_add(window_layout);
+ if (content_check == NULL) {
+ _ERR("elm_check_add failed");
+ goto out;
+ }
+
+ int hidden_value;
+ mf_util_get_hidden_state(&hidden_value);
+
+ if (hidden_value == FILE_HIDDEN_SHOW)
+ elm_check_state_set(content_check, EINA_TRUE);
+ else
+ elm_check_state_set(content_check, EINA_FALSE);
+
+ if (dialog_popup_info->content)
+ elm_object_part_text_set(window_layout, "part_content_text", dialog_popup_info->content);
+ else
+ elm_object_part_text_set(window_layout, "part_content_text", " Show hidden files");
+
+ elm_object_part_content_set(window_layout, "part_content_swallow", content_check);
+ evas_object_show(content_check);
+
+ evas_object_smart_callback_add(content_check, "item,focused", _item_focus_cb, "item,focused");
+ evas_object_smart_callback_add(content_check, "item,unfocused", _item_focus_cb, "item,unfocused");
+
+ elm_object_focus_next_object_set(button_1, content_check, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(content_check, button_1, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(button_2, content_check, ELM_FOCUS_UP);
+
+ } else if (dialog_popup_info->dialog_popup_type == DIALOG_POPUP_TYPE_YES_OR_CANCEL) {
+ if (dialog_popup_info->content)
+ elm_object_part_text_set(window_layout, "part_content_swallow", dialog_popup_info->content);
+ else
+ elm_object_part_text_set(window_layout, "part_content_swallow", "Delete?");
+ } else {
+ int content_len = 0;
+ int buffer_size = 0;
+ const char *start_tag = "<font=BreezeSans:style=Light color=#686868 align=left left_margin=20 font_size=28>";
+ const char *end_tag = "</font>";
+
+ content_label = elm_label_add(window_layout);
+
+ if (content_label == NULL) {
+ _ERR("elm_label_add failed");
+ goto out;
+ }
+
+ if (dialog_popup_info->content) {
+ content_len = strlen(dialog_popup_info->content);
+ buffer_size = strlen(start_tag) + content_len + strlen(end_tag);
+ content = (char*)calloc(buffer_size + 1, sizeof(char));
+ snprintf(content, buffer_size+1, "%s%s%s", start_tag, dialog_popup_info->content, end_tag);
+ elm_object_text_set(content_label, content);
+ }
+ elm_object_part_content_set(window_layout, "part_content_swallow", content_label);
+ elm_object_scale_set(content_label, 1/edje_scale_get());
+ evas_object_show(content_label);
+ }
+
+ button_1 = elm_button_add(window_layout);
+ elm_object_focus_allow_set(button_1, EINA_TRUE);
+ elm_object_part_content_set(window_layout, "part_button_1", button_1);
+ elm_object_style_set(button_1, STYLE_TARGET_BTN);
+ if (dialog_popup_info->button_1_text)
+ elm_object_part_text_set(button_1, "part_popup_btn_text", dialog_popup_info->button_1_text);
+ else
+ elm_object_part_text_set(button_1, "part_popup_btn_text", "OK");
+
+ evas_object_show(button_1);
+ evas_object_smart_callback_add(button_1, "clicked", _down_btn1_cb, priv);
+
+ if (dialog_popup_info->dialog_popup_type != DIALOG_POPUP_TYPE_NOTIFY) {
+ button_2 = elm_button_add(window_layout);
+ elm_object_focus_allow_set(button_2, EINA_TRUE);
+ elm_object_part_content_set(window_layout, "part_button_2", button_2);
+ elm_object_style_set(button_2, STYLE_TARGET_BTN);
+ if (dialog_popup_info->button_2_text)
+ elm_object_part_text_set(button_2, "part_popup_btn_text", dialog_popup_info->button_2_text);
+ else
+ elm_object_part_text_set(button_2, "part_popup_btn_text", "Cancel");
+
+ evas_object_show(button_2);
+ evas_object_smart_callback_add(button_2, "clicked", _down_btn2_cb, priv);
+
+ evas_object_smart_callback_add(button_1, "item,focused", _item_focus_cb, "item,focused");
+ evas_object_smart_callback_add(button_1, "item,unfocused", _item_focus_cb, "item,unfocused");
+ evas_object_smart_callback_add(button_2, "item,focused", _item_focus_cb, "item,focused");
+ evas_object_smart_callback_add(button_2, "item,unfocused", _item_focus_cb, "item,unfocused");
+
+ elm_object_focus_next_object_set(button_1, button_2, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(button_2, button_1, ELM_FOCUS_LEFT);
+ }
+
+ evas_object_smart_callback_add(content_entry, "activated", _down_btn1_cb, priv);
+ priv->popup_info = dialog_popup_info;
+
+ inputmgr_add_callback(dialog_popup, 0, &popup_handler, priv);
+
+ evas_object_show(dialog_popup);
+ elm_win_activate(dialog_popup);
+
+out:
+ SAFE_FREE_CHAR(content);
+
+ return dialog_popup;
+}
diff --git a/src/view/select_folder_view.c b/src/view/select_folder_view.c
new file mode 100755
index 0000000..2031171
--- /dev/null
+++ b/src/view/select_folder_view.c
@@ -0,0 +1,639 @@
+#include <Elementary.h>
+#include <app_control.h>
+#include <app_debug.h>
+#include <inputmgr.h>
+#include <viewmgr.h>
+
+#include "define.h"
+#include "view.h"
+#include "data.h"
+#include "util/utils.h"
+#include "util/file-util.h"
+#include "util/fs-error.h"
+#include "view/dialog_popup.h"
+#include "view/submenu_view.h"
+
+#define STYLE_TARGET_BTN "target_btn"
+#define DEFAULT_PAD 20
+
+static char* _list_label_get(void *data, Evas_Object *obj, const char *part);
+static Evas_Object* _list_content_get(void *data, Evas_Object *obj, const char *part);
+static void _list_del(void *data, Evas_Object *obj);
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev);
+
+static void _down_btn_cb(void *data, Evas_Object *obj, void *event_info);
+
+static void _selected(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
+static void _focused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
+static void _unfocused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
+
+static bool _draw_child_folder_list(Evas_Object *obj, util_item_data_s *uid_param, struct _priv *priv);
+
+static input_handler popup_handler = {
+ .key_up = _key_up_cb,
+ .selected = _selected
+};
+
+static input_handler genlist_handler = {
+ .key_up = _key_up_cb
+};
+
+static input_handler focus_handler = {
+ .focused = _focused,
+ .unfocused = _unfocused
+};
+
+static void _set_folder_item_data(util_item_data_s *uid, fsNodeInfo *node, struct _priv *priv)
+{
+ char *new_path = NULL;
+
+ if (node == NULL)
+ return;
+
+ uid->node = node;
+
+ if (node->path != NULL)
+ uid->parent_path = strdup(node->path);
+ if (node->name != NULL)
+ uid->folder_name = strdup(node->name);
+
+ new_path = utils_get_combined_string(node->path, node->name, NULL);
+
+ if (new_path == NULL)
+ uid->child = NULL;
+ else {
+ uid->child = mf_file_ls(new_path, priv);
+ SAFE_FREE_CHAR(new_path);
+ }
+
+ SAFE_FREE_CHAR(node->path);
+ SAFE_FREE_CHAR(node->name);
+ return;
+}
+
+
+static Eina_Bool ecore_timer_cb(void *data)
+{
+ Evas_Object * genlist = (Evas_Object *)data;
+ Elm_Object_Item * it = elm_genlist_selected_item_get(genlist);
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+check_changed_item_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object * genlist = (Evas_Object *)data;
+ ecore_timer_add(0.1, ecore_timer_cb, genlist);
+}
+
+static fsNodeInfo* _get_fsNodeInfo(Eina_List *list, int index)
+{
+ fsNodeInfo *node = NULL;
+
+ if (list == NULL)
+ return node;
+
+ node = (fsNodeInfo *)eina_list_nth(list, index);
+
+ return node;
+}
+
+static void _selected(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
+{
+ if (data == NULL) {
+ _ERR("data is null. failed select popup menu");
+ return;
+ }
+
+ struct _priv *priv;
+ priv = (struct _priv *)data;
+
+ if (item == NULL) {
+ _ERR("item is null. failed select popup menu");
+ return;
+ }
+
+ priv->submenu_index = elm_genlist_item_index_get(item);
+ inputmgr_remove_callback(priv->popup_win, &popup_handler);
+ evas_object_del(priv->popup_win);
+
+ switch (priv->submenu_index) {
+ case SUBMENU_COPY:
+ case SUBMENU_MOVE:
+ case SUBMENU_RENAME:
+ case SUBMENU_DELETE:
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE_TO_SELECT, priv);
+ break;
+ case SUBMENU_NEW_FOLDER:
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_INPUT_NAME, "New Folder", "Folder", "OK", "Cancel", priv);
+ break;
+ case SUBMENU_SETTING:
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_CONFIGURATION, "Setting", " Show hidden files", "OK", "Cancel", priv);
+ break;
+ }
+
+ return;
+}
+
+static void _focused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
+{
+ elm_object_item_signal_emit(item, "mouse,in", "elm");
+}
+
+static void _unfocused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
+{
+ elm_object_item_signal_emit(item, "mouse,out", "elm");
+}
+
+static Evas_Object* create_check(Evas_Object *parent, void *data)
+{
+ Evas_Object *check;
+ check = elm_check_add(parent);
+ evas_object_smart_callback_add(check, "changed", check_changed_item_cb, data);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ return check;
+}
+
+static char*
+_list_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (data == NULL) {
+ _ERR("data is null. Failed get label");
+ return NULL;
+ }
+
+ char buf[256];
+ util_item_data_s *uid = (util_item_data_s *)data;
+
+ if (!strcmp("elm.text.file", part)) {
+ if (uid->folder_name == NULL)
+ return NULL;
+
+ snprintf(buf, sizeof(buf), "%s", uid->folder_name);
+ }
+
+ return strdup(buf);
+}
+
+static Evas_Object*
+_list_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (data == NULL) {
+ _ERR("data is null. failed get content");
+ return NULL;
+ }
+
+ util_item_data_s *uid = (util_item_data_s *)data;
+
+ if (!strcmp("elm.swallow.icon", part)) {
+ Evas_Object *icon = elm_image_add(obj);
+
+ elm_image_file_set(icon, IMGDIR"/icon/myfile_icon_folder.png", NULL);
+ return icon;
+ } else if (!strcmp("padding.top.left", part)) {
+ Evas_Object *padding = evas_object_rectangle_add(evas_object_evas_get(obj));
+ evas_object_move(padding, 0, 0);
+
+ int minw;
+
+ if (uid->level > 1) {
+ minw = DEFAULT_PAD + (15 * (uid->level - 1));
+ evas_object_size_hint_min_set(padding, minw, 15);
+ evas_object_resize(padding, minw, 20);
+ } else {
+ evas_object_size_hint_min_set(padding, DEFAULT_PAD, 15);
+ evas_object_resize(padding, DEFAULT_PAD, 15);
+ }
+
+ evas_object_color_set(padding, 255, 255, 255, 0);
+ evas_object_show(padding);
+
+ return padding;
+ } else if (!strcmp("elm.swallow.end", part)) {
+ return create_check(obj, data);
+ }
+
+ return NULL;
+}
+
+static void
+_list_del(void *data, Evas_Object *obj)
+{
+ util_item_data_s *uid = (util_item_data_s *)data;
+ util_free_util_item_data_s(uid);
+ free(uid);
+}
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev)
+{
+ if (!data)
+ return;
+
+ struct _priv *priv;
+ priv = (struct _priv *)data;
+
+ if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_ESC)) {
+ inputmgr_remove_callback(priv->popup_win, &popup_handler);
+ evas_object_del(priv->popup_win);
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
+ }
+}
+
+static int _create_new_folder(util_item_data_s *uid, struct _priv *priv)
+{
+ int error_code, result = 0;
+ char *path = NULL, *parent_path = NULL;
+
+ parent_path = utils_get_combined_string(uid->parent_path, uid->folder_name, NULL);
+ path = utils_get_combined_string(uid->parent_path, uid->folder_name, uid->new_folder_name);
+
+ if (mf_file_attr_is_duplicated_name(parent_path, uid->new_folder_name)) {
+ _DBG("new folder name is duplicated.");
+ result = 1;
+ } else {
+ error_code = mf_fs_oper_create_dir(path);
+ if (error_code) {
+ _DBG("failed create directory. error_code : %d", error_code);
+ result = 2;
+ }
+ }
+
+ SAFE_FREE_CHAR(uid->new_folder_name);
+ SAFE_FREE_CHAR(parent_path);
+ SAFE_FREE_CHAR(path);
+ return result;
+}
+
+static void _down_nf_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!data)
+ return;
+
+ struct _priv *priv = (struct _priv *)data;
+
+ evas_object_del(priv->popup_win);
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_INPUT_NAME, "New Folder", "Input new name to make.", "OK", "Cancel", priv);
+
+ return;
+}
+
+static void _down_ok_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!data)
+ return;
+
+ struct _priv *priv = (struct _priv *)data;
+
+ if (priv->popup_genlist == NULL) {
+ _ERR("genlist is null. Failed down_ok_btn_cb.");
+ return;
+ }
+
+ int result = 0;
+ char *src = NULL, *dst = NULL;
+
+ Elm_Object_Item *selected_item = NULL;
+ selected_item = elm_genlist_selected_item_get(priv->popup_genlist);
+
+ util_item_data_s *uid = NULL;
+
+ if (selected_item != NULL)
+ uid = (util_item_data_s *)elm_object_item_data_get(selected_item);
+
+ if (priv->submenu_index == SUBMENU_COPY) {
+ src = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
+ dst = utils_get_combined_string(uid->parent_path, uid->folder_name, priv->selected_folder);
+
+ if (src == NULL || dst == NULL) {
+ _ERR("SRC path or DST path are wrong. failed to copy file");
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_NOTIFY, NULL, "Path is wrong. Fail to copy file.", "OK", NULL, priv);
+ } else {
+ result = mf_file_cp(src, dst);
+
+ if (!result)
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_NOTIFY, NULL, "Fail to copy file.", "OK", NULL, priv);
+ }
+ } else if (priv->submenu_index == SUBMENU_MOVE) {
+ src = utils_get_combined_string(priv->selected_parent_path, priv->selected_folder, NULL);
+ dst = utils_get_combined_string(uid->parent_path, uid->folder_name, priv->selected_folder);
+
+ if (src == NULL || dst == NULL) {
+ _ERR("SRC path or DST path are wrong. failed to move file");
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_NOTIFY, NULL, "Path is wrong. Fail to move file.", "OK", NULL, priv);
+ } else {
+ result = mf_file_mv(src, dst);
+
+ if (!result)
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_NOTIFY, NULL, "Fail to move file.", "OK", NULL, priv);
+ }
+ } else if (priv->submenu_index == SUBMENU_NEW_FOLDER) {
+ if (priv->new_folder_name != NULL) {
+ uid->new_folder_name = strdup(priv->new_folder_name);
+ result = _create_new_folder(uid, priv);
+ SAFE_FREE_CHAR(priv->new_folder_name);
+ }
+ if (result == 1)
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_NOTIFY, NULL, "Folder is exist already.", "OK", NULL, priv);
+ else
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_NOTIFY, NULL, "Some errors are occured.", "OK", NULL, priv);
+ }
+
+ evas_object_del(priv->popup_win);
+ evas_object_del(priv->popup_genlist);
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
+
+ SAFE_FREE_CHAR(src);
+ SAFE_FREE_CHAR(dst);
+
+ return;
+}
+
+
+static void _down_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!data)
+ return;
+
+ struct _priv *priv = (struct _priv *)data;
+
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
+ evas_object_del(priv->popup_win);
+}
+
+static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (event_info == NULL) {
+ _ERR("event_info is null");
+ return;
+ }
+
+ Evas_Object *check = NULL;
+ Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+ Elm_Object_Item *selected_item = NULL;
+ Eina_List *total_list = NULL, *l = NULL;
+
+ if (obj == NULL) {
+ _ERR("obj is null.");
+ return;
+ }
+
+ total_list = elm_genlist_realized_items_get(obj);
+
+ EINA_LIST_FOREACH(total_list, l, selected_item) {
+ check = elm_object_item_part_content_get(selected_item, "elm.swallow.end");
+
+ if (check == NULL) {
+ _ERR("check box is null. Failed item_selected_cb");
+ return;
+ }
+
+ elm_check_state_set(check, EINA_FALSE);
+ }
+
+ elm_genlist_item_selected_set(item, EINA_TRUE);
+ check = elm_object_item_part_content_get(item, "elm.swallow.end");
+
+ if (check == NULL) {
+ _ERR("check box is null. Failed item_selected_cb");
+ return;
+ }
+
+ elm_check_state_set(check, EINA_TRUE);
+
+ if (data == NULL) {
+ _ERR("data is null. Failed item_selected_cb");
+ return;
+ }
+
+ struct _priv *priv = (struct _priv *)data;
+ util_item_data_s *uid = (util_item_data_s *)elm_object_item_data_get(event_info);
+
+ if (uid->child != NULL && eina_list_count(uid->child)) {
+ if (!_draw_child_folder_list(obj, uid, priv)) {
+ _ERR("_draw_child_folder_list failed.");
+ return;
+ }
+ uid->expanded = 1;
+ }
+ return;
+}
+
+static bool _draw_child_folder_list(Evas_Object *obj, util_item_data_s *uid_param, struct _priv *priv)
+{
+ if (priv == NULL) {
+ _ERR("priv is null. failed draw child folder list");
+ return false;
+ }
+
+ Elm_Object_Item *parent = uid_param->item;
+ Elm_Object_Item *it = NULL;
+
+ int i = 0, ret, level;
+ char *path = NULL, *new_path = NULL;
+ list_data_s *list_data = calloc(1, sizeof(list_data_s));
+
+ util_item_data_s *uid;
+ fsNodeInfo *node;
+
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ itc->item_style = "custom_file_target";
+ itc->func.text_get = _list_label_get;
+ itc->func.content_get = _list_content_get;
+ itc->func.del = _list_del;
+
+ path = utils_get_combined_string(uid_param->parent_path, uid_param->folder_name, NULL);
+
+ ret = mf_fs_oper_read_dir(path, &list_data->folder_list, &list_data->file_list);
+ if (ret != MYFILE_ERR_NONE) {
+ _ERR("failed read dir. ret : %d", ret);
+ SAFE_FREE_CHAR(path);
+ mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
+ mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
+ free(list_data);
+ list_data = NULL;
+
+ return false;
+ }
+
+ list_data->file_count = eina_list_count(list_data->file_list);
+ list_data->folder_count = eina_list_count(list_data->folder_list);
+
+ for (i = 0; i < list_data->folder_count; i++) {
+ uid = calloc(1, sizeof(util_item_data_s));
+ uid->index = i;
+
+ node = (fsNodeInfo *)eina_list_nth(list_data->folder_list, i);
+ _set_folder_item_data(uid, node, priv);
+
+ new_path = utils_get_combined_string(path, uid->folder_name, NULL);
+
+ mf_file_attr_get_path_level(new_path, &level);
+ uid->level = level;
+
+ it = elm_genlist_item_insert_after(obj, itc, uid, parent, parent, ELM_GENLIST_ITEM_NONE, _item_selected_cb, priv);
+ uid->item = it;
+ elm_object_item_data_set(it, uid);
+ SAFE_FREE_CHAR(new_path);
+ }
+
+ elm_genlist_item_class_free(itc);
+
+ SAFE_FREE_CHAR(path);
+ mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
+ mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
+ free(list_data);
+ list_data = NULL;
+ return true;
+}
+
+
+void utils_show_select_folder_popup(struct _priv *priv)
+{
+ if (priv == NULL) {
+ _ERR("priv is null. Failed to show select folder popup");
+ return;
+ }
+
+ Evas_Object *notification_popup;
+ Evas_Object *window_layout = NULL;
+ Evas_Object *ok_btn, *cancel_btn, *new_folder_btn;
+ Evas_Object *genlist;
+
+ Elm_Object_Item *it = NULL;
+
+ util_item_data_s *uid;
+ list_data_s *list_data = calloc(1, sizeof(list_data_s));
+
+ char *path = NULL;
+ fsNodeInfo *node = NULL;
+
+ int screen_x, screen_y, screen_w, screen_h;
+
+ notification_popup = elm_win_add(NULL, "notification_popup", ELM_WIN_BASIC);
+ priv->popup_win = notification_popup;
+
+ elm_win_screen_size_get(notification_popup, &screen_x, &screen_y, &screen_w, &screen_h);
+
+ elm_win_alpha_set(notification_popup, EINA_TRUE);
+ elm_win_borderless_set(notification_popup, EINA_TRUE);
+ elm_win_autodel_set(notification_popup, EINA_TRUE);
+
+ window_layout = elm_layout_add(notification_popup);
+ elm_layout_file_set(window_layout, EDJEFILE, GRP_VIEW_SELECT_FOLDER);
+ evas_object_resize(window_layout, screen_w, screen_h);
+ evas_object_show(window_layout);
+
+ genlist = elm_genlist_add(window_layout);
+ elm_object_part_content_set(window_layout, "select_folder_genlist", genlist);
+ elm_object_scale_set(genlist, 1/edje_scale_get());
+ elm_object_focus_allow_set(genlist, EINA_TRUE);
+
+ path = Get_Root_Path(STORAGE_TYPE_INTERNAL);
+ if (path == NULL)
+ list_data->path = NULL;
+ else
+ list_data->path = path;
+
+ int ret = mf_fs_oper_read_dir(list_data->path, &list_data->folder_list, &list_data->file_list);
+ if (ret != MYFILE_ERR_NONE) {
+ _ERR("failed read dir. ret : %d", ret);
+ SAFE_FREE_CHAR(path);
+ mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
+ mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
+ free(list_data);
+ list_data = NULL;
+
+ evas_object_del(notification_popup);
+ notification_popup = NULL;
+ return;
+ }
+
+ list_data->file_count = eina_list_count(list_data->file_list);
+ list_data->folder_count = eina_list_count(list_data->folder_list);
+
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ itc->item_style = "custom_file_target";
+ itc->func.text_get = _list_label_get;
+ itc->func.content_get = _list_content_get;
+ itc->func.del = _list_del;
+
+ int i;
+ for (i = 0; i < list_data->folder_count; i++) {
+ uid = calloc(1, sizeof(util_item_data_s));
+ uid->index = i;
+ uid->expanded = 0;
+ uid->level = 1;
+
+ node = _get_fsNodeInfo(list_data->folder_list, uid->index);
+ _set_folder_item_data(uid, node, priv);
+
+ it = elm_genlist_item_append(genlist, itc, uid, NULL, ELM_GENLIST_ITEM_NONE, _item_selected_cb, priv);
+
+ uid->item = it;
+ elm_object_item_data_set(it, uid);
+ }
+
+ priv->popup_genlist = genlist;
+ elm_genlist_item_class_free(itc);
+ evas_object_show(genlist);
+
+ ok_btn = elm_button_add(window_layout);
+ elm_object_style_set(ok_btn, STYLE_TARGET_BTN);
+ elm_object_focus_allow_set(ok_btn, EINA_TRUE);
+ elm_object_part_content_set(window_layout, "select_folder_ok_btn", ok_btn);
+ elm_object_part_text_set(ok_btn, "part_popup_btn_text", "OK");
+ evas_object_show(ok_btn);
+
+ cancel_btn = elm_button_add(window_layout);
+ elm_object_style_set(cancel_btn, STYLE_TARGET_BTN);
+ elm_object_focus_allow_set(cancel_btn, EINA_TRUE);
+ elm_object_part_content_set(window_layout, "select_folder_cancel_btn", cancel_btn);
+ elm_object_part_text_set(cancel_btn, "part_popup_btn_text", "Cancel");
+ evas_object_show(cancel_btn);
+
+ new_folder_btn = elm_button_add(window_layout);
+ elm_object_style_set(new_folder_btn, STYLE_TARGET_BTN);
+ elm_object_focus_allow_set(new_folder_btn, EINA_TRUE);
+ elm_object_part_content_set(window_layout, "select_folder_newfolder_btn", new_folder_btn);
+ elm_object_part_text_set(new_folder_btn, "part_popup_btn_text", "New Folder");
+ evas_object_show(new_folder_btn);
+
+ if (priv->after_input_folder_name)
+ elm_object_disabled_set(new_folder_btn, EINA_TRUE);
+ else
+ elm_object_disabled_set(new_folder_btn, EINA_FALSE);
+
+ elm_object_focus_next_object_set(ok_btn, cancel_btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(cancel_btn, ok_btn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, new_folder_btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(new_folder_btn, cancel_btn, ELM_FOCUS_LEFT);
+
+ inputmgr_add_callback(notification_popup, 0, &popup_handler, priv);
+ inputmgr_add_callback(genlist, 0, &genlist_handler, priv);
+ inputmgr_add_callback(genlist, 0, &focus_handler, priv);
+
+ inputmgr_add_callback(ok_btn, 0, &focus_handler, priv);
+ inputmgr_add_callback(cancel_btn, 0, &focus_handler, priv);
+ inputmgr_add_callback(new_folder_btn, 0, &focus_handler, priv);
+
+ evas_object_smart_callback_add(ok_btn, "clicked", _down_ok_btn_cb, priv);
+ evas_object_smart_callback_add(cancel_btn, "clicked", _down_btn_cb, priv);
+ evas_object_smart_callback_add(new_folder_btn, "clicked", _down_nf_btn_cb, priv);
+
+ evas_object_show(notification_popup);
+ elm_win_activate(notification_popup);
+
+ mf_util_free_eina_list_with_data(&list_data->folder_list, MYFILE_TYPE_FSNODE);
+ mf_util_free_eina_list_with_data(&list_data->file_list, MYFILE_TYPE_FSNODE);
+ SAFE_FREE_CHAR(path);
+ free(list_data);
+ list_data = NULL;
+
+ return;
+}
diff --git a/src/view/submenu_view.c b/src/view/submenu_view.c
new file mode 100755
index 0000000..37c16e8
--- /dev/null
+++ b/src/view/submenu_view.c
@@ -0,0 +1,229 @@
+#include <Elementary.h>
+#include <app_control.h>
+#include <app_debug.h>
+#include <viewmgr.h>
+
+#include "define.h"
+#include "view.h"
+#include "util/utils.h"
+#include "util/file-util.h"
+#include "view/dialog_popup.h"
+#include "view/submenu_view.h"
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev);
+
+static void _selected(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
+static void _focused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
+static void _unfocused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
+
+
+static input_handler popup_handler = {
+ .key_up = _key_up_cb,
+ .selected = _selected
+};
+
+static input_handler focus_handler = {
+ .focused = _focused,
+ .unfocused = _unfocused
+};
+
+static void _selected(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
+{
+ if (data == NULL) {
+ _ERR("data is null. failed select popup menu");
+ return;
+ }
+
+ struct _priv *priv;
+ priv = (struct _priv *)data;
+
+ if (item == NULL) {
+ _ERR("item is null. failed select popup menu");
+ return;
+ }
+
+ priv->submenu_index = elm_genlist_item_index_get(item);
+ inputmgr_remove_callback(priv->popup_win, &popup_handler);
+ evas_object_del(priv->popup_win);
+
+ switch (priv->submenu_index) {
+ case SUBMENU_COPY:
+ case SUBMENU_MOVE:
+ case SUBMENU_RENAME:
+ case SUBMENU_DELETE:
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE_TO_SELECT, priv);
+ break;
+ case SUBMENU_NEW_FOLDER:
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_INPUT_NAME, "New Folder", "Folder", "OK", "Cancel", priv);
+ break;
+ case SUBMENU_SETTING:
+ utils_show_dialog_popup(DIALOG_POPUP_TYPE_CONFIGURATION, "Setting", " Show hidden files", "OK", "Cancel", priv);
+ break;
+ }
+
+ return;
+}
+
+static void _focused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
+{
+ elm_object_item_signal_emit(item, "mouse,in", "elm");
+}
+
+static void _unfocused(int id, void *data, Evas_Object *obj, Elm_Object_Item *item)
+{
+ elm_object_item_signal_emit(item, "mouse,out", "elm");
+}
+
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev)
+{
+ if (!data)
+ return;
+
+ struct _priv *priv;
+ priv = (struct _priv *)data;
+
+ if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_ESC)) {
+ inputmgr_remove_callback(priv->popup_win, &popup_handler);
+ evas_object_del(priv->popup_win);
+ viewmgr_update_view(VIEW_BASE, UPDATE_FILE, priv);
+ }
+}
+
+
+static char*
+_list_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (data == NULL) {
+ _ERR("data is null. Failed get label");
+ return NULL;
+ }
+
+ char buf[256];
+ util_item_data_s *uid = (util_item_data_s *)data;
+
+ if (!strcmp("elm.text.file", part)) {
+ if (uid->folder_name == NULL)
+ return NULL;
+
+ snprintf(buf, sizeof(buf), "%s", uid->folder_name);
+ } else {
+ if (uid->index == 0)
+ snprintf(buf, sizeof(buf), "Copy");
+ else if (uid->index == 1)
+ snprintf(buf, sizeof(buf), "Move");
+ else if (uid->index == 2)
+ snprintf(buf, sizeof(buf), "Rename");
+ else if (uid->index == 3)
+ snprintf(buf, sizeof(buf), "New folder");
+ else if (uid->index == 4)
+ snprintf(buf, sizeof(buf), "Delete");
+ else if (uid->index == 5)
+ snprintf(buf, sizeof(buf), "Setting");
+ else
+ return NULL;
+ }
+
+ return strdup(buf);
+}
+
+
+static void
+_list_del(void *data, Evas_Object *obj)
+{
+ /* Unrealized callback can be called after this. */
+ /* Accessing item_data_s can be dangerous on unrealized callback. */
+ util_item_data_s *uid = (util_item_data_s *)data;
+ util_free_util_item_data_s(uid);
+ free(uid);
+}
+
+
+void utils_show_submenu_popup(struct _priv *priv)
+{
+ if (priv == NULL) {
+ _ERR("priv is null. failed to show submenu popup");
+ return;
+ }
+
+ Evas_Object *notification_popup;
+ Evas_Object *window_layout = NULL;
+ Evas_Object *genlist;
+
+ util_item_data_s *uid;
+
+ Evas *e = NULL;
+ Ecore_Evas *ee = NULL;
+ Eina_Bool result = EINA_FALSE;
+ int screen_x, screen_y, screen_w, screen_h;
+
+ notification_popup = elm_win_add(NULL, "notification_popup", ELM_WIN_BASIC);
+ priv->popup_win = notification_popup;
+
+ if (notification_popup == NULL) {
+ _ERR("elm_win_add failed");
+ goto out;
+ }
+
+ e = evas_object_evas_get(notification_popup);
+ if (!e) {
+ _ERR("evas_object_evas_get failed");
+ evas_object_del(notification_popup);
+ notification_popup = NULL;
+ goto out;
+ }
+
+ ee = ecore_evas_ecore_evas_get(e);
+ if (!ee) {
+ _ERR("ecore_evas_ecore_evas_get failed");
+ evas_object_del(notification_popup);
+ notification_popup = NULL;
+ goto out;
+ }
+
+ elm_win_alpha_set(notification_popup, EINA_TRUE);
+ elm_win_borderless_set(notification_popup, EINA_TRUE);
+ elm_win_autodel_set(notification_popup, EINA_TRUE);
+
+ elm_win_screen_size_get(notification_popup, &screen_x, &screen_y, &screen_w, &screen_h);
+
+ window_layout = elm_layout_add(notification_popup);
+ result = elm_layout_file_set(window_layout, EDJEFILE, GRP_VIEW_SUBMENU);
+ _DBG("Layout elm_layout_file_set for [%s] returns [%d]", EDJEFILE, result);
+ evas_object_resize(window_layout, screen_w, screen_h);
+ evas_object_show(window_layout);
+
+ genlist = elm_genlist_add(window_layout);
+ elm_object_part_content_set(window_layout, "submenu_genlist", genlist);
+ elm_object_scale_set(genlist, 1/edje_scale_get());
+ elm_object_focus_allow_set(genlist, EINA_TRUE);
+
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ itc->item_style = "custom_1text";
+ itc->func.text_get = _list_label_get;
+ itc->func.del = _list_del;
+
+ int i;
+ for (i = 0; i < 6; i++) {
+ uid = calloc(1, sizeof(util_item_data_s));
+ uid->index = i;
+
+ elm_genlist_item_append(genlist, itc, uid, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ }
+
+ elm_genlist_item_class_free(itc);
+ evas_object_show(genlist);
+
+ elm_object_item_focus_set(elm_genlist_first_item_get(genlist), EINA_TRUE);
+ inputmgr_add_callback(genlist, 0, &focus_handler, priv);
+ inputmgr_add_callback(genlist, 0, &popup_handler, priv);
+
+ evas_object_show(notification_popup);
+ elm_win_activate(notification_popup);
+
+out:
+ return;
+}