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
35 #ifdef UG_OPERATION_SELECT_MODE
\r
36 #define OPERATION_SEPERATOR ";"
\r
38 #define NORMAL_SEPERATOR "?"
\r
40 /******************************
\r
41 ** Prototype : ug_genlist_selected_state_get
\r
43 ** Input : void *data
\r
50 ** 1.Date : 2010/12/10
\r
52 ** Modification : Created function
\r
54 ******************************/
\r
55 bool mf_ug_util_is_genlist_selected(void *data)
\r
58 ugData *ugd = (ugData *)data;
\r
59 ug_mf_retvm_if(ugd == NULL, false, "ugd is NULL");
\r
61 Elm_Object_Item *gli = NULL;
\r
62 Elm_Object_Item *nli = NULL;
\r
63 Evas_Object *genlist = NULL;
\r
65 ugNaviBar *pNavi_s = mf_ug_navi_bar_get_in_use_navi(ugd);
\r
66 ug_mf_retvm_if(pNavi_s == NULL, false, "get navigation bar in use failed");
\r
68 if (ugd->ug_MainWindow.ug_pNaviGenlist) {
\r
69 genlist = ugd->ug_MainWindow.ug_pNaviGenlist;
\r
70 gli = elm_genlist_first_item_get(genlist);
\r
73 ugListItemData *itemData = (ugListItemData *)elm_object_item_data_get(gli);
\r
74 ug_mf_retvm_if(itemData == NULL, false, "itemData is NULL");
\r
75 if (itemData->ug_bChecked == true) {
\r
79 nli = elm_genlist_item_next_get(gli);
\r
87 /******************************
\r
88 ** Prototype : ug_parase_path_get
\r
90 ** Input : GList *dest_list
\r
98 ** 1.Date : 2010/12/10
\r
100 ** Modification : Created function
\r
102 ******************************/
\r
103 void mf_ug_util_get_params_path(Eina_List **dest_list, const char *path_list)
\r
106 ug_mf_retm_if(dest_list == NULL, "dest_list is NULL");
\r
108 gchar **result = NULL;
\r
109 gchar **params = NULL;
\r
110 result = g_strsplit(path_list, "?", 0);
\r
112 for (params = result; *params; params++) {
\r
113 *dest_list = eina_list_append(*dest_list, strdup(*params));
\r
116 g_strfreev(result);
\r
120 /******************************
\r
121 ** Prototype : mf_ug_util_free_eina_list_data
\r
122 ** Description : Samsung
\r
123 ** Input : Eina_List **list
\r
124 ** mf_ug_eina_list_node_type node_type
\r
131 ** 1.Date : 2010/12/10
\r
132 ** Author : Samsung
\r
133 ** Modification : Created function
\r
135 ******************************/
\r
136 void mf_ug_util_free_eina_list_data(Eina_List **list, mf_ug_eina_list_node_type node_type)
\r
139 ug_mf_retm_if(list == NULL, "list is NULL");
\r
140 ug_mf_retm_if(*list == NULL, "*list is NULL");
\r
142 Eina_List *l = NULL;
\r
143 void *pNode = NULL;
\r
144 switch (node_type) {
\r
145 case NODE_TYPE_CHAR:
\r
146 case NODE_TYPE_PNODE:
\r
147 EINA_LIST_FOREACH(*list, l, pNode) {
\r
152 case NODE_TYPE_GSTRING:
\r
153 EINA_LIST_FOREACH(*list, l, pNode) {
\r
154 if (pNode != NULL) {
\r
155 g_string_free(pNode, TRUE);
\r
164 eina_list_free(*list);
\r
170 /******************************
\r
171 ** Prototype : __mf_ug_util_get_marked_selected_items
\r
173 ** Input : GList *list
\r
180 ** 1.Date : 2010/12/10
\r
181 ** Author : Samsung
\r
182 ** Modification : Created function
\r
184 ******************************/
\r
185 static void __mf_ug_util_get_marked_selected_items(Eina_List *list, Eina_List **select_list)
\r
188 ug_mf_retm_if(select_list == NULL, "select_list is NULL");
\r
189 ug_mf_retm_if(list == NULL, "list is NULL");
\r
191 Eina_List *l = NULL;
\r
192 void *pNode = NULL;
\r
194 EINA_LIST_FOREACH(list, l, pNode) {
\r
195 if (pNode != NULL) {
\r
196 *select_list = eina_list_append(*select_list, strdup(pNode));
\r
203 /******************************
\r
204 ** Prototype : __mf_ug_util_get_marked_off_selected_items
\r
206 ** Input : void *data
\r
207 ** Evas_Object* content
\r
214 ** 1.Date : 2010/12/10
\r
215 ** Author : Samsung
\r
216 ** Modification : Created function
\r
218 ******************************/
\r
219 static void __mf_ug_util_get_marked_off_selected_items(void *data, Eina_List **select_list)
\r
222 ugData *ugd = (ugData *)data;
\r
223 ug_mf_retm_if(ugd == NULL, "ugData is NULL");
\r
224 ug_mf_retm_if(select_list == NULL, "selected_list is NULL");
\r
225 ug_mf_retm_if(ugd->ug_MainWindow.ug_pNaviGenlist == NULL, "ugd->ug_MainWindow.ug_pNaviGenlist is NULL");
\r
228 Evas_Object *content = ugd->ug_MainWindow.ug_pNaviGenlist;
\r
229 Elm_Object_Item *gli = elm_genlist_first_item_get(content);
\r
231 Elm_Object_Item *nli = NULL;
\r
236 ugListItemData *params = (ugListItemData *)elm_object_item_data_get(gli);
\r
237 ug_mf_retm_if(params == NULL, "params is NULL");
\r
238 if (ugd->ug_UiGadget.ug_iSelectMode == SINGLE_ALL_MODE || ugd->ug_UiGadget.ug_iSelectMode == SINGLE_FILE_MODE) {
\r
239 if (params->ug_pRadioBox) {
\r
240 if (elm_radio_value_get(ugd->ug_MainWindow.ug_pRadioGroup) == radio_id) {
\r
241 *select_list = eina_list_append(*select_list, strdup(params->ug_pItemName->str));
\r
246 } else if (ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE ||
\r
247 ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE ||
\r
248 ugd->ug_UiGadget.ug_iSelectMode == IMPORT_MODE ||
\r
249 ugd->ug_UiGadget.ug_iSelectMode == IMPORT_PATH_SELECT_MODE ||
\r
250 ugd->ug_UiGadget.ug_iSelectMode == IMPORT_SINGLE) {
\r
251 if (params->ug_pCheckBox) {
\r
252 if (params->ug_bChecked == true) {
\r
253 *select_list = eina_list_append(*select_list, strdup(params->ug_pItemName->str));
\r
257 nli = elm_genlist_item_next_get(gli);
\r
263 /******************************
\r
264 ** Prototype : mf_ug_util_get_send_result
\r
266 ** Input : void *data
\r
273 ** 1.Date : 2010/12/10
\r
274 ** Author : Samsung
\r
275 ** Modification : Created function
\r
277 ******************************/
\r
278 char *mf_ug_util_get_send_result(void *data)
\r
281 ugData *ugd = (ugData *)data;
\r
282 ug_mf_retvm_if(ugd == NULL, NULL, "ugData is NULL");
\r
284 char *file_selected = NULL;
\r
285 Eina_List *selected_list = NULL;
\r
286 Eina_List *l = NULL;
\r
287 char *pNode = NULL;
\r
289 if (ugd->ug_UiGadget.ug_iMarkedMode == MARKED_ON
\r
290 && (ugd->ug_UiGadget.ug_iSelectMode == MULTI_FILE_MODE || ugd->ug_UiGadget.ug_iSelectMode == MULTI_ALL_MODE)) {
\r
291 __mf_ug_util_get_marked_selected_items(ugd->ug_UiGadget.ug_pMultiSelectFileList, &selected_list);
\r
293 __mf_ug_util_get_marked_off_selected_items(ugd, &selected_list);
\r
296 EINA_LIST_FOREACH(selected_list, l, pNode) {
\r
297 if (pNode != NULL) {
\r
298 if (file_selected == NULL) {
\r
299 file_selected = g_strconcat(pNode, NULL);
\r
301 char *temp = file_selected;
\r
302 #ifdef UG_OPERATION_SELECT_MODE
\r
303 if (ugd->ug_UiGadget.ug_bOperationSelectFlag) {
\r
304 file_selected = g_strconcat(file_selected, OPERATION_SEPERATOR, pNode, NULL);
\r
307 file_selected = g_strconcat(file_selected, NORMAL_SEPERATOR, pNode, NULL);
\r
312 mf_ug_util_free_eina_list_data(&selected_list, NODE_TYPE_CHAR);
\r
314 return file_selected;
\r
318 /******************************
\r
319 ** Prototype : _ug_mf_set_state_as
\r
321 ** Input : struct ugmyfiledata* data
\r
329 ** 1.Date : 2010/12/10
\r
330 ** Author : Samsung
\r
331 ** Modification : Created function
\r
333 ******************************/
\r
334 void mf_ug_util_set_current_state(void *data, int state)
\r
337 ugData *ugd = (ugData *)data;
\r
338 ug_mf_retm_if(ugd == NULL, "ugd is NULL");
\r
340 ugd->ug_Status.ug_iState = state;
\r
345 /******************************
\r
346 ** Prototype : mf_ug_util_get_mmc_state
\r
348 ** Input : int* mmc_card
\r
355 ** 1.Date : 2010/12/10
\r
356 ** Author : Samsung
\r
357 ** Modification : Created function
\r
359 ******************************/
\r
360 int mf_ug_util_get_mmc_state(int *mmc_card)
\r
363 int data = UG_ERROR_RETURN;
\r
364 int error_code = MYFILE_ERR_NONE;
\r
366 ug_mf_retvm_if(mmc_card == NULL, MYFILE_ERR_SRC_ARG_INVALID, "mmc_card is NULL");
\r
369 error_code = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &data);
\r
373 return MYFILE_ERR_GET_VCONF_FAIL;
\r
376 if (data != VCONFKEY_SYSMAN_MMC_MOUNTED) {
\r
377 *mmc_card = MMC_OFF;
\r
379 *mmc_card = MMC_ON;
\r
385 /******************************
\r
386 ** Prototype : mf_ug_util_create_dir_monitor
\r
387 ** Description : Samsung
\r
388 ** Input : void *data
\r
395 ** 1.Date : 2010/12/10
\r
396 ** Author : Samsung
\r
397 ** Modification : Created function
\r
399 ******************************/
\r
400 int mf_ug_util_create_dir_monitor(void *data)
\r
403 ugData *ugd = (ugData *)data;
\r
404 ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugData is NULL");
\r
406 if (ugd->ug_UiGadget.ug_pInotifyPipe) {
\r
407 ecore_pipe_del(ugd->ug_UiGadget.ug_pInotifyPipe);
\r
408 ugd->ug_UiGadget.ug_pInotifyPipe = NULL;
\r
410 ugd->ug_UiGadget.ug_pInotifyPipe = ecore_pipe_add(mf_ug_cb_dir_pipe_cb, (const void *)ugd);
\r
413 return mf_ug_inotify_handle_init_inotify();
\r
417 /******************************
\r
418 ** Prototype : mf_ug_util_add_dir_watch
\r
419 ** Description : Samsung
\r
420 ** Input : const char *path
\r
428 ** 1.Date : 2010/12/10
\r
429 ** Author : Samsung
\r
430 ** Modification : Created function
\r
432 ******************************/
\r
433 int mf_ug_util_add_dir_watch(const char *path, void *data)
\r
436 ugData *ugd = (ugData *)data;
\r
437 ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugd is NULL");
\r
438 UG_SAFE_FREE_CHAR(ugd->ug_Status.monitor_path);
\r
439 ugd->ug_Status.monitor_path = g_strdup(path);
\r
440 return mf_ug_inotify_handle_add_inotify_watch(path, mf_ug_cb_dir_update_cb, data);
\r
443 int mf_ug_util_remove_dir_watch(void)
\r
445 return mf_ug_inotify_handle_rm_inotify_watch();
\r
448 /******************************
\r
449 ** Prototype : mf_ug_util_set_mmc_state_cb
\r
450 ** Description : Samsung
\r
451 ** Input : void *data
\r
458 ** 1.Date : 2010/12/10
\r
459 ** Author : Samsung
\r
460 ** Modification : Created function
\r
462 ******************************/
\r
463 int mf_ug_util_set_mmc_state_cb(void *data)
\r
466 ugData *ugd = (ugData *)data;
\r
467 ug_mf_retvm_if(ugd == NULL, UG_ERROR_RETURN, "ugd is NULL");
\r
469 int mmc_state = MMC_OFF;
\r
470 mf_ug_util_get_mmc_state(&mmc_state);
\r
471 ugd->ug_Status.ug_iMmcFlag = mmc_state;
\r
474 return vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, mf_ug_cb_mmc_changed_cb, ugd);
\r
477 /******************************
\r
478 ** Prototype : mf_ug_util_destory_mmc_state_cb
\r
479 ** Description : Samsung
\r
487 ** 1.Date : 2010/12/10
\r
488 ** Author : Samsung
\r
489 ** Modification : Created function
\r
491 ******************************/
\r
492 void mf_ug_util_destory_mmc_state_cb()
\r
495 vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, mf_ug_cb_mmc_changed_cb);
\r
499 /******************************
\r
500 ** Prototype : mf_ug_util_destory_dir_monitor
\r
501 ** Description : Samsung
\r
502 ** Input : void *data
\r
509 ** 1.Date : 2010/12/10
\r
510 ** Author : Samsung
\r
511 ** Modification : Created function
\r
513 ******************************/
\r
514 void mf_ug_util_destory_dir_monitor(void *data)
\r
517 ugData *ugd = (ugData *)data;
\r
518 ug_mf_retm_if(ugd == NULL, "ugd is NULL");
\r
520 if (ugd->ug_UiGadget.ug_pInotifyPipe) {
\r
521 ecore_pipe_del(ugd->ug_UiGadget.ug_pInotifyPipe);
\r
522 ugd->ug_UiGadget.ug_pInotifyPipe = NULL;
\r
525 mf_ug_inotify_handle_finalize_inotify();
\r
532 /******************************
\r
533 ** Prototype : mf_ug_util_storage_insert_action
\r
534 ** Description : Samsung
\r
535 ** Input : void *data
\r
536 ** char* pItemLabel
\r
543 ** 1.Date : 2010/12/10
\r
544 ** Author : Samsung
\r
545 ** Modification : Created function
\r
547 ******************************/
\r
548 void mf_ug_util_storage_insert_action(void *data, char *pItemLabel)
\r
551 ugData *ugd = (ugData *)data;
\r
552 ug_mf_retm_if(ugd == NULL, "ugd is NULL");
\r
554 Elm_Object_Item *pItemPhone = NULL;
\r
555 ugFsNodeInfo *pNode = NULL;
\r
557 if (ugd->ug_Status.ug_iViewType != mf_ug_view_root) {
\r
562 if (ugd->ug_Status.ug_iMmcFlag) {
\r
563 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
564 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
566 snprintf(pNode->path, sizeof(pNode->path), "%s", STORAGE_PARENT);
\r
567 snprintf(pNode->name, sizeof(pNode->name), "%s", MMC_NAME);
\r
568 pNode->type = UG_FILE_TYPE_DIR;
\r
569 ugd->ug_UiGadget.ug_pDirList = eina_list_append(ugd->ug_UiGadget.ug_pDirList, pNode);
\r
570 mf_ug_genlist_item_append(ugd->ug_MainWindow.ug_pNaviGenlist, pNode, ugd, 0, &ugd->ug_Status.ug_normalitc);
\r
578 /******************************
\r
579 ** Prototype : mf_ug_util_get_file_launch_type
\r
581 ** Input : char * path
\r
582 ** Output : UG_MYFILE_LAUNCH_TYPE
\r
588 ** 1.Date : 2010/12/10
\r
589 ** Author : Samsung
\r
590 ** Modification : Created function
\r
592 ******************************/
\r
593 mf_ug_launch_type mf_ug_util_get_file_launch_type(char *path)
\r
595 if (path == NULL) {
\r
597 return LAUNCH_TYPE_UNSUPPORT;
\r
599 if (ecore_file_file_get(path) == NULL) {
\r
601 return LAUNCH_TYPE_UNSUPPORT;
\r
603 if (ecore_file_is_dir(path) == 1) {
\r
605 return LAUNCH_TYPE_UNSUPPORT;
\r
607 if (mf_ug_file_attr_is_drm_file(path) == 0) {
\r
608 mf_ug_drm_file_mime_type drm_file_type = mf_ug_fs_oper_get_drm_type(path);
\r
610 if (drm_file_type == MF_UG_DRM_RINGTONE_FILE) {
\r
612 return LAUNCH_TYPE_MUSIC;
\r
613 } else if (drm_file_type == MF_UG_DRM_IMAGE_FILE) {
\r
615 return LAUNCH_TYPE_IMAGE;
\r
616 } else if (drm_file_type == MF_UG_DRM_VIDEO_FILE) {
\r
618 return LAUNCH_TYPE_VIDEO;
\r
621 return LAUNCH_TYPE_UNSUPPORT;
\r
624 mf_ug_fs_file_type category_t = 0;
\r
625 mf_ug_file_attr_get_file_category(path, &category_t);
\r
626 if (category_t == UG_FILE_TYPE_MUSIC || category_t == UG_FILE_TYPE_SOUND || category_t == UG_FILE_TYPE_VOICE) {
\r
628 return LAUNCH_TYPE_MUSIC;
\r
629 } else if (category_t == UG_FILE_TYPE_IMAGE) {
\r
631 return LAUNCH_TYPE_IMAGE;
\r
634 return LAUNCH_TYPE_UNSUPPORT;
\r
640 mf_ug_theme_type mf_ug_util_get_theme(void)
\r
642 mf_ug_theme_type theme = UG_THEME_INVALID;
\r
645 char *theme_name = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR);
\r
646 ug_debug("theme is [%s]", theme_name);
\r
647 ug_mf_retvm_if(theme_name == NULL, UG_THEME_ERROR, "Failed to get vconf value"); /* file system exceptional handle */
\r
649 name = strrchr(theme_name, '/');
\r
656 ug_debug("name is [%s]", name);
\r
657 //SETTING_TRACE("name:%s", name);
\r
658 /* special theme process.. */
\r
659 if (0 == g_strcmp0("tizen-black.edj", name) || 0 == g_strcmp0("tizen-black-hd.edj", name)) {
\r
660 theme = UG_THEME_NBEAT_BLACK;
\r
661 } else if (0 == g_strcmp0("tizen.edj", name) || 0 == g_strcmp0("tizen-hd.edj", name)
\r
662 || 0 == g_strcmp0("blue-hd.edj", name)) {
\r
663 theme = UG_THEME_NBEAT;
\r
665 theme = UG_THEME_ERROR;
\r
669 ug_debug("theme is [%d]", theme);
\r
674 char *mf_ug_util_upper_folder_name_get(void *data, GString *fullpath)
\r
676 ug_mf_retvm_if(data == NULL, NULL, "data is NULL");
\r
677 ug_mf_retvm_if(fullpath == NULL, NULL, "fullpath is NULL");
\r
678 ug_mf_retvm_if(fullpath->str == NULL, NULL, "fullpath is NULL");
\r
680 GString *parent_path = NULL;
\r
681 GString *gName = NULL;
\r
682 char *upper_name = NULL;
\r
684 parent_path = mf_ug_fm_svc_wrapper_get_file_parent_path(fullpath);
\r
686 ug_mf_retvm_if(parent_path == NULL, NULL, "fullpath is NULL");
\r
687 ug_mf_retvm_if(parent_path->str == NULL, NULL, "fullpath is NULL");
\r
690 if (!g_strcmp0(parent_path->str, PHONE_FOLDER)) {
\r
691 upper_name = g_strdup(MF_UG_LABEL_PHONE);
\r
692 } else if (!g_strcmp0(parent_path->str, MEMORY_FOLDER)) {
\r
693 upper_name = g_strdup(MF_UG_LABEL_MMC);
\r
695 gName = mf_ug_fm_svc_wapper_get_file_name(parent_path);
\r
696 UG_GSTRING_CHECK_NULL_GOTO(gName, FAILED_EXIT);
\r
697 upper_name = g_strdup(gName->str);
\r
700 UG_CHAR_CHECK_NULL_GOTO(upper_name, FAILED_EXIT);
\r
701 UG_SAFE_FREE_GSTRING(parent_path);
\r
702 UG_SAFE_FREE_GSTRING(gName);
\r
706 UG_SAFE_FREE_GSTRING(parent_path);
\r
707 UG_SAFE_FREE_GSTRING(gName);
\r
712 void mf_ug_util_sort_the_file_list(void *data)
\r
716 ug_mf_retm_if(data == NULL, "data is null");
\r
717 ugData *ugd = (ugData *)data;
\r
719 int iSortTypeValue = 0;
\r
721 iSortTypeValue = ugd->ug_Status.ug_iSortType;
\r
723 mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pFilterList, MF_UG_SORT_BY_NAME_A2Z);
\r
724 mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pDirList, MF_UG_SORT_BY_NAME_A2Z);
\r
726 //mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pFilterList, iSortTypeValue);
\r
727 /*need to sort folder items only By Name and Date*/
\r
728 //mf_ug_fs_oper_sort_list(&ugd->ug_UiGadget.ug_pDirList, iSortTypeValue);
\r
731 int mf_ug_util_check_disk_space(void *data)
\r
734 ug_mf_retvm_if(data == NULL, MYFILE_ERR_SRC_ARG_INVALID, "data is null");
\r
735 ugData *ugd = (ugData *)data;
\r
737 mf_ug_storage_type state = MF_UG_NONE;
\r
738 unsigned long free_space = 0;
\r
740 if (ugd->ug_Status.ug_iMore == UG_MORE_CREATE_FOLDER) {
\r
741 state = mf_ug_fm_svc_wapper_get_location(ugd->ug_Status.ug_pPath->str);
\r
742 free_space = mf_ug_fm_svc_wrapper_get_free_space(state);
\r
743 ug_debug("free size is %lu\n", free_space);
\r
745 ** in vfat fs type, sector size is 16K.
\r
746 ** it is to say that the limited size of the free space should be 16K
\r
747 ** or it will report space used up.
\r
748 ** check free_space == 0 can make sure at least 16K is free on the disk
\r
749 ** while every dir takes 4K
\r
751 if (free_space == 0) {
\r
752 ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL,
\r
753 MF_UG_LABEL_NOT_ENOUGH_SPACE, MF_UG_LABEL_OK,
\r
754 NULL, NULL, mf_ug_cb_warning_popup_cb, ugd);
\r
755 return MYFILE_ERR_NO_FREE_SPACE;
\r
759 return MYFILE_ERR_NONE;
\r
762 void mf_ug_util_operation_alloc_failed(void *data)
\r
765 ug_mf_retm_if(data == NULL, "data is null");
\r
766 ugData *ugd = (ugData *)data;
\r
768 ugd->ug_MainWindow.ug_pNormalPopup = mf_ug_popup_create(ugd, UG_POPMODE_TEXT, NULL, MF_UG_LABEL_MEMORY_NOT_ENOUGH,
\r
769 NULL, NULL, NULL, (Evas_Smart_Cb) elm_exit, NULL);
\r
772 long mf_ug_util_character_count_get(const char *original)
\r
774 ug_mf_retvm_if(original == NULL, 0, "input string is NULL");
\r
776 char *utf8_form = g_locale_to_utf8(original, -1, NULL, NULL, NULL);
\r
777 if (utf8_form == NULL)
\r
780 count = g_utf8_strlen(utf8_form, -1);
\r
782 ug_debug("utf8 count is %ld", count);
\r
787 ugFsNodeInfo *mf_ug_util_generate_pnode(const char *path, int file_type)
\r
789 ug_mf_retvm_if(path == NULL, NULL, "path is NULL");
\r
790 ugFsNodeInfo *pNode = NULL;
\r
791 int error = MYFILE_ERR_NONE;
\r
793 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
794 if (pNode == NULL) {
\r
797 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
798 char *parent = NULL;
\r
799 error = mf_ug_file_attr_get_parent_path(path, &parent);
\r
800 if (error == MYFILE_ERR_NONE) {
\r
801 snprintf(pNode->path, sizeof(pNode->path), "%s", parent);
\r
802 snprintf(pNode->name, sizeof(pNode->name), "%s", ecore_file_file_get(path));
\r
803 mf_ug_file_attr_get_file_stat(path, &pNode);
\r
804 if (file_type == UG_FILE_TYPE_DIR) {
\r
805 pNode->type = file_type;
\r
807 mf_ug_file_attr_get_file_category(path, &(pNode->type));
\r
810 UG_SAFE_FREE_CHAR(pNode);
\r
815 void mf_util_generate_list(Eina_List **list, const char *path, int file_type)
\r
817 ug_mf_retm_if(list == NULL, "list is NULL");
\r
818 ug_mf_retm_if(path == NULL, "path is NULL");
\r
820 ugFsNodeInfo *pNode = mf_ug_util_generate_pnode(path, file_type);
\r
823 *list = eina_list_append(*list, pNode);
\r
826 void mf_util_remove_item_from_list_by_location(Eina_List **list, int location)
\r
828 ug_mf_retm_if(list == NULL, "list is NULL");
\r
830 Eina_List *l = NULL;
\r
831 ugFsNodeInfo *node = NULL;
\r
833 EINA_LIST_FOREACH(*list, l, node) {
\r
834 if ((ugFsNodeInfo *)node != NULL && strlen(((ugFsNodeInfo *)node)->path) != 0) {
\r
835 if (mf_ug_fm_svc_wapper_get_location(node->path) == location){
\r
836 UG_SAFE_FREE_CHAR(node->ext);
\r
837 UG_SAFE_FREE_CHAR(node);
\r
838 *list = eina_list_remove_list(*list, l);
\r
844 int mf_ug_util_generate_root_view_file_list(Eina_List **list, int storage_state)
\r
848 ugFsNodeInfo *pNode = NULL;
\r
849 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
850 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
852 snprintf(pNode->path, sizeof(pNode->path), "%s", PHONE_PARENT);
\r
853 snprintf(pNode->name, sizeof(pNode->name), "%s", PHONE_NAME);
\r
854 pNode->type = UG_FILE_TYPE_DIR;
\r
855 *list = eina_list_append(*list, pNode);
\r
857 if (storage_state == MMC_ON) {
\r
858 pNode = (ugFsNodeInfo *) malloc(sizeof(ugFsNodeInfo));
\r
859 memset(pNode, 0, sizeof(ugFsNodeInfo));
\r
861 snprintf(pNode->path, sizeof(pNode->path), "%s", STORAGE_PARENT);
\r
862 snprintf(pNode->name, sizeof(pNode->name), "%s", MMC_NAME);
\r
863 pNode->type = UG_FILE_TYPE_DIR;
\r
864 *list = eina_list_append(*list, pNode);
\r