2 * Copyright 2012 Samsung Electronics Co., Ltd
\r
4 * Licensed under the Flora License, Version 1.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://floralicense.org/license/
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
21 #include <pthread.h>
\r
24 #include "mf-ug-util.h"
\r
25 #include "mf-ug-cb.h"
\r
26 #include "mf-ug-winset.h"
\r
27 #include "mf-ug-fm-svc-wrapper.h"
\r
28 #include "mf-ug-fs-util.h"
\r
29 #include "mf-ug-inotify-handle.h"
\r
30 #include "mf-ug-resource.h"
\r
32 #define MF_UG_TIMER_INTERVAL_VIBRATION 0.5
\r
33 #define MF_UG_VIBRATION_DEVICE 0
\r
34 #define MF_UG_VIBRATION_DURATION 500
\r
36 /******************************
\r
37 ** Prototype : ug_genlist_selected_state_get
\r
39 ** Input : void *data
\r
46 ** 1.Date : 2010/12/10
\r
48 ** Modification : Created function
\r
50 ******************************/
\r
51 bool mf_ug_util_is_genlist_selected(void *data)
\r
54 ugData *ugd = (ugData *)data;
\r
55 ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL");
\r
57 Elm_Object_Item *gli = NULL;
\r
58 Elm_Object_Item *nli = NULL;
\r
59 Evas_Object *genlist = NULL;
\r
61 ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd);
\r
62 ug_mf_retvm_if(pNavi_s == NULL, false, "get navigation bar in use failed");
\r
64 if (ugd->ug_MainWindow.ug_pContent) {
\r
65 genlist = ugd->ug_MainWindow.ug_pContent;
\r
66 gli = elm_genlist_first_item_get(genlist);
\r
69 ugListItemData *itemData = (ugListItemData *)elm_object_item_data_get(gli);
\r
70 ug_mf_retvm_if(itemData == NULL, false, "itemData is NULL");
\r
71 if (itemData->ug_bChecked == true) {
\r
75 nli = elm_genlist_item_next_get(gli);
\r
83 /******************************
\r
84 ** Prototype : ug_parase_path_get
\r
86 ** Input : GList *dest_list
\r
94 ** 1.Date : 2010/12/10
\r
96 ** Modification : Created function
\r
98 ******************************/
\r
99 void mf_ug_util_get_params_path(Eina_List **dest_list, const char *path_list)
\r
102 ug_mf_retm_if(dest_list == NULL, "dest_list is NULL");
\r
104 gchar **result = NULL;
\r
105 gchar **params = NULL;
\r
106 result = g_strsplit(path_list, "?", 0);
\r
108 for (params = result; *params; params++) {
\r
109 *dest_list = eina_list_append(*dest_list, strdup(*params));
\r
112 g_strfreev(result);
\r
116 /******************************
\r
117 ** Prototype : mf_ug_util_free_eina_list_data
\r
118 ** Description : Samsung
\r
119 ** Input : Eina_List **list
\r
120 ** mf_ug_eina_list_node_type node_type
\r
127 ** 1.Date : 2010/12/10
\r
128 ** Author : Samsung
\r
129 ** Modification : Created function
\r
131 ******************************/
\r
132 void mf_ug_util_free_eina_list_data(Eina_List **list, mf_ug_eina_list_node_type node_type)
\r
135 ug_mf_retm_if(list == NULL, "list is NULL");
\r
136 ug_mf_retm_if(*list == NULL, "*list is NULL");
\r
138 Eina_List *l = NULL;
\r
139 void *pNode = NULL;
\r
140 switch (node_type) {
\r
141 case NODE_TYPE_CHAR:
\r
142 case NODE_TYPE_PNODE:
\r
143 EINA_LIST_FOREACH(*list, l, pNode) {
\r
148 case NODE_TYPE_GSTRING:
\r
149 EINA_LIST_FOREACH(*list, l, pNode) {
\r
150 if (pNode != NULL) {
\r
151 g_string_free(pNode, TRUE);
\r
160 eina_list_free(*list);
\r
166 /******************************
\r
167 ** Prototype : __mf_ug_util_get_marked_selected_items
\r
169 ** Input : GList *list
\r
176 ** 1.Date : 2010/12/10
\r
177 ** Author : Samsung
\r
178 ** Modification : Created function
\r
180 ******************************/
\r
181 static void __mf_ug_util_get_marked_selected_items(Eina_List *list, Eina_List **select_list)
\r
184 ug_mf_retm_if(select_list == NULL, "select_list is NULL");
\r
185 ug_mf_retm_if(list == NULL, "list is NULL");
\r
187 Eina_List *l = NULL;
\r
188 void *pNode = NULL;
\r
190 EINA_LIST_FOREACH(list, l, pNode) {
\r
191 if (pNode != NULL) {
\r
192 *select_list = eina_list_append(*select_list, strdup(pNode));
\r
199 /******************************
\r
200 ** Prototype : __mf_ug_util_get_marked_off_selected_items
\r
202 ** Input : void *data
\r
203 ** Evas_Object* content
\r
210 ** 1.Date : 2010/12/10
\r
211 ** Author : Samsung
\r
212 ** Modification : Created function
\r
214 ******************************/
\r
215 static void __mf_ug_util_get_marked_off_selected_items(void *data, Eina_List **select_list)
\r
218 ugData *ugd = (ugData *)data;
\r
219 ug_mf_retm_if(ugd == NULL, "ugData is NULL");
\r
220 ug_mf_retm_if(select_list == NULL, "selected_list is NULL");
\r
221 ug_mf_retm_if(ugd->ug_MainWindow.ug_pContent == NULL, "ugd->ug_MainWindow.ug_pContent is NULL");
\r
224 Evas_Object *content = ugd->ug_MainWindow.ug_pContent;
\r
225 Elm_Object_Item *gli = elm_genlist_first_item_get(content);
\r
227 Elm_Object_Item *nli = NULL;
\r
232 ugListItemData *params = (ugListItemData *)elm_object_item_data_get(gli);
\r
233 ug_mf_retm_if(params == NULL, "params is NULL");
\r
234 if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) {
\r
235 if (params->ug_pRadioBox) {
\r
236 if (elm_radio_value_get(ugd->ug_MainWindow.ug_pRadioGroup) == radio_id) {
\r
237 *select_list = eina_list_append(*select_list, strdup(params->ug_pItemName->str));
\r
242 } else if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE ||
\r
243 ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE ||
\r
244 ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE ||
\r
245 ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) {
\r
246 if (params->ug_pCheckBox) {
\r
247 if (params->ug_bChecked == true) {
\r
248 *select_list = eina_list_append(*select_list, strdup(params->ug_pItemName->str));
\r
252 nli = elm_genlist_item_next_get(gli);
\r
258 /******************************
\r
259 ** Prototype : mf_ug_util_get_send_result
\r
261 ** Input : void *data
\r
268 ** 1.Date : 2010/12/10
\r
269 ** Author : Samsung
\r
270 ** Modification : Created function
\r
272 ******************************/
\r
273 char *mf_ug_util_get_send_result(void *data)
\r
276 ugData *ugd = (ugData *)data;
\r
277 ug_mf_retvm_if(ugd == NULL, NULL, "ugData is NULL");
\r
279 char *file_selected = NULL;
\r
280 Eina_List *selected_list = NULL;
\r
281 Eina_List *l = NULL;
\r
282 char *pNode = NULL;
\r
284 if (ugd->ug_UiGadget.ug_iMarkedMode == MARKED_ON
\r
285 && (ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE || ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE)) {
\r
286 __mf_ug_util_get_marked_selected_items(ugd->ug_UiGadget.ug_pMultiSelectFileList, &selected_list);
\r
288 __mf_ug_util_get_marked_off_selected_items(ugd, &selected_list);
\r
291 EINA_LIST_FOREACH(selected_list, l, pNode) {
\r
292 if (pNode != NULL) {
\r
293 if (file_selected == NULL) {
\r
294 file_selected = g_strconcat(pNode, NULL);
\r
296 char *temp = file_selected;
\r
297 file_selected = g_strconcat(file_selected, "?", pNode, NULL);
\r
302 mf_ug_util_free_eina_list_data(&selected_list, NODE_TYPE_CHAR);
\r
304 return file_selected;
\r
308 /******************************
\r
309 ** Prototype : _ug_mf_set_state_as
\r
311 ** Input : struct ugmyfiledata* data
\r
319 ** 1.Date : 2010/12/10
\r
320 ** Author : Samsung
\r
321 ** Modification : Created function
\r
323 ******************************/
\r
324 void mf_ug_util_set_current_state(void *data, int state)
\r
327 ugData *ugd = (ugData *)data;
\r
328 ug_mf_retm_if(ugd == NULL, "ugd is NULL");
\r
330 ugd->ug_Status.ug_iState = state;
\r
335 /******************************
\r
336 ** Prototype : mf_ug_util_get_mmc_state
\r
338 ** Input : int* mmc_card
\r
345 ** 1.Date : 2010/12/10
\r
346 ** Author : Samsung
\r
347 ** Modification : Created function
\r
349 ******************************/
\r
350 int mf_ug_util_get_mmc_state(int *mmc_card)
\r
353 int data = UG_ERROR_RETURN;
\r
354 int error_code = MYFILE_ERR_NONE;
\r
356 ug_mf_retvm_if(mmc_card == NULL, MYFILE_ERR_SRC_ARG_INVALID, "mmc_card is NULL");
\r
359 error_code = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &data);
\r
363 return MYFILE_ERR_GET_VCONF_FAIL;
\r
366 if (data != VCONFKEY_SYSMAN_MMC_MOUNTED) {
\r
367 *mmc_card = MMC_OFF;
\r
369 *mmc_card = MMC_ON;
\r
375 /******************************
\r
376 ** Prototype : mf_ug_util_create_dir_monitor
\r
377 ** Description : Samsung
\r
378 ** Input : void *data
\r
385 ** 1.Date : 2010/12/10
\r
386 ** Author : Samsung
\r
387 ** Modification : Created function
\r
389 ******************************/
\r
390 int mf_ug_util_create_dir_monitor(void *data)
\r
393 ugData *ugd = (ugData *)data;
\r
394 ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugData is NULL");
\r
396 if (ugd->ug_UiGadget.ug_pInotifyPipe) {
\r
397 ecore_pipe_del(ugd->ug_UiGadget.ug_pInotifyPipe);
\r
398 ugd->ug_UiGadget.ug_pInotifyPipe = NULL;
\r
400 ugd->ug_UiGadget.ug_pInotifyPipe = ecore_pipe_add(mf_ug_cb_dir_pipe_cb, (const void *)ugd);
\r
403 return mf_ug_inotify_handle_init_inotify();
\r
407 /******************************
\r
408 ** Prototype : mf_ug_util_add_dir_watch
\r
409 ** Description : Samsung
\r
410 ** Input : const char *path
\r
418 ** 1.Date : 2010/12/10
\r
419 ** Author : Samsung
\r
420 ** Modification : Created function
\r
422 ******************************/
\r
423 int mf_ug_util_add_dir_watch(const char *path, void *data)
\r
425 return mf_ug_inotify_handle_add_inotify_watch(path, mf_ug_cb_dir_update_cb, data);
\r
428 int mf_ug_util_remove_dir_watch(void)
\r
430 return mf_ug_inotify_handle_rm_inotify_watch();
\r
433 /******************************
\r
434 ** Prototype : mf_ug_util_set_mmc_state_cb
\r
435 ** Description : Samsung
\r
436 ** Input : void *data
\r
443 ** 1.Date : 2010/12/10
\r
444 ** Author : Samsung
\r
445 ** Modification : Created function
\r
447 ******************************/
\r
448 int mf_ug_util_set_mmc_state_cb(void *data)
\r
451 ugData *ugd = (ugData *)data;
\r
452 ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugd is NULL");
\r
454 int mmc_state = MMC_OFF;
\r
455 mf_ug_util_get_mmc_state(&mmc_state);
\r
456 ugd->ug_Status.ug_iMmcFlag = mmc_state;
\r
459 return vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, mf_ug_cb_mmc_changed_cb, ugd);
\r
462 /******************************
\r
463 ** Prototype : mf_ug_util_destory_mmc_state_cb
\r
464 ** Description : Samsung
\r
472 ** 1.Date : 2010/12/10
\r
473 ** Author : Samsung
\r
474 ** Modification : Created function
\r
476 ******************************/
\r
477 void mf_ug_util_destory_mmc_state_cb()
\r
480 vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, mf_ug_cb_mmc_changed_cb);
\r
484 /******************************
\r
485 ** Prototype : mf_ug_util_destory_dir_monitor
\r
486 ** Description : Samsung
\r
487 ** Input : void *data
\r
494 ** 1.Date : 2010/12/10
\r
495 ** Author : Samsung
\r
496 ** Modification : Created function
\r
498 ******************************/
\r
499 void mf_ug_util_destory_dir_monitor(void *data)
\r
502 ugData *ugd = (ugData *)data;
\r
503 ug_mf_retm_if(ugd == NULL, "ugd is NULL");
\r
505 if (ugd->ug_UiGadget.ug_pInotifyPipe) {
\r
506 ecore_pipe_del(ugd->ug_UiGadget.ug_pInotifyPipe);
\r
507 ugd->ug_UiGadget.ug_pInotifyPipe = NULL;
\r
510 mf_ug_inotify_handle_finalize_inotify();
\r
517 /******************************
\r
518 ** Prototype : mf_ug_util_storage_insert_action
\r
519 ** Description : Samsung
\r
520 ** Input : void *data
\r
521 ** char* pItemLabel
\r
528 ** 1.Date : 2010/12/10
\r
529 ** Author : Samsung
\r
530 ** Modification : Created function
\r
532 ******************************/
\r
533 void mf_ug_util_storage_insert_action(void *data, char *pItemLabel)
\r
536 ugData *ugd = (ugData *)data;
\r
537 ug_mf_retm_if(ugd == NULL, "ugd is NULL");
\r
539 Elm_Object_Item *pItemPhone = NULL;
\r
540 ugFsNodeInfo *pNode = NULL;
\r
542 if (ugd->ug_Status.ug_iViewType != mf_ug_view_root) {
\r
547 if (ugd->ug_Status.ug_iMmcFlag) {
\r
548 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
549 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
551 snprintf(pNode->path, sizeof(pNode->path), "%s", STORAGE_PARENT);
\r
552 snprintf(pNode->name, sizeof(pNode->name), "%s", MMC_NAME);
\r
553 pNode->type = UG_FILE_TYPE_DIR;
\r
554 ugd->ug_UiGadget.ug_pDirList = eina_list_append(ugd->ug_UiGadget.ug_pDirList, pNode);
\r
555 mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pContent, pNode, ugd, 0, &ugd->ug_Status.ug_normalitc);
\r
563 /******************************
\r
564 ** Prototype : mf_ug_util_get_file_launch_type
\r
566 ** Input : char * path
\r
567 ** Output : UG_MYFILE_LAUNCH_TYPE
\r
573 ** 1.Date : 2010/12/10
\r
574 ** Author : Samsung
\r
575 ** Modification : Created function
\r
577 ******************************/
\r
578 mf_ug_launch_type mf_ug_util_get_file_launch_type(char *path)
\r
580 if (path == NULL) {
\r
582 return LAUNCH_TYPE_UNSUPPORT;
\r
584 if (ecore_file_file_get(path) == NULL) {
\r
586 return LAUNCH_TYPE_UNSUPPORT;
\r
588 if (ecore_file_is_dir(path) == 1) {
\r
590 return LAUNCH_TYPE_UNSUPPORT;
\r
592 if (mf_ug_file_attr_is_drm_file(path) == 0) {
\r
593 mf_ug_drm_file_mime_type drm_file_type = mf_ug_fs_oper_get_drm_type(path);
\r
595 if (drm_file_type == MF_UG_DRM_RINGTONE_FILE) {
\r
597 return LAUNCH_TYPE_MUSIC;
\r
598 } else if (drm_file_type == MF_UG_DRM_IMAGE_FILE) {
\r
600 return LAUNCH_TYPE_IMAGE;
\r
601 } else if (drm_file_type == MF_UG_DRM_VIDEO_FILE) {
\r
603 return LAUNCH_TYPE_VIDEO;
\r
606 return LAUNCH_TYPE_UNSUPPORT;
\r
609 mf_ug_fs_file_type category_t = 0;
\r
610 mf_ug_file_attr_get_file_category(path, &category_t);
\r
611 if (category_t == UG_FILE_TYPE_MUSIC || category_t == UG_FILE_TYPE_SOUND || category_t == UG_FILE_TYPE_VOICE) {
\r
613 return LAUNCH_TYPE_MUSIC;
\r
614 } else if (category_t == UG_FILE_TYPE_IMAGE) {
\r
616 return LAUNCH_TYPE_IMAGE;
\r
619 return LAUNCH_TYPE_UNSUPPORT;
\r
625 mf_ug_theme_type mf_ug_util_get_theme(void)
\r
627 mf_ug_theme_type theme = UG_THEME_INVALID;
\r
630 char *theme_name = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR);
\r
631 ug_debug("theme is [%s]", theme_name);
\r
632 ug_mf_retvm_if(theme_name == NULL, UG_THEME_ERROR, "Failed to get vconf value"); /* file system exceptional handle */
\r
634 name = strrchr(theme_name, '/');
\r
641 ug_debug("name is [%s]", name);
\r
642 //SETTING_TRACE("name:%s", name);
\r
643 /* special theme process.. */
\r
644 if (0 == g_strcmp0("tizen-black.edj", name) || 0 == g_strcmp0("tizen-black-hd.edj", name)) {
\r
645 theme = UG_THEME_NBEAT_BLACK;
\r
646 } else if (0 == g_strcmp0("tizen.edj", name) || 0 == g_strcmp0("tizen-hd.edj", name)
\r
647 || 0 == g_strcmp0("blue-hd.edj", name)) {
\r
648 theme = UG_THEME_NBEAT;
\r
650 theme = UG_THEME_ERROR;
\r
654 ug_debug("theme is [%d]", theme);
\r
659 char *mf_ug_util_upper_folder_name_get(void *data, GString *fullpath)
\r
661 ug_mf_retvm_if(data == NULL, NULL, "data is NULL");
\r
662 ug_mf_retvm_if(fullpath == NULL, NULL, "fullpath is NULL");
\r
663 ug_mf_retvm_if(fullpath->str == NULL, NULL, "fullpath is NULL");
\r
665 GString *parent_path = NULL;
\r
666 GString *gName = NULL;
\r
667 char *upper_name = NULL;
\r
669 parent_path = mf_ug_fm_svc_wrapper_get_file_parent_path(fullpath);
\r
671 ug_mf_retvm_if(parent_path == NULL, NULL, "fullpath is NULL");
\r
672 ug_mf_retvm_if(parent_path->str == NULL, NULL, "fullpath is NULL");
\r
675 if (!g_strcmp0(parent_path->str, PHONE_FOLDER)) {
\r
676 upper_name = g_strdup(MF_UG_LABEL_PHONE);
\r
677 } else if (!g_strcmp0(parent_path->str, MEMORY_FOLDER)) {
\r
678 upper_name = g_strdup(MF_UG_LABEL_MMC);
\r
680 gName = mf_ug_fm_svc_wapper_get_file_name(parent_path);
\r
681 UG_GSTRING_CHECK_NULL_GOTO(gName, FAILED_EXIT);
\r
682 upper_name = g_strdup(gName->str);
\r
685 UG_CHAR_CHECK_NULL_GOTO(upper_name, FAILED_EXIT);
\r
686 UG_SAFE_FREE_GSTRING(parent_path);
\r
687 UG_SAFE_FREE_GSTRING(gName);
\r
691 UG_SAFE_FREE_GSTRING(parent_path);
\r
692 UG_SAFE_FREE_GSTRING(gName);
\r
697 void mf_ug_util_sort_the_file_list(void *data)
\r
701 ug_mf_retm_if(data == NULL, "data is null");
\r
702 ugData *ugd = (ugData *)data;
\r
704 int iSortTypeValue = 0;
\r
706 iSortTypeValue = ugd->ug_Status.ug_iSortType;
\r
708 mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pFilterList, MF_UG_SORT_BY_NAME_A2Z);
\r
709 mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pDirList, MF_UG_SORT_BY_NAME_A2Z);
\r
711 //mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pFilterList, iSortTypeValue);
\r
712 /*need to sort folder items only By Name and Date*/
\r
713 //mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pDirList, iSortTypeValue);
\r
716 int mf_ug_util_check_disk_space(void *data)
\r
719 ug_mf_retvm_if(data == NULL, MYFILE_ERR_SRC_ARG_INVALID, "data is null");
\r
720 ugData *ugd = (ugData *)data;
\r
722 mf_ug_storage_type state = MF_UG_NONE;
\r
723 unsigned long free_space = 0;
\r
725 if (ugd->ug_Status.ug_iMore == UG_MORE_CREATE_FOLDER) {
\r
726 state = mf_ug_fm_svc_wapper_get_location(ugd->ug_Status.ug_pPath->str);
\r
727 free_space = mf_ug_fm_svc_wrapper_get_free_space(state);
\r
728 ug_debug("free size is %lu\n", free_space);
\r
730 ** in vfat fs type, sector size is 16K.
\r
731 ** it is to say that the limited size of the free space should be 16K
\r
732 ** or it will report space used up.
\r
733 ** check free_space == 0 can make sure at least 16K is free on the disk
\r
734 ** while every dir takes 4K
\r
736 if (free_space == 0) {
\r
737 ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL,
\r
738 MF_UG_LABEL_NOT_ENOUGH_SPACE, MF_UG_LABEL_OK,
\r
739 NULL, NULL, mf_ug_cb_warning_popup_cb, ugd);
\r
740 return MYFILE_ERR_NO_FREE_SPACE;
\r
744 return MYFILE_ERR_NONE;
\r
747 void mf_ug_util_operation_alloc_failed(void *data)
\r
750 ug_mf_retm_if(data == NULL, "data is null");
\r
751 ugData *ugd = (ugData *)data;
\r
753 ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_MEMORY_NOT_ENOUGH,
\r
754 NULL, NULL, NULL, (Evas_Smart_Cb) elm_exit, NULL);
\r
757 long mf_ug_util_character_count_get(const char *original)
\r
759 ug_mf_retvm_if(original == NULL, 0, "input string is NULL");
\r
761 char *utf8_form = g_locale_to_utf8(original, -1, NULL, NULL, NULL);
\r
762 if (utf8_form == NULL)
\r
765 count = g_utf8_strlen(utf8_form, -1);
\r
767 ug_debug("utf8 count is %ld", count);
\r
772 ugFsNodeInfo *mf_ug_util_generate_pnode(const char *path, int file_type)
\r
774 ug_mf_retvm_if(path == NULL, NULL, "path is NULL");
\r
775 ugFsNodeInfo *pNode = NULL;
\r
776 int error = MYFILE_ERR_NONE;
\r
778 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
779 if (pNode == NULL) {
\r
782 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
783 char *parent = NULL;
\r
784 error = mf_ug_file_attr_get_parent_path(path, &parent);
\r
785 if (error == MYFILE_ERR_NONE) {
\r
786 snprintf(pNode->path, sizeof(pNode->path), "%s", parent);
\r
787 snprintf(pNode->name, sizeof(pNode->name), "%s", ecore_file_file_get(path));
\r
788 mf_ug_file_attr_get_file_stat(path, &pNode);
\r
789 if (file_type == UG_FILE_TYPE_DIR) {
\r
790 pNode->type = file_type;
\r
792 mf_ug_file_attr_get_file_category(path, &(pNode->type));
\r
795 UG_SAFE_FREE_CHAR(pNode);
\r
800 void mf_util_generate_list(Eina_List **list, const char *path, int file_type)
\r
802 ug_mf_retm_if(list == NULL, "list is NULL");
\r
803 ug_mf_retm_if(path == NULL, "path is NULL");
\r
805 ugFsNodeInfo *pNode = mf_ug_util_generate_pnode(path, file_type);
\r
808 *list = eina_list_append(*list, pNode);
\r
811 void mf_util_remove_item_from_list_by_location(Eina_List **list, int location)
\r
813 ug_mf_retm_if(list == NULL, "list is NULL");
\r
815 Eina_List *l = NULL;
\r
816 ugFsNodeInfo *node = NULL;
\r
818 EINA_LIST_FOREACH(*list, l, node) {
\r
819 if ((ugFsNodeInfo *)node != NULL && strlen(((ugFsNodeInfo *)node)->path) != 0) {
\r
820 if (mf_ug_fm_svc_wapper_get_location(node->path) == location){
\r
821 UG_SAFE_FREE_CHAR(node->ext);
\r
822 UG_SAFE_FREE_CHAR(node);
\r
823 *list = eina_list_remove_list(*list, l);
\r
829 int mf_ug_util_generate_root_view_file_list(Eina_List **list, int storage_state)
\r
833 ugFsNodeInfo *pNode = NULL;
\r
834 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
835 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
837 snprintf(pNode->path, sizeof(pNode->path), "%s", PHONE_PARENT);
\r
838 snprintf(pNode->name, sizeof(pNode->name), "%s", PHONE_NAME);
\r
839 pNode->type = UG_FILE_TYPE_DIR;
\r
840 *list = eina_list_append(*list, pNode);
\r
842 if (storage_state == MMC_ON) {
\r
843 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
844 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
846 snprintf(pNode->path, sizeof(pNode->path), "%s", STORAGE_PARENT);
\r
847 snprintf(pNode->name, sizeof(pNode->name), "%s", MMC_NAME);
\r
848 pNode->type = UG_FILE_TYPE_DIR;
\r
849 *list = eina_list_append(*list, pNode);
\r