Tizen 2.0 Release
[apps/core/preloaded/myfiles.git] / src / common / mf-callback.c
1 /*
2  * Copyright 2013         Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *  http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18
19
20
21 #include <stdio.h>
22
23
24 #include <dbus/dbus.h>
25
26 #include <pthread.h>
27 #include <vconf.h>
28 #include <vconf-keys.h>
29 #include "mf-main.h"
30 #include "mf-conf.h"
31 #include "mf-util.h"
32 #include "mf-callback.h"
33 #include "mf-fm-svc-wrapper.h"
34
35 #include "mf-widget.h"
36 #include "mf-fs-util.h"
37 #include "mf-launch.h"
38 #include "mf-dlog.h"
39 #include "mf-inotify-handle.h"
40 #include "mf-copy.h"
41 #include "mf-delete.h"
42 #include "mf-move.h"
43 #include "mf-otg.h"
44 #include "mf-resource.h"
45 #include "mf-language-mgr.h"
46 #include "mf-s-beam.h"
47 #include "mf-share.h"
48
49
50 struct appdata *temp_data;
51 pthread_mutex_t pb_mutex = PTHREAD_MUTEX_INITIALIZER;
52 /* mutex for refresh */
53 pthread_mutex_t refresh_mutex = PTHREAD_MUTEX_INITIALIZER;
54 /* mutex for dbus message */
55 pthread_mutex_t refresh_lock;
56 pthread_cond_t refresh_finished;
57 unsigned int refresh_flag = 0;
58 typedef struct _mf_dir_event_t {
59         int event;
60         char *name;
61 } mf_dir_event_t;
62
63 void mf_callback_save_cb(void *data, Evas_Object * obj, void *event_info);
64 void mf_callback_cancel_cb(void *data, Evas_Object * obj, void *event_info);
65 static void __mf_callback_mmc_removed(void *data, MF_STORAGE storage);
66
67 /******************************
68 ** Prototype    : mf_callback_warning_popup_cb
69 ** Description  :
70 ** Input        : void *data
71 **                Evas_Object *obj
72 **                void *event_info
73 ** Output       : None
74 ** Return Value :
75 ** Calls        :
76 ** Called By    :
77 **
78 **  History        :
79 **  1.Date         : 2010/12/10
80 **    Author       : Samsung
81 **    Modification : Created function
82 **
83 ******************************/
84 void mf_callback_warning_popup_cb(void *data, Evas_Object * obj, void *event_info)
85 {
86         struct appdata *ap = (struct appdata *)data;
87         assert(ap);
88
89         Evas_Object *btn = (Evas_Object *)obj;
90         const char *label = elm_object_text_get(btn);
91
92         if (g_strcmp0(label, GET_SYS_STR(MF_BUTTON_LABEL_OK)) == 0 ) {
93                 evas_object_del(ap->mf_MainWindow.pNormalPopup);
94                 ap->mf_MainWindow.pNormalPopup = NULL;
95         }
96 }
97
98 /******************************
99 ** Prototype    : mf_callback_app_rotate_cb
100 ** Description  :
101 ** Input        : enum appcore_rm mode
102 **                void *data
103 ** Output       : None
104 ** Return Value :
105 ** Calls        :
106 ** Called By    :
107 **
108 **  History        :
109 **  1.Date         : 2010/12/10
110 **    Author       : Samsung
111 **    Modification : Created function
112 **
113 ******************************/
114 #ifdef MYFILE_SPLIT_VIEW
115
116 static Eina_Bool __mf_callback_do_rotation_cb (void *data)
117 {
118         MF_TRACE_BEGIN;
119         struct appdata *ap = data;
120         assert(ap);
121
122         mf_widget_create(ap);
123         mf_widget_set_main_layout_content(ap);
124
125         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
126                 if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
127                         mf_split_view_refresh(ap);
128                 }
129         } else {
130                 if (!(ap->mf_Status.more == MORE_EDIT ||
131                     ap->mf_Status.more == MORE_CREATE_FOLDER ||
132                     ap->mf_Status.more == MORE_THUMBNAIL_RENAME ||
133                     (ap->mf_Status.more == MORE_RENAME && ap->mf_Status.preMore == MORE_EDIT) ||
134                     ap->mf_Status.more == MORE_SEARCH || (ap->mf_Status.more == MORE_RENAME && ap->mf_Status.preMore == MORE_SEARCH))) {
135                         if (ap->mf_Status.more == MORE_DEFAULT) {
136                                 mf_navi_bar_create_default_view(ap);
137                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
138                         } else if (ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
139                                    || ap->mf_Status.more == MORE_DATA_COPYING || ap->mf_Status.more == MORE_DATA_MOVING) {
140                                 mf_navi_bar_create_path_select_view(ap);
141                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
142                         }
143                 }
144                 if (ap->mf_Status.more == MORE_EDIT) {
145                         mf_navi_bar_title_set(ap);
146                 }
147
148         }
149
150         if (ap->mf_Status.more == MORE_RENAME || ap->mf_Status.more == MORE_SEARCH || ap->mf_Status.more == MORE_CREATE_FOLDER || (ap->mf_Status.more == MORE_RENAME && ap->mf_Status.preMore == MORE_SEARCH)) {
151                 if (ap->mf_MainWindow.pEntry) {
152                         if (ap->mf_Status.flagIME != EINA_FALSE) {
153                                 if (ap->mf_MainWindow.pNormalPopup == NULL) {
154                                         elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_TRUE);
155                                 }
156                         }
157                 }
158         }
159         if (ap->mf_Status.more == MORE_SEARCH) {
160                 if (ap->mf_MainWindow.pSearchEntry) {
161                         if (ap->mf_Status.flagIME != EINA_FALSE) {
162                                 if (ap->mf_MainWindow.pNormalPopup == NULL) {
163                                         elm_object_focus_set(ap->mf_MainWindow.pSearchEntry, EINA_TRUE);
164                                 }
165                         }
166                 }
167         }
168
169         mf_genlist_gl_edit_item_selected(ap);/*note: for plm issue:P121002-2027*/
170         mf_navi_bar_title_set(ap);
171         MF_TRACE_END;
172
173         return ECORE_CALLBACK_CANCEL;
174 }
175
176 void mf_callback_app_rotate_cb(app_device_orientation_e  mode, void *data)
177 {
178         MF_TRACE_BEGIN;
179         struct appdata *ap = data;
180         assert(ap);
181
182         if (ap->mf_Status.pre_rotate_type == mode)
183                 return;
184
185         const char *config = elm_config_profile_get();
186         if (!strcmp(config, "desktop"))
187                 return;
188
189         enum ug_event evt = UG_EVENT_NONE;
190
191         switch (mode) {
192         case APP_DEVICE_ORIENTATION_270:
193                 ap->mf_Status.rotation_angle = -90;
194                 ap->mf_Status.view_mode_end = FALSE;
195                 ap->mf_Status.pre_rotate_type = APP_DEVICE_ORIENTATION_270;
196                 evt = UG_EVENT_ROTATE_LANDSCAPE;
197                 break;
198
199         case APP_DEVICE_ORIENTATION_90:
200                 ap->mf_Status.rotation_angle = 90;
201                 ap->mf_Status.view_mode_end = FALSE;
202                 ap->mf_Status.pre_rotate_type = APP_DEVICE_ORIENTATION_90;
203                 evt = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
204                 break;
205
206         case APP_DEVICE_ORIENTATION_180:
207                 ap->mf_Status.rotation_angle = 180;
208                 ap->mf_Status.view_mode_end = TRUE;
209                 ap->mf_Status.pre_rotate_type = APP_DEVICE_ORIENTATION_180;
210                 evt = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
211                 break;
212
213         case APP_DEVICE_ORIENTATION_0 :
214         default:
215                 ap->mf_Status.rotation_angle = 0;
216                 ap->mf_Status.view_mode_end = TRUE;
217                 ap->mf_Status.pre_rotate_type = APP_DEVICE_ORIENTATION_0;
218                 evt = UG_EVENT_ROTATE_PORTRAIT;
219                 break;
220         }
221
222         ug_send_event(evt);
223
224         if (ap->mf_MainWindow.pContextPopup) {
225                 evas_object_del(ap->mf_MainWindow.pContextPopup);
226                 ap->mf_MainWindow.pContextPopup = NULL;
227                 ap->mf_Status.flagCtxPopShow = EINA_TRUE;
228         } else {
229                 ap->mf_Status.flagCtxPopShow = EINA_FALSE;
230         }
231
232         if (mode == APP_DEVICE_ORIENTATION_270 || mode == APP_DEVICE_ORIENTATION_90) {
233                 ap->mf_Status.rotation_type = MF_ROTATE_LANDSCAPE;
234         } else {
235                 ap->mf_Status.rotation_type = MF_ROTATE_PORTRAIT;
236         }
237         elm_win_rotation_with_resize_set(ap->mf_MainWindow.pWindow, ap->mf_Status.rotation_angle);
238         __mf_callback_do_rotation_cb(ap);
239
240         MF_TRACE_END;
241 }
242
243 #else
244
245 void mf_callback_app_rotate_cb(app_device_orientation_e  mode, void *data)
246 {
247         struct appdata *ap = data;
248         assert(ap);
249
250         ap->mf_Status.rotation_type = mode;
251
252         if (ap->mf_FileOperation.ugImageViewer) {
253                 enum ug_mode md = ug_get_mode(ap->mf_FileOperation.ugImageViewer);
254                 enum ug_event ev = UG_EVENT_ROTATE_LANDSCAPE;
255                 if (md == UG_MODE_FULLVIEW) {
256                         switch (mode) {
257                         case APP_DEVICE_ORIENTATION_0 :
258                                 elm_win_rotation_with_resize_set(ap->mf_MainWindow.pWindow, 0);
259                                 ev = UG_EVENT_ROTATE_PORTRAIT;
260                                 break;
261                         case APP_DEVICE_ORIENTATION_180:
262                                 elm_win_rotation_with_resize_set(ap->mf_MainWindow.pWindow, 180);
263                                 ev = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
264                                 break;
265                         case APP_DEVICE_ORIENTATION_270:
266                                 elm_win_rotation_with_resize_set(ap->mf_MainWindow.pWindow, 270);
267                                 ev = UG_EVENT_ROTATE_LANDSCAPE;
268                                 break;
269                         case APP_DEVICE_ORIENTATION_90:
270                                 elm_win_rotation_with_resize_set(ap->mf_MainWindow.pWindow, 90);
271                                 ev = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
272                                 break;
273                         default:
274                                 break;
275                         }
276                         /*send event to ug */
277                         ug_send_event(ev);
278                 }
279         }
280 }
281 #endif
282
283 #ifdef MYFILE_SPLIT_VIEW
284 void mf_callback_storage_cb(void *data, const char *label)
285 {
286         MF_TRACE_BEGIN;
287         mf_retm_if(data == NULL, "data is NULL");
288         mf_retm_if(label == NULL, "label is NULL");
289
290         struct appdata *ap = (struct appdata *)data;
291         mf_retm_if(ap->mf_Status.path == NULL, "ap->mf_Status.path is NULL");
292         mf_retm_if(ap->mf_Status.path->str == NULL, "ap->mf_Status.path->str is NULL");
293         Evas_Object *pNaviBar = NULL;
294         myfileNaviBar *pNavi_s_inuse = NULL;
295         myfileNaviBar *pNavi_s_toshow = NULL;
296         myfileNaviBar *pNaviBarStruct = NULL;
297         char *rootpath = NULL;
298         int current_storage = MYFILE_PHONE;
299         int current_more = ap->mf_Status.more;
300         pNavi_s_inuse = mf_navi_bar_get_in_use(ap);
301
302         current_storage = mf_fm_svc_wrapper_get_location(ap->mf_Status.path->str);
303
304         if (g_strcmp0(pNavi_s_inuse->pNaviLabel, label) == 0) {
305                 MF_TRACE_END;
306                 return;
307         } else {
308                 if (ap->mf_Status.more == MORE_SEARCH) {
309                         ap->mf_Status.more = MORE_DEFAULT;
310                 }
311                 pNavi_s_inuse->naviFlagInUse = FALSE;
312                 pNaviBarStruct = mf_navi_bar_get_navi_from_navilist(ap->mf_MainWindow.plistNaviBar, label);
313
314
315                 if (pNaviBarStruct == NULL) {
316                         /*2.0   get root path by storage label */
317                         rootpath = mf_fm_svc_wrapper_get_root_path_by_tab_label(label);
318                         CHAR_CHECK_NULL_GOTO(rootpath, ERROR_EXIT);
319
320                         /*2.1   create the navi for the tab */
321                         pNavi_s_toshow = malloc(sizeof(myfileNaviBar));
322                         CHAR_CHECK_NULL_GOTO(pNavi_s_toshow, ERROR_EXIT);
323                         memset(pNavi_s_toshow, 0, sizeof(myfileNaviBar));
324
325                         pNavi_s_toshow->naviFlagInUse = TRUE;
326                         /*2.2   set path as root path of the storage */
327                         pNavi_s_toshow->pCurrentPath = g_strdup(rootpath);
328                         pNavi_s_toshow->pNaviLabel = strdup(label);
329                         free(rootpath);
330                         /*2.3   insert phone navi into the navi_list */
331                         ap->mf_MainWindow.plistNaviBar = eina_list_append(ap->mf_MainWindow.plistNaviBar, pNavi_s_toshow);
332
333                         g_string_free(ap->mf_Status.path, TRUE);
334                         ap->mf_Status.path = NULL;
335                         ap->mf_Status.path = g_string_new(pNavi_s_toshow->pCurrentPath);
336                         if (ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
337                             || ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE) {
338                                 SAFE_FREE_GSTRING(pNavi_s_toshow->pre_operation.path);
339                                         pNavi_s_toshow->pre_operation.path = g_string_new(pNavi_s_toshow->pCurrentPath);
340                                         pNavi_s_toshow->naviFlagEditJoin = TRUE;
341                         }
342                         if (ap->mf_Status.more == MORE_DEFAULT) {
343                                 mf_navi_bar_create_default_view(ap);
344                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
345                         } else if (ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
346                                    || ap->mf_Status.more == MORE_DATA_COPYING || ap->mf_Status.more == MORE_DATA_MOVING) {
347                                 mf_navi_bar_create_path_select_view(ap);
348                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
349                         }
350
351                         ap->mf_Status.more = current_more;
352                         goto SUCCESS_EXIT;
353                 } else {
354                         /*2.1   get the navi of the tab */
355                         pNaviBar = ap->mf_MainWindow.pNaviBar;
356                         pNavi_s_toshow = mf_navi_bar_get_struct_by_label(ap, label);
357                         pNavi_s_toshow->naviFlagInUse = TRUE;
358
359                         /*2.2   set related status value. */
360                         g_string_free(ap->mf_Status.path, TRUE);
361                         ap->mf_Status.path = NULL;
362
363                         ap->mf_Status.path = g_string_new(pNavi_s_toshow->pCurrentPath);
364                         /*2.3   update the content to catch update */
365                         /*Todo: How to ensure insert only once */
366                         if (ap->mf_Status.more == MORE_DEFAULT) {
367                                 mf_navi_bar_create_default_view(ap);
368                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
369                         } else if (ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
370                                    || ap->mf_Status.more == MORE_DATA_COPYING || ap->mf_Status.more == MORE_DATA_MOVING) {
371                                 mf_navi_bar_create_path_select_view(ap);
372                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
373                         }
374                         goto SUCCESS_EXIT;
375                 }
376
377         }
378
379 ERROR_EXIT:
380         SAFE_FREE_CHAR(pNavi_s_toshow);
381         SAFE_FREE_CHAR(rootpath);
382         MF_TRACE_END;
383         return;
384
385 SUCCESS_EXIT:
386         MF_TRACE_END;
387         return;
388
389 }
390 #endif
391
392 /******************************
393 ** Prototype    : tab_callback
394 ** Description  :
395 ** Input        : void *data
396 **                Evas_Object *obj
397 **                void *event_info
398 ** Output       : None
399 ** Return Value :
400 ** Calls        :
401 ** Called By    :
402 **
403 **  History        :
404 **  1.Date         : 2010/12/10
405 **    Author       : Samsung
406 **    Modification : Created function
407 **
408 ******************************/
409 void mf_callback_tab_cb(void *data, const char * path)
410 {
411         MF_TRACE_BEGIN;
412         mf_retm_if(data == NULL, "data is NULL");
413         mf_retm_if(path == NULL, "path is NULL");
414         struct appdata *ap = (struct appdata *)data;
415
416         const char *label = NULL;
417         Evas_Object *pNaviBar = NULL;
418         myfileNaviBar *pNavi_s_toshow = NULL;
419         myfileNaviBar *pNavi_s_inuse = NULL;
420 #if 0
421         Elm_Object_Item *it = NULL;
422         it = (Elm_Object_Item *)event_info;
423         label = elm_object_item_text_get(it);
424 #endif
425         int optStorage = 0;
426         optStorage = mf_fm_svc_wrapper_get_location(path);
427         switch (optStorage) {
428         case MYFILE_PHONE:
429                 label = GET_SYS_STR(MF_LABEL_PHONE);
430                 break;
431         case MYFILE_MMC:
432                 label = GET_SYS_STR(MF_LABEL_MMC);
433                 break;
434         case MYFILE_OTG:
435                 label = GET_STR(MF_LABEL_OTG);
436                 break;
437         default:
438                 break;
439         }
440
441
442         if (ap->mf_Status.more == MORE_RENAME)
443                 mf_callback_destory_rename(ap);
444
445         if (label != NULL) {
446                 pNavi_s_inuse = mf_navi_bar_get_in_use(ap);
447                 if (pNavi_s_inuse == NULL || pNavi_s_inuse->pNaviLabel == NULL) {
448                         MF_TRACE_END;
449                         return;
450                 }
451
452 #if 0
453                 if (ap->mf_MainWindow.pNaviItem) {
454                         mf_navi_bottom_item_del(&ap->mf_MainWindow.pNaviItem);
455                 }
456 #endif
457
458                 if (ap->mf_Status.more == MORE_EDIT)
459                         ap->mf_Status.more = MORE_DEFAULT;
460 #ifdef  MYFILE_SPLIT_VIEW
461                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
462                         mf_callback_storage_cb(ap, label);
463                         MF_TRACE_END;
464                         return;
465                 }
466 #endif
467                 /*0. set the previous navi to be out of use */
468                 pNavi_s_inuse->naviFlagInUse = FALSE;
469                 /*1. get navi bar pointer by the label */
470                 pNaviBar = ap->mf_MainWindow.pNaviBar;
471                 pNavi_s_toshow = mf_navi_bar_get_navi_from_navilist(ap->mf_MainWindow.plistNaviBar, label);
472                 /*2. create navi bar if not created, otherwise get it by pNaviBar */
473                 if (pNavi_s_toshow == NULL) {
474                         /*2.0   get root path by storage label */
475                         char *rootpath = mf_fm_svc_wrapper_get_root_path_by_tab_label(label);
476                         if (rootpath == NULL) {
477                                 MF_TRACE_END;
478                                 return;
479                         }
480                         /*2.1   create the navi for the tab */
481                         pNavi_s_toshow = malloc(sizeof(myfileNaviBar));
482                         if (pNavi_s_toshow == NULL) {
483                                 free(rootpath);
484                                 rootpath = NULL;
485                                 mf_debug("pNavi_s_toshow is NULL");
486                                 MF_TRACE_END;
487                                 return;
488                         }
489                         memset(pNavi_s_toshow, 0, sizeof(myfileNaviBar));
490
491                         pNavi_s_toshow->naviFlagInUse = TRUE;
492                         /*2.2   set path as root path of the storage */
493                         pNavi_s_toshow->pCurrentPath = g_strdup(rootpath);
494                         pNavi_s_toshow->pNaviLabel = strdup(label);
495                         free(rootpath);
496                         /*2.3   insert phone navi into the navi_list */
497                         ap->mf_MainWindow.plistNaviBar = eina_list_append(ap->mf_MainWindow.plistNaviBar, pNavi_s_toshow);
498
499                         if (ap->mf_Status.path != NULL) {
500                                 g_string_free(ap->mf_Status.path, TRUE);
501                                 ap->mf_Status.path = NULL;
502                         }
503                         ap->mf_Status.path = g_string_new(pNavi_s_toshow->pCurrentPath);
504                         if (ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
505                             || ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE) {
506                                 pNavi_s_toshow->pre_operation.path = g_string_new(pNavi_s_toshow->pCurrentPath);
507                                 mf_navi_bar_create_path_select_view(ap);
508                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
509                                 pNavi_s_toshow->naviFlagEditJoin = TRUE;
510                         } else {
511                                 mf_navi_bar_create_default_view(ap);
512                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
513                         }
514                         MF_TRACE_END;
515
516
517                 } else {
518                         /*2.1   get the navi of the tab */
519                         pNavi_s_toshow = mf_navi_bar_get_struct_by_label(ap, label);
520                         pNavi_s_toshow->naviFlagInUse = TRUE;
521                         char *rootpath = mf_fm_svc_wrapper_get_root_path_by_tab_label(label);
522
523                         /*2.2   set related status value. */
524                         SAFE_FREE_GSTRING(ap->mf_Status.path);
525                         SAFE_FREE_CHAR(pNavi_s_toshow->pCurrentPath);
526                         ap->mf_Status.path = g_string_new(rootpath);
527                         pNavi_s_toshow->pCurrentPath = rootpath;
528                         /*2.3   update the content to catch update */
529                         /*Todo: How to ensure insert only once */
530                         if ((ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
531                              || ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE)) {
532                                 mf_navi_bar_create_path_select_view(ap);
533                                 pNavi_s_toshow->naviFlagEditJoin = TRUE;
534                         } else {
535                                 mf_navi_bar_create_default_view(ap);
536                         }
537                         mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
538                         MF_TRACE_END;
539                 }
540
541         }
542
543 }
544
545 /******************************
546 ** Prototype    : click_callback
547 ** Description  :
548 ** Input        : struct appdata* data
549 **                mfAction key
550 **                GString* path
551 ** Output       : None
552 ** Return Value :
553 ** Calls        :
554 ** Called By    :
555 **
556 **  History        :
557 **  1.Date         : 2010/12/10
558 **    Author       : Samsung
559 **    Modification : Created function
560 **
561 ******************************/
562 void mf_callback_upper_folder_cb(void *data)
563 {
564         struct appdata *ap = (struct appdata *)data;
565         assert(ap);
566
567         if (ap->mf_Status.flagNaviPush) {
568                 mf_debug("the transition of the naviframe is not finished");
569                 return;
570         }
571
572         GString *parent_path = NULL;
573         int error_code = 0;
574         int mmc_card = 0;
575         error_code = mf_util_is_mmc_on(&mmc_card);
576
577         parent_path = mf_fm_svc_wrapper_get_file_parent_path(ap->mf_Status.path);
578
579         myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
580         mf_retm_if(pNavi_s == NULL, "get navi structure failed");
581         if (ap->mf_Status.path != NULL) {
582                 g_string_free(ap->mf_Status.path, TRUE);
583                 ap->mf_Status.path = NULL;
584         }
585         ap->mf_Status.path = parent_path;
586
587         if (pNavi_s->pCurrentPath != NULL) {
588                 free(pNavi_s->pCurrentPath);
589                 pNavi_s->pCurrentPath = NULL;
590         }
591         pNavi_s->pCurrentPath = g_strdup(parent_path->str);
592
593         if (ap->mf_Status.more == MORE_DEFAULT) {
594                 mf_navi_bar_create_default_view(ap);
595         }
596         mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
597 }
598
599 void mf_callback_upper_button_pressed_cb(void *data, Evas_Object * obj, void *event_info)
600 {
601         MF_TRACE_BEGIN;
602         mf_retm_if(data == NULL, "data is NULL");
603
604         Evas_Object *upper_button_ic = (Evas_Object *)data;
605         elm_image_file_set(upper_button_ic, MF_TITLE_ICON_UPPER_PRESS, NULL);
606 }
607
608 void mf_callback_upper_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info)
609 {
610         MF_TRACE_BEGIN;
611         mf_retm_if(data == NULL, "data is NULL");
612
613         Evas_Object *upper_button_ic = (Evas_Object *)data;
614         elm_image_file_set(upper_button_ic, MF_TITLE_ICON_UPPER, NULL);
615 }
616
617 void mf_callback_upper_click_cb(void *data, Evas_Object * obj, void *event_info)
618 {
619         assert(data);
620         struct appdata *ap = data;
621
622
623         if (ap->mf_Status.flagNaviPush) {
624                 mf_debug("the transition of the naviframe is not finished");
625                 return;
626         }
627
628         if (ap->mf_Status.more == MORE_CREATE_FOLDER) {
629                 return;
630         }
631
632         if (ap->mf_Status.view_type == mf_view_root) {
633                 return;
634         }
635         mf_callback_remove_dir_watch();
636
637         if (ap->mf_Status.more == MORE_RENAME) {
638                 mf_callback_destory_rename(ap);
639         }
640
641         if (ap->mf_MainWindow.pNaviItem) {
642                 mf_navi_bottom_item_del(&ap->mf_MainWindow.pNaviItem);
643         }
644
645         myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
646         mf_retm_if(pNavi_s == NULL, "get navi structure failed");
647         GString *parent_path = NULL;
648
649         if (mf_fm_svc_wrapper_is_root_path(ap->mf_Status.path->str)) {
650                 ap->mf_Status.view_type = mf_view_root;
651 #ifdef MYFILE_SPLIT_VIEW
652                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
653                         mf_navi_bar_set_panes_navi_to_main(ap);
654                 }
655 #endif
656
657         } else {
658                 parent_path = mf_fm_svc_wrapper_get_file_parent_path(ap->mf_Status.path);
659
660                 g_string_free(ap->mf_Status.path, TRUE);
661                 ap->mf_Status.path = NULL;
662                 ap->mf_Status.path = parent_path;
663 #ifdef MYFILE_USB_OTG
664                 /* if click items under otg root path, it means some disk take into use*/
665                 int storage = mf_fm_svc_wrapper_is_root_path(ap->mf_Status.path->str);
666                 if (storage == MYFILE_OTG) {    /* a usb disk take into use */
667                         char *dev_in_use = mf_otg_get_node_in_use(ap);
668                         if (dev_in_use != NULL)
669                                 mf_otg_set_node_using_flag(ap, dev_in_use, FALSE);
670                 } else {
671                 }
672 #endif
673                 if (pNavi_s->pCurrentPath != NULL) {
674                         free(pNavi_s->pCurrentPath);
675                         pNavi_s->pCurrentPath = NULL;
676                 }
677                 pNavi_s->pCurrentPath = g_strdup(parent_path->str);
678
679         }
680
681
682         mf_widget_refresh_view(ap);
683
684
685 }
686
687 #ifdef MYFILE_SPLIT_VIEW
688 void mf_callback_left_click_cb(struct appdata *data, GString * path, Elm_Object_Item *item)
689 {
690         MF_TRACE_BEGIN;
691         mf_retm_if(data == NULL, "data is NULL");
692         mf_retm_if(path == NULL, "path is NULL");
693         mf_retm_if(path->str == NULL, "path->str is NULL");
694
695         struct appdata *ap = (struct appdata *)data;
696
697         if (ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL) {
698                 return;
699         }
700         if (ap->mf_Status.flagNaviPush) {
701                 mf_debug("the transition of the naviframe is not finished");
702                 return;
703         }
704
705         Evas_Object *pGenlist = NULL;
706
707         int locate = mf_fm_svc_wrapper_get_location(ap->mf_Status.path->str);
708         int click_locate = MYFILE_PHONE;
709
710         pGenlist = ap->mf_MainWindow.sSplitData.pSplitLeftGenlist;
711
712         click_locate = mf_fm_svc_wrapper_get_location(path->str);
713
714         if (locate == click_locate) {
715
716                 int error_code = 0;
717                 int mmc_card = 0;
718                 bool result = FALSE;
719
720                 myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
721                 mf_retm_if(pNavi_s == NULL, "get navi structure failed");
722                 error_code = mf_util_is_mmc_on(&mmc_card);
723                 if (ap->mf_Status.more == MORE_DEFAULT || ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
724                     || ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.more == MORE_SEARCH) {
725                         SAFE_FREE_GSTRING(ap->mf_Status.path);
726                         ap->mf_Status.path = g_string_new(path->str);
727                         SAFE_FREE_CHAR(pNavi_s->pCurrentPath);
728                         pNavi_s->pCurrentPath = g_strdup(path->str);
729 #ifdef MYFILE_USB_OTG
730                         /* if click items under otg root path, it means some disk take into use*/
731                         error_code = 0;
732                         error_code = mf_file_attr_is_disk_link(path->str, &result);
733                         if (error_code == 0 && result == TRUE) {        /* a usb disk take into use */
734                                 /*
735                                 **we don't need to set the previous device flag to be false
736                                 **because click cannot jump from one device to another
737                                 */
738                                 mf_otg_set_node_using_flag(ap, path->str,TRUE);
739                         }
740 #endif
741                         /*set new path */
742                         if (ap->mf_Status.more == MORE_DEFAULT) {
743                                 mf_navi_bar_create_default_view(ap);
744                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
745                         } else if (ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
746                                    || ap->mf_Status.more == MORE_DATA_COPYING || ap->mf_Status.more == MORE_DATA_MOVING) {
747                                 mf_navi_bar_create_path_select_view(ap);
748                                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
749                         }
750                 }
751
752         } else {
753
754                 if (g_strcmp0(path->str, PHONE_FOLDER) == 0) {
755                         mf_callback_storage_cb(ap, GET_SYS_STR(MF_LABEL_PHONE));
756                 } else if (g_strcmp0(path->str, MEMORY_FOLDER) == 0) {
757                         mf_callback_storage_cb(ap, GET_SYS_STR(MF_LABEL_MMC));
758                 } else if (g_strcmp0(path->str, OTG_FOLDER) == 0) {
759                         mf_callback_storage_cb(ap, GET_STR(MF_LABEL_OTG));
760                 }
761         }
762
763         MF_TRACE_END;
764 }
765 #endif
766 void mf_callback_click_cb(struct appdata *data, mfAction key, GString * path)
767 {
768         mf_debug("Start");
769         assert(data);
770         mf_debug("key:%d path:%s\n", key, path->str);
771
772         struct appdata *ap = data;
773         if (ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL) {
774                 return;
775         }
776
777         if (ap->mf_Status.flagNaviPush) {
778                 mf_debug("the transition of the naviframe is not finished");
779                 return;
780         }
781         if (ap->mf_Status.view_type == mf_view_root) {
782                 ap->mf_Status.view_type = mf_view_normal;
783 #ifdef MYFILE_SPLIT_VIEW
784                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
785                         mf_navi_bar_reset_panes_main(ap);
786                 }
787 #endif
788                 mf_callback_tab_cb(ap, path->str);
789                 return;
790         }
791         GString *new_path = NULL;
792
793         int error_code = 0;
794         int mmc_card = 0;
795         bool result = FALSE;
796
797         myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
798         mf_retm_if(pNavi_s == NULL, "get navi structure failed");
799
800         error_code = mf_util_is_mmc_on(&mmc_card);
801         if (ap->mf_Status.more == MORE_DEFAULT || ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE
802             || ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.more == MORE_SEARCH) {
803                 if (key == MFACTION_CLICK) {
804                         if (mf_fm_svc_wrapper_is_dir(path)) {
805                                 if (ap->mf_Status.more == MORE_SEARCH) {
806                                         if (ap->mf_FileOperation.search_result_list) {
807                                                 mf_util_free_eina_list_with_data(&(ap->mf_FileOperation.search_result_list), MYFILE_TYPE_CHAR);
808                                         }
809                                         elm_object_focus_set(ap->mf_MainWindow.pSearchEntry, EINA_FALSE);
810                                         ap->mf_Status.more = MORE_DEFAULT;
811 #ifdef MYFILE_SPLIT_VIEW
812                                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
813                                                 mf_navi_bar_reset_panes_main(ap);
814                                         }
815 #endif
816
817                                 }
818                                 new_path = g_string_new(path->str);
819
820 #ifdef MYFILE_USB_OTG
821                                 /* if click items under otg root path, it means some disk take into use*/
822                                 error_code = 0;
823                                 error_code = mf_file_attr_is_disk_link(new_path->str, &result);
824                                 if (error_code == 0 && result == TRUE) {        /* a usb disk take into use */
825                                         /*
826                                         **we don't need to set the previous device flag to be false
827                                         **because click cannot jump from one device to another
828                                         */
829                                         mf_otg_set_node_using_flag(ap, new_path->str,TRUE);
830                                 }
831 #endif
832                                 /*set new path */
833                                 if (ap->mf_Status.path != NULL) {
834                                         g_string_free(ap->mf_Status.path, TRUE);
835                                         ap->mf_Status.path = NULL;
836                                 }
837                                 ap->mf_Status.path = new_path;
838
839                                 if (pNavi_s->pCurrentPath != NULL) {
840                                         free(pNavi_s->pCurrentPath);
841                                         pNavi_s->pCurrentPath = NULL;
842                                 }
843                                 pNavi_s->pCurrentPath = g_strdup(new_path->str);
844                                 mf_widget_refresh_view(ap);
845                         } else {
846                                 struct timeval mytime;
847                                 gettimeofday(&mytime, NULL);
848                                 mf_debug("[myfiles click time] %ld sec %ld usec \n", mytime.tv_sec, mytime.tv_usec);
849
850                                 int ret = 0;
851                                 ret = mf_launch_service(ap, path->str);
852                                 mf_debug("ret is %d\n", ret);
853                         }
854                 }
855
856                 else if (key == MFACTION_FLICK) {
857                         mf_debug("flick\n");
858                 }
859         }
860 }
861
862 /******************************
863 ** Prototype    : __mf_callback_imk_cancel_cb
864 ** Description  :
865 ** Input        : void *data
866 ** Output       : None
867 ** Return Value :
868 ** Calls        :
869 ** Called By    :
870 **
871 **  History        :
872 **  1.Date         : 2010/12/10
873 **    Author       : Samsung
874 **    Modification : Created function
875 **
876 ******************************/
877 static int __mf_callback_imk_cancel_cb(void *data)
878 {
879         struct appdata *ap = (struct appdata *)data;
880         assert(ap);
881
882         mf_callback_cancel_cb(ap, NULL, NULL);
883         return 0;
884 }
885
886 /******************************
887 ** Prototype    : __mf_callback_illegal_char_popup_cb
888 ** Description  :
889 ** Input        : void *data
890 **                Evas_Object *obj
891 **                void *event_info
892 ** Output       : None
893 ** Return Value :
894 ** Calls        :
895 ** Called By    :
896 **
897 **  History        :
898 **  1.Date         : 2010/12/10
899 **    Author       : Samsung
900 **    Modification : Created function
901 **
902 ******************************/
903 static void __mf_callback_illegal_char_popup_cb(void *data, Evas_Object * obj, void *event_info)
904 {
905         struct appdata *ap = (struct appdata *)data;
906         assert(ap);
907         Evas_Object *btn = (Evas_Object *)obj;
908         const char *label = elm_object_text_get(btn);
909
910         if (g_strcmp0(label, GET_SYS_STR(MF_BUTTON_LABEL_YES)) == 0 ) {
911                 evas_object_del(ap->mf_MainWindow.pNormalPopup);
912                 ap->mf_MainWindow.pNormalPopup = NULL;
913
914                 Evas_Object *entry = ap->mf_MainWindow.pEntry;
915                 if (entry != NULL)
916                         elm_object_focus_set(entry, EINA_TRUE);
917         } else if (g_strcmp0(label, GET_SYS_STR(MF_BUTTON_LABEL_NO)) == 0 ) {
918                 evas_object_del(ap->mf_MainWindow.pNormalPopup);
919                 ap->mf_MainWindow.pNormalPopup = NULL;
920                 ecore_idler_add((Ecore_Task_Cb) __mf_callback_imk_cancel_cb, ap);
921         }
922
923 }
924
925 /******************************
926 ** Prototype    : __mf_ime_mkdir_cb
927 ** Description  :
928 ** Input        : void *data
929 **                char* fileName
930 ** Output       : None
931 ** Return Value :
932 ** Calls        :
933 ** Called By    :
934 **
935 **  History        :
936 **  1.Date         : 2010/12/10
937 **    Author       : Samsung
938 **    Modification : Created function
939 **
940 ******************************/
941 static int __mf_callback_ime_mkdir_cb(void *data, char *fileName)
942 {
943         mf_debug();
944         struct appdata *ap = (struct appdata *)data;
945         assert(ap);
946         assert(fileName);
947
948         int ret = 0;
949         const char *message = NULL;
950         const char *left_label = NULL;
951         const char *right_label = NULL;
952
953         left_label = GET_SYS_STR(MF_BUTTON_LABEL_YES);
954         right_label = GET_SYS_STR(MF_BUTTON_LABEL_NO);
955         if (strlen(fileName)) {
956
957                 if (ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL) {
958                         mf_debug("ap->mf_Status.path is NULL\n");
959                         return MYFILE_ERR_ALLOCATE_MEMORY_FAIL;
960                 }
961                 GString *fullpathdir = g_string_new(ap->mf_Status.path->str);
962
963                 if (fullpathdir == NULL) {
964                         mf_util_operation_alloc_failed(ap);
965                         return MYFILE_ERR_ALLOCATE_MEMORY_FAIL;
966                 }
967                 /*check the space */
968                 gchar *test_space = g_strstrip(fileName);
969                 if (test_space == NULL) {
970                         g_string_free(fullpathdir, TRUE);
971                         fullpathdir = NULL;
972                         mf_util_operation_alloc_failed(ap);
973                         return MYFILE_ERR_ALLOCATE_MEMORY_FAIL;
974                 }
975                 mf_debug("====================================fileName is [%s] test_space is [%s]", fileName, test_space);
976
977                 GString *fullpathname = g_string_new(test_space);
978
979                 if (fullpathname == NULL) {
980                         g_string_free(fullpathdir, TRUE);
981                         fullpathdir = NULL;
982                         mf_util_operation_alloc_failed(ap);
983                         return MYFILE_ERR_ALLOCATE_MEMORY_FAIL;
984                 }
985
986                 if (strlen(test_space) == 0) {
987                         message = GET_STR(MF_POPUP_MSG_NAME_INVALID);   /*TODO */
988                         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
989                                                                                left_label, right_label, NULL,
990                                                                                __mf_callback_illegal_char_popup_cb, ap);
991
992                         g_string_free(fullpathdir, TRUE);
993                         fullpathdir = NULL;
994                         g_string_free(fullpathname, TRUE);
995                         fullpathname = NULL;
996                         return MYFILE_ERR_DIR_CREATE_FAIL;
997                 }
998
999                 /*check if input name is valid */
1000                 if (mf_file_attr_is_valid_name(fullpathname->str) == MYFILE_ERR_INVALID_FILE_NAME) {
1001
1002                         message = GET_STR(MF_MSG_ILLEGAL_CHAR);
1003                         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
1004                                                                                left_label, right_label, NULL,
1005                                                                                __mf_callback_illegal_char_popup_cb, ap);
1006                         mf_debug("Name contains illegal character!!!");
1007                         g_string_free(fullpathdir, TRUE);
1008                         fullpathdir = NULL;
1009                         g_string_free(fullpathname, TRUE);
1010                         fullpathname = NULL;
1011
1012                         return MYFILE_ERR_DIR_CREATE_FAIL;
1013                 }
1014
1015                 GString *fullpath = NULL;
1016                 char *temp_fullpath = g_strconcat(fullpathdir->str, "/", fullpathname->str, NULL);
1017                 if (temp_fullpath) {
1018                         fullpath = g_string_new(temp_fullpath);
1019
1020                         free(temp_fullpath);
1021                         temp_fullpath = NULL;
1022                         if (fullpath == NULL) {
1023                                 g_string_free(fullpathdir, TRUE);
1024                                 fullpathdir = NULL;
1025                                 g_string_free(fullpathname, TRUE);
1026                                 fullpathname = NULL;
1027                                 mf_util_operation_alloc_failed(ap);
1028                                 return MYFILE_ERR_ALLOCATE_MEMORY_FAIL;
1029                         }
1030                 } else {
1031                         g_string_free(fullpathdir, TRUE);
1032                         fullpathdir = NULL;
1033                         g_string_free(fullpathname, TRUE);
1034                         fullpathname = NULL;
1035                         return MYFILE_ERR_ALLOCATE_MEMORY_FAIL;
1036                 }
1037
1038                 mf_debug("length is %d\n", strlen(fileName));
1039                 mf_debug("fullpath is %s\n", fullpath->str);
1040                 /*check whether DIR name is override(DIR name has no extention) */
1041                 /*check whether path length is override */
1042                 if ((strlen(fullpathdir->str) + strlen(fullpathname->str)) > MYFILE_FILE_PATH_LEN_MAX) {
1043
1044                         message = GET_STR(MF_MSG_PATH_REACH_MAX_LEN);
1045                         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
1046                                                                                left_label, right_label, NULL,
1047                                                                                __mf_callback_illegal_char_popup_cb, ap);
1048                         mf_debug("Full path length should be  less than 4096 Retry!!!");
1049                         g_string_free(fullpathdir, TRUE);
1050                         fullpathdir = NULL;
1051                         g_string_free(fullpathname, TRUE);
1052                         fullpathname = NULL;
1053                         ret = MYFILE_ERR_DIR_CREATE_FAIL;
1054                 }
1055                 /*check if duplicated name */
1056                 else if (mf_file_attr_is_duplicated_name(ap->mf_Status.path->str, test_space) == MYFILE_ERR_DUPLICATED_NAME) {
1057                         message = GET_STR(MF_MSG_DUP_NAME);
1058                         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
1059                                                                                left_label, right_label, NULL,
1060                                                                                __mf_callback_illegal_char_popup_cb, ap);
1061
1062                         mf_debug("Duplicated Name, Retry?");
1063                         g_string_free(fullpathdir, TRUE);
1064                         fullpathdir = NULL;
1065                         g_string_free(fullpathname, TRUE);
1066                         fullpathname = NULL;
1067                         ret = MYFILE_ERR_DIR_CREATE_FAIL;
1068                 }
1069                 /*check if DIR name is all spaces */
1070                 else {
1071                         ret = mf_fm_svc_wrapper_create_service(ap, fullpath);
1072                         /*check whether operate on read only area */
1073                         if (errno == EROFS) {
1074                                 message = GET_STR(MF_MSG_OPER_READ_ONLY);
1075                                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL);
1076                                 ret = MYFILE_ERR_DIR_CREATE_FAIL;
1077                         } else if (ret) {
1078                                 message = GET_STR(MF_MSG_CREATE_DIR_FAILED);
1079                                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL);
1080                                 mf_debug("create folder error   %d      \n", ret);
1081                         }
1082
1083                         g_string_free(fullpathdir, TRUE);
1084                         fullpathdir = NULL;
1085                         g_string_free(fullpathname, TRUE);
1086                         fullpathname = NULL;
1087                         g_string_free(fullpath, TRUE);
1088                         fullpath = NULL;
1089
1090                 }
1091         } else {
1092                 message = GET_STR(MF_MSG_EMPTY_FOLDER_NAME);
1093
1094                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
1095                                                                        left_label, right_label, NULL, __mf_callback_illegal_char_popup_cb, ap);
1096                 ret = MYFILE_ERR_DIR_CREATE_FAIL;
1097         }
1098         return ret;
1099 }
1100
1101 /******************************
1102 ** Prototype    : mf_callback_cancel_cb
1103 ** Description  :
1104 ** Input        : void *data
1105 **                Evas_Object *obj
1106 **                void *event_info
1107 ** Output       : None
1108 ** Return Value :
1109 ** Calls        :
1110 ** Called By    :
1111 **
1112 **  History        :
1113 **  1.Date         : 2010/12/10
1114 **    Author       : Samsung
1115 **    Modification : Created function
1116 **
1117 ******************************/
1118 void mf_callback_cancel_cb(void *data, Evas_Object * obj, void *event_info)
1119 {
1120         MF_TRACE_BEGIN;
1121         struct appdata *ap = (struct appdata *)data;
1122         mf_retm_if(ap == NULL, "ap is NULL");
1123         mf_retm_if(ap->mf_Status.path == NULL, "ap->mf_Status.path is NULL");
1124         mf_retm_if(ap->mf_Status.path->str == NULL, "ap->mf_Status.path->str is NULL");
1125
1126         if (ap->mf_Status.flagNaviPush) {
1127                 mf_debug("the transition of the naviframe is not finished");
1128                 return;
1129         }
1130
1131         Evas_Object *newContent;
1132
1133         Eina_List *l = NULL;
1134         void *item = NULL;
1135         myfileNaviBar *pNavi_s = NULL;
1136         myfileNaviBar *pNavi_toshow = NULL;
1137         int flagTabbar = 0;
1138         switch (ap->mf_Status.more) {
1139         case MORE_INTERNAL_COPY:
1140         case MORE_INTERNAL_MOVE:
1141         case MORE_INTERNAL_COPY_MOVE:
1142                 mf_debug();
1143                 if (ap->mf_FileOperation.source != NULL) {
1144                         g_string_free(ap->mf_FileOperation.source, TRUE);
1145                         ap->mf_FileOperation.source = NULL;
1146                 }
1147                 /*1.    state set */
1148                 /*1.1   status set to default */
1149                 ap->mf_Status.preMore = ap->mf_Status.more;
1150                 ap->mf_Status.more = MORE_EDIT;
1151                 flagTabbar = mf_fm_svc_wrapper_is_root_path(ap->mf_Status.path->str);
1152                 /*1.2   free the path to set it to the one just when edit clicked later */
1153                 g_string_free(ap->mf_Status.path, TRUE);
1154                 ap->mf_Status.path = NULL;
1155                 /*2.    navigation bar state recovery */
1156                 EINA_LIST_FOREACH(ap->mf_MainWindow.plistNaviBar, l, item) {
1157                         pNavi_s = (myfileNaviBar *) item;
1158                         /*2.2   pop all the temprory views */
1159                         /*2.3   recover the path just before when edit click */
1160                         pNavi_s->pCurrentPath = strdup(pNavi_s->pre_operation.path->str);
1161                         /*2.5   set navi related status */
1162                         if (pNavi_s->naviFlagEditStart == TRUE) {
1163                                 /*2.5-1 set path in mf_status */
1164                                 ap->mf_Status.path = g_string_new(pNavi_s->pCurrentPath);
1165                                 /*2.5-2 set InUse flag */
1166                                 pNavi_s->naviFlagInUse = TRUE;
1167                                 /*2.5-3 set pNavi_toshow for refreshing */
1168                                 pNavi_toshow = pNavi_s;
1169                         } else {
1170                                 pNavi_s->naviFlagInUse = FALSE;
1171                         }
1172                 }
1173
1174                 if (pNavi_toshow == NULL) {
1175                         mf_debug("pNavi_toshow is NULL");
1176                         return;
1177                 }
1178
1179
1180                 ap->mf_Status.more = MORE_DEFAULT;
1181                 if (ap->mf_Status.view_type == mf_view_root) {
1182                         ap->mf_Status.view_type = ap->mf_Status.preViewType;
1183 #ifdef MYFILE_SPLIT_VIEW
1184                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1185                                 if (ap->mf_Status.preViewType != mf_view_root_category) {
1186                                         mf_navi_bar_reset_panes_main(ap);
1187                                 }
1188                         }
1189 #endif
1190                 } else {
1191                         ap->mf_Status.view_type = ap->mf_Status.preViewType;
1192 #ifdef MYFILE_SPLIT_VIEW
1193                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1194                                 if (ap->mf_Status.preViewType == mf_view_root_category) {
1195                                         mf_navi_bar_set_panes_navi_to_main(ap);
1196                                 }
1197                         }
1198 #endif
1199                 }
1200
1201                 mf_navi_bar_create_default_view(ap);
1202                 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
1203
1204                 ap->mf_Status.more = MORE_EDIT;
1205                 mf_widget_refresh_view(ap);
1206
1207                 ap->mf_Status.preMore = MORE_DEFAULT;
1208                 return;
1209         case MORE_RENAME:
1210                 mf_callback_destory_rename(ap);
1211                 if (ap->mf_Status.preMore == MORE_SEARCH) {
1212                         goto SEARCH_CANCEL;
1213                 }
1214                 break;
1215                 /* when cancle rename, just destory the rename relative, and then the mode will change to Edit
1216                    then do what cancle edit do, so here not need "break" */
1217         case MORE_EDIT:
1218                 /*1     pop edit view */
1219                 if (ap->mf_MainWindow.pLabelLayout) {
1220                         mf_widget_unset_part_content(ap->mf_MainWindow.pNaviLayout, "sel_contents");
1221                         if (ap->mf_MainWindow.pLabelLayout)
1222                                 evas_object_del(ap->mf_MainWindow.pLabelLayout);
1223
1224                         ap->mf_MainWindow.pLabelLayout = NULL;
1225                 }
1226                 ap->mf_Status.flagFolderSelect = FALSE;
1227                 ap->mf_Status.flagFileSelect = FALSE;
1228                 pNavi_toshow = mf_navi_bar_get_in_use(ap);
1229                 mf_retm_if(pNavi_toshow == NULL, "get navi in use failed");
1230                 ap->mf_Status.more = MORE_DEFAULT;
1231                         /*3.    refresh the content of the view */
1232
1233                 mf_navi_bar_recover_info_box(ap, pNavi_toshow);
1234                 Evas_Object *btn = NULL;
1235                 btn = elm_object_item_part_content_unset(ap->mf_MainWindow.pNaviItem, TITLE_LEFT_BTN);
1236                 SAFE_FREE_OBJ(btn);
1237
1238                 mf_genlist_update_default_view_item_style(ap);
1239                 newContent = mf_navi_bar_content_create(ap);
1240                 mfNaviBarSetContent(ap, ap->mf_MainWindow.pNaviLayout, newContent);
1241
1242                 //mf_ctrl_bar_reset(ap);
1243                 mf_navi_bar_reset_ctrl_button(ap);
1244                 mf_navi_add_back_button(ap);
1245                 /*4.    set tab enable */
1246                 mf_navi_bar_title_set(ap);
1247                 break;
1248         case MORE_SEARCH:
1249              SEARCH_CANCEL:
1250                 if (ap->mf_Status.more == MORE_SEARCH)
1251                         ap->mf_MainWindow.pSearchViewSweepItem = NULL;
1252 #ifdef MYFILE_SPLIT_VIEW
1253                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1254                         /**** 1. unset naviframe from mainlayout **/
1255                         if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
1256                                 mf_navi_bar_reset_panes_main(ap);
1257                         }
1258                 }
1259 #endif
1260
1261                 if (ap->mf_FileOperation.search_IME_hide_timer != NULL) {
1262                         ecore_timer_del(ap->mf_FileOperation.search_IME_hide_timer);
1263                         ap->mf_FileOperation.search_IME_hide_timer = NULL;
1264                 }
1265
1266                 if (ap->mf_FileOperation.search_result_list) {
1267                         mf_util_free_eina_list_with_data(&(ap->mf_FileOperation.search_result_list), MYFILE_TYPE_CHAR);
1268                 }
1269
1270                 if (ap->mf_Status.search_handler > 0) {
1271                         mf_search_stop(ap->mf_Status.search_handler);
1272                         mf_search_finalize(&ap->mf_Status.search_handler);
1273                 }
1274                 ap->mf_Status.more = MORE_DEFAULT;
1275                 elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_FALSE);
1276                 evas_object_del(ap->mf_MainWindow.pEntry);
1277                 ap->mf_MainWindow.pSearchEntry = NULL;
1278
1279                 mf_widget_refresh_view(ap);
1280                 ap->mf_Status.preMore = MORE_DEFAULT;
1281
1282                 break;
1283         case MORE_CREATE_FOLDER:
1284 #ifdef MYFILE_SPLIT_VIEW
1285                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1286                         if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
1287                                 mf_navi_bar_reset_panes_main(ap);
1288                         }
1289                 }
1290 #endif
1291                 ap->mf_Status.more = ap->mf_Status.preMore;
1292                 elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_FALSE);
1293                 evas_object_del(ap->mf_MainWindow.pEntry);
1294                 ap->mf_MainWindow.pEntry = NULL;
1295                 mf_widget_imf_hide_callback_del(ap->mf_MainWindow.pConformant);
1296
1297                 mf_widget_refresh_view(ap);
1298
1299
1300                 break;
1301         case MORE_THUMBNAIL_RENAME:
1302 #ifdef MYFILE_SPLIT_VIEW
1303                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1304                         if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
1305                                 mf_navi_bar_reset_panes_main(ap);
1306                         }
1307                 }
1308 #endif
1309                 ap->mf_Status.more = MORE_DEFAULT;//ap->mf_Status.preMore;
1310                 ap->mf_Status.preMore = MORE_THUMBNAIL_RENAME;
1311                 elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_FALSE);
1312                 evas_object_del(ap->mf_MainWindow.pEntry);
1313                 ap->mf_MainWindow.pEntry = NULL;
1314                 mf_widget_imf_hide_callback_del(ap->mf_MainWindow.pConformant);
1315
1316                 mf_widget_refresh_view(ap);
1317                 ap->mf_Status.preMore = MORE_DEFAULT;
1318                 break;
1319         default:
1320                 ap->mf_Status.more = MORE_DEFAULT;
1321                 /*4.    set tab enable */
1322                 break;
1323         }
1324
1325         if (ap->mf_MainWindow.pLabel) {
1326                 evas_object_del(ap->mf_MainWindow.pLabel);
1327                 ap->mf_MainWindow.pLabel = NULL;
1328         }
1329 }
1330
1331 /******************************
1332 ** Prototype    : __mf_popup_show_vk_cb
1333 ** Description  : Samsung
1334 ** Input        : void *data
1335 **                Evas_Object * obj
1336 **                void *event_info
1337 ** Output       : None
1338 ** Return Value :
1339 ** Calls        :
1340 ** Called By    :
1341 **
1342 **  History        :
1343 **  1.Date         : 2010/12/10
1344 **    Author       : Samsung
1345 **    Modification : Created function
1346 **
1347 ******************************/
1348 void mf_popup_show_vk_cb(void *data, Evas_Object *obj, void *event_info)
1349 {
1350         MF_TRACE_BEGIN;
1351         struct appdata *ap = (struct appdata *)data;
1352         assert(ap);
1353
1354         Evas_Object *pEntry = NULL;
1355
1356         evas_object_del(ap->mf_MainWindow.pNormalPopup);
1357
1358         ap->mf_MainWindow.pNormalPopup = NULL;
1359
1360         pEntry = ap->mf_MainWindow.pEntry;
1361         elm_entry_cursor_end_set(ap->mf_MainWindow.pEntry);
1362
1363         elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_TRUE);
1364         MF_TRACE_END;
1365
1366 }
1367
1368 static void __mf_callback_refresh_rename(void *data, GString *pre_name, GString *new_name)
1369 {
1370         MF_TRACE_BEGIN;
1371         mf_retm_if(data == NULL, "data is NULL");
1372         mf_retm_if(pre_name == NULL, "pre_name is NULL");
1373         mf_retm_if(pre_name->str == NULL, "pre_name->str is NULL");
1374         mf_retm_if(new_name == NULL, "new_name is NULL");
1375         mf_retm_if(new_name->str == NULL, "new_name->str is NULL");
1376         struct appdata *ap = (struct appdata *)data;
1377
1378         mfItemData_s *item_data = NULL;
1379
1380         item_data = elm_object_item_data_get(ap->mf_FileOperation.rename_item);
1381         if (item_data == NULL) {
1382                 return;
1383         }
1384
1385         if (g_string_equal(item_data->m_ItemName, pre_name)) {
1386                 g_string_free(item_data->m_ItemName, TRUE);
1387                 item_data->m_ItemName = g_string_new(new_name->str);
1388                 elm_object_item_data_set(ap->mf_FileOperation.rename_item, item_data);
1389                 elm_genlist_item_update(ap->mf_FileOperation.rename_item);
1390                 if (ap->mf_Status.view_type == mf_view_root_category) {
1391                         mf_util_update_item_from_list_by_name(&ap->mf_FileOperation.category_list, pre_name->str, new_name->str);
1392                 }
1393         }
1394         mf_callback_destory_rename(ap);
1395 }
1396
1397 void mf_callback_destory_rename(void *data)
1398 {
1399         MF_TRACE_BEGIN;
1400         struct appdata *ap = (struct appdata *)data;
1401         mf_retm_if(ap == NULL, "ap is null");
1402
1403         if (ap->mf_Status.more != MORE_RENAME) {
1404                 return;
1405         }
1406
1407         myfileNaviBar *pNavi_toshow = NULL;
1408         pNavi_toshow = mf_navi_bar_get_in_use(ap);
1409         mf_retm_if(pNavi_toshow == NULL, "get navi in use failed");
1410
1411         ap->mf_Status.more = ap->mf_Status.preMore;
1412         elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_FALSE);
1413         if (ap->mf_FileOperation.file_name_suffix != NULL) {
1414                 SAFE_FREE_CHAR(ap->mf_FileOperation.file_name_suffix);
1415         }
1416         if (ap->mf_FileOperation.to_rename) {
1417                 SAFE_FREE_GSTRING(ap->mf_FileOperation.to_rename);
1418         }
1419         if (ap->mf_FileOperation.rename_item) {
1420                 elm_genlist_item_flip_set(ap->mf_FileOperation.rename_item, EINA_FALSE);
1421                 elm_genlist_item_select_mode_set(ap->mf_FileOperation.rename_item,  ELM_OBJECT_SELECT_MODE_DEFAULT);
1422                 elm_genlist_item_update(ap->mf_FileOperation.rename_item);
1423                 ap->mf_FileOperation.rename_item = NULL;
1424         }
1425
1426         if (ap->mf_MainWindow.pEntry) {
1427                 ap->mf_MainWindow.pEntry = NULL;
1428         }
1429
1430         if (ap->mf_Status.preMore == MORE_DEFAULT) {
1431                 mf_navi_bar_set_upper_item_disable(ap, FALSE);
1432                 mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, CTRL_DISABLE_DEFAULT_ALL, FALSE);
1433                 //mf_ctrl_bar_item_set_disable(ap->mf_MainWindow.pNaviCtrlBar, CTRL_DISABLE_DEFAULT_ALL, FALSE);
1434         } else {
1435                 mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, CTRL_DISABLE_EDIT_ALL, FALSE);
1436                 //mf_ctrl_bar_item_set_disable(ap->mf_MainWindow.pNaviCtrlBar, CTRL_DISABLE_EDIT_ALL, FALSE);
1437
1438                 if (ap->mf_Status.iCtrlDisableItem > 0) {
1439                         mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, ap->mf_Status.iCtrlDisableItem, TRUE);
1440                         //mf_ctrl_bar_item_set_disable(ap->mf_MainWindow.pNaviCtrlBar, ap->mf_Status.iCtrlDisableItem, TRUE);
1441                 }
1442         }
1443         MF_TRACE_END;
1444 }
1445
1446
1447 /******************************
1448 ** Prototype    : mf_callback_rename_save_cb
1449 ** Description  :
1450 ** Input        : void *ad
1451 **                Evas_Object *obj
1452 **                void *event_info
1453 ** Output       : None
1454 ** Return Value :
1455 ** Calls        :
1456 ** Called By    :
1457 **
1458 **  History        :
1459 **  1.Date         : 2010/12/10
1460 **    Author       : Samsung
1461 **    Modification : Created function
1462 **
1463 ******************************/
1464 void mf_callback_rename_save_cb(void *ad, Evas_Object *obj, void *event_info)
1465 {
1466         MF_TRACE_BEGIN;
1467         struct appdata *ap = (struct appdata *)ad;
1468         mf_retm_if(ap == NULL, "ap is NULL");
1469
1470         char *name = NULL;
1471         Evas_Object *pEntry = NULL;
1472         const char *entry_data = NULL;
1473         int ret = MYFILE_ERR_NONE;
1474         const char *message = NULL;
1475         GString *from = NULL;
1476         GString *to = NULL;
1477         char *pFullPath = NULL;
1478         char *pName = NULL;
1479         if (ap->mf_Status.more != MORE_RENAME && ap->mf_Status.more != MORE_THUMBNAIL_RENAME) {
1480                 MF_TRACE_END;
1481                 return;
1482         }
1483         if (ap->mf_Status.flagNaviPush) {
1484                 mf_debug("the transition of the naviframe is not finished");
1485                 MF_TRACE_END;
1486                 return;
1487         }
1488
1489         pEntry = ap->mf_MainWindow.pEntry;
1490         if (pEntry == NULL && ap->mf_Status.more == MORE_RENAME) {
1491                 mf_callback_destory_rename(ap);
1492                 MF_TRACE_END;
1493                 return;
1494         }
1495         entry_data = elm_entry_entry_get(pEntry);
1496         if (entry_data) {
1497                 name = elm_entry_markup_to_utf8(entry_data);
1498                 if (name == NULL) {
1499                         message = GET_STR(MF_RENAME_MSG_GET_NAME_FAILED);
1500                         goto INVAILD_NAME_EXIT;
1501                 }
1502                 if (strlen(name) == 0 && ap->mf_Status.more == MORE_THUMBNAIL_RENAME)
1503                 {
1504                         SAFE_FREE_CHAR(name);
1505                         message = GET_STR(MF_MSG_GET_NAME_FAILED);
1506                         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
1507                                                                                GET_SYS_STR(MF_BUTTON_LABEL_YES), GET_SYS_STR(MF_BUTTON_LABEL_NO), NULL,
1508                                                                                __mf_callback_illegal_char_popup_cb, ap);
1509                         return;
1510                 }
1511         } else {
1512                 message = GET_STR(MF_RENAME_MSG_GET_NAME_FAILED);
1513                 goto INVAILD_NAME_EXIT;
1514         }
1515
1516         if (strlen(name)) {
1517
1518                 if (ap->mf_FileOperation.file_name_suffix != NULL && strlen(ap->mf_FileOperation.file_name_suffix) > 0) {
1519                         pName = g_strconcat(name, ".", ap->mf_FileOperation.file_name_suffix, NULL);
1520                         CHAR_CHECK_NULL_GOTO(pName, ALLOC_FAILED_EXIT);
1521                 } else {
1522                         pName = g_strdup(name);
1523                         CHAR_CHECK_NULL_GOTO(pName, ALLOC_FAILED_EXIT);
1524                 }
1525
1526                 GString *parent_path = mf_fm_svc_wrapper_get_file_parent_path(ap->mf_FileOperation.to_rename);
1527                 GSTRING_CHECK_NULL_GOTO(parent_path, ALLOC_FAILED_EXIT);
1528                 pFullPath = g_strconcat(parent_path->str, "/", pName, NULL);
1529                 CHAR_CHECK_NULL_GOTO(pFullPath, ALLOC_FAILED_EXIT);
1530                 SAFE_FREE_GSTRING(parent_path);
1531
1532                 switch (mf_util_is_valid_name_check(pName)) {
1533
1534                 case MF_INTERNAL_FILE_NAME_EMPTY:
1535                 case MF_INTERNAL_FILE_NAME_IGNORE:
1536                         message = GET_STR(MF_MSG_SET_NAME_DOT);
1537                         goto INVAILD_NAME_EXIT;
1538                 case MF_INTERNAL_FILE_NAME_CHUG:
1539                         message = GET_STR(MF_MSG_SET_NAME_ALL_SPACE);
1540                         goto INVAILD_NAME_EXIT;
1541                 case MF_INTERNAL_FILE_NAME_MAX_LENGTH:
1542                         message = GET_STR(MF_MSG_NAME_REACH_MAX_LEN);
1543                         goto INVAILD_NAME_EXIT;
1544                 case MF_INTERNAL_FILE_NAME_INVALID_CHAR:
1545                         message = GET_STR(MF_MSG_ILLEGAL_CHAR);
1546                         goto INVAILD_NAME_EXIT;
1547                 case MF_INTERNAL_FILE_NAME_NULL:
1548                         message = GET_STR(MF_MSG_NO_NAME_WARNING);
1549                         goto INVAILD_NAME_EXIT;
1550                 default:
1551                         break;
1552                 }
1553
1554
1555                 if (strlen(pFullPath) > MYFILE_FILE_PATH_LEN_MAX) {
1556                         message = GET_STR(MF_MSG_PATH_REACH_MAX_LEN);
1557                         goto INVAILD_NAME_EXIT;
1558                 }
1559
1560                 from = g_string_new(ap->mf_FileOperation.to_rename->str);
1561                 GSTRING_CHECK_NULL_GOTO(from, ALLOC_FAILED_EXIT);
1562                 to = g_string_new(pFullPath);
1563                 GSTRING_CHECK_NULL_GOTO(from, ALLOC_FAILED_EXIT);
1564
1565                 if (!g_string_equal(from, to)) {
1566                         ret = mf_fm_svc_wrapper_rename_service(ap, from, to);
1567                         if (ret != MYFILE_ERR_NONE) {
1568                                 if (errno == EROFS) {
1569                                         message = GET_STR(MF_MSG_OPER_READ_ONLY);
1570                                         goto INVAILD_NAME_EXIT;
1571                                 } else if (ret == MYFILE_ERR_INVALID_DIR_NAME || ret == MYFILE_ERR_INVALID_FILE_NAME) {
1572                                         message = GET_STR(MF_MSG_ILLEGAL_CHAR);
1573                                         goto INVAILD_NAME_EXIT;
1574                                 } else if (ret == MYFILE_ERR_DUPLICATED_NAME) {
1575                                         message = GET_STR(MF_RENAME_MSG_DUP_NAME);
1576                                         goto INVAILD_NAME_EXIT;
1577                                 } else {
1578                                         message = GET_STR(MF_MSG_UNKNOW_REASON_RENAME_FAILED);
1579                                         goto INVAILD_NAME_EXIT;
1580                                 }
1581                         } else {
1582                                 if (ap->mf_Status.more == MORE_RENAME)
1583                                         __mf_callback_refresh_rename(ap, from, to);
1584                                 else if (ap->mf_Status.more == MORE_THUMBNAIL_RENAME){
1585 #ifdef MYFILE_SPLIT_VIEW
1586                                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1587                                                 mf_navi_bar_reset_panes_main(ap);
1588                                         }
1589 #endif
1590                                         ap->mf_Status.more = MORE_DEFAULT;
1591                                         ap->mf_Status.preMore = MORE_THUMBNAIL_RENAME;
1592                                         elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_FALSE);
1593                                         evas_object_del(ap->mf_MainWindow.pEntry);
1594                                         ap->mf_MainWindow.pEntry = NULL;
1595                                         mf_widget_imf_hide_callback_del(ap->mf_MainWindow.pConformant);
1596                                         if (ap->mf_Status.view_type == mf_view_root_category) {
1597                                                 mf_util_update_item_from_list_by_name(&ap->mf_FileOperation.category_list, from->str, to->str);
1598                                         }
1599
1600                                         mf_widget_refresh_view(ap);
1601                                         ap->mf_Status.preMore = MORE_DEFAULT;
1602                                 }
1603                                 goto NORMAL_EXIT;
1604                         }
1605                 } else {
1606
1607                         if (ap->mf_Status.more == MORE_RENAME)
1608                                 mf_callback_destory_rename(ap);
1609                         else if (ap->mf_Status.more == MORE_THUMBNAIL_RENAME){
1610                                 mf_callback_cancel_cb(ap, NULL, NULL);
1611                         }
1612                         goto NORMAL_EXIT;
1613                 }
1614         }else {
1615                 mf_callback_destory_rename(ap);
1616                 goto NORMAL_EXIT;
1617         }
1618 NORMAL_EXIT:
1619         SAFE_FREE_CHAR(name);
1620         SAFE_FREE_CHAR(pName);
1621         SAFE_FREE_CHAR(pFullPath);
1622         SAFE_FREE_GSTRING(from);
1623         SAFE_FREE_GSTRING(to);
1624         MF_TRACE_END;
1625         return;
1626
1627 INVAILD_NAME_EXIT:
1628         SAFE_FREE_CHAR(name);
1629         SAFE_FREE_CHAR(pName);
1630         SAFE_FREE_CHAR(pFullPath);
1631         SAFE_FREE_GSTRING(from);
1632         SAFE_FREE_GSTRING(to);
1633
1634         if (ap->mf_Status.more == MORE_THUMBNAIL_RENAME)
1635         {
1636                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
1637                                                                        GET_SYS_STR(MF_BUTTON_LABEL_YES), GET_SYS_STR(MF_BUTTON_LABEL_NO), NULL,
1638                                                                        __mf_callback_illegal_char_popup_cb, ap);
1639                 return;
1640         } else {
1641                 mf_callback_destory_rename(ap);
1642                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message, NULL, NULL, NULL, mf_popup_show_vk_cb, ap);
1643         }
1644
1645         MF_TRACE_END;
1646         return;
1647
1648 ALLOC_FAILED_EXIT:
1649         SAFE_FREE_CHAR(name);
1650         SAFE_FREE_CHAR(pName);
1651         SAFE_FREE_CHAR(pFullPath);
1652         SAFE_FREE_GSTRING(from);
1653         mf_util_operation_alloc_failed(ap);
1654         MF_TRACE_END;
1655         return;
1656
1657 }
1658
1659
1660 /******************************
1661 ** Prototype    : mf_callback_save_cb
1662 ** Description  :
1663 ** Input        : void *data
1664 **                Evas_Object *obj
1665 **                void *event_info
1666 ** Output       : None
1667 ** Return Value :
1668 ** Calls        :
1669 ** Called By    :
1670 **
1671 **  History        :
1672 **  1.Date         : 2010/12/10
1673 **    Author       : Samsung
1674 **    Modification : Created function
1675 **
1676 ******************************/
1677 void mf_callback_save_cb(void *data, Evas_Object *obj, void *event_info)
1678 {
1679         mf_debug();
1680         struct appdata *ap = (struct appdata *)data;
1681         assert(ap);
1682
1683         if (ap->mf_Status.flagNaviPush) {
1684                 mf_debug("the transition of the naviframe is not finished");
1685                 return;
1686         }
1687
1688         int ret = 0;
1689         int noContentFlag = 0;
1690         const char *message = NULL;
1691         const char *left_label = NULL;
1692         const char *right_label = NULL;
1693
1694         if (ap->mf_Status.more == MORE_RENAME || ap->mf_Status.more == MORE_THUMBNAIL_RENAME) {
1695                 mf_callback_rename_save_cb(ap, NULL, NULL);
1696         } else if (ap->mf_Status.more == MORE_CREATE_FOLDER) {
1697                 const char *entry_data = NULL;
1698                 char *name = NULL;
1699
1700                 /*hide IMF*/
1701                 if (ap->mf_MainWindow.pEntry != NULL) {
1702                         Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ap->mf_MainWindow.pEntry);
1703                         if (imf_context != NULL)
1704                                 ecore_imf_context_hide(imf_context);
1705                 }
1706
1707                 entry_data = elm_entry_entry_get(ap->mf_MainWindow.pEntry);
1708
1709                 if (entry_data) {
1710                         name = elm_entry_markup_to_utf8(entry_data);
1711                 } else {
1712                         message = GET_STR(MF_MSG_GET_NAME_FAILED);
1713                         left_label = GET_SYS_STR(MF_BUTTON_LABEL_YES);
1714                         right_label = GET_SYS_STR(MF_BUTTON_LABEL_NO);
1715                         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_TWO_BTN, NULL, message,
1716                                                                                left_label, right_label, NULL,
1717                                                                                __mf_callback_illegal_char_popup_cb, ap);
1718                         return;
1719                 }
1720
1721                 if (name == NULL)
1722                         return;
1723
1724                 ret = __mf_callback_ime_mkdir_cb(ap, name);
1725                 if (ret == 0) {
1726 #ifdef MYFILE_SPLIT_VIEW
1727                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1728                                 if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
1729                                         mf_navi_bar_reset_panes_main(ap);
1730                                 }
1731                         }
1732 #endif
1733                         ap->mf_Status.more = ap->mf_Status.preMore;
1734                         elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_FALSE);
1735                         evas_object_del(ap->mf_MainWindow.pEntry);
1736                         ap->mf_MainWindow.pEntry = NULL;
1737                         mf_widget_imf_hide_callback_del(ap->mf_MainWindow.pConformant);
1738
1739                         mf_widget_refresh_view(ap);
1740
1741                         if (ap->mf_Status.more == MORE_DEFAULT && noContentFlag) {
1742                                 mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, CTRL_DISABLE_NOCONTENT_VIEW, false);
1743                                 //mf_ctrl_bar_item_set_disable(ap->mf_MainWindow.pNaviCtrlBar, CTRL_DISABLE_NOCONTENT_VIEW, false);
1744                         }
1745                 }
1746
1747                 if (name != NULL) {
1748                         free(name);
1749                         name = NULL;
1750                 }
1751         }
1752 }
1753
1754
1755 void mf_callback_popup_deleted_cb(void *data, Evas_Object * obj, void *event_info)
1756 {
1757         struct appdata *ap = (struct appdata *)data;
1758         assert(ap);
1759
1760         if (ap->mf_MainWindow.pNormalPopup != NULL) {
1761                 evas_object_del(ap->mf_MainWindow.pNormalPopup);
1762         }
1763         ap->mf_MainWindow.pNormalPopup = NULL;
1764
1765 }
1766
1767 /******************************
1768 ** Prototype    : mf_callback_launch_send_cb
1769 ** Description  :
1770 ** Input        : void *data
1771 **                Evas_Object *obj
1772 **                void *event_info
1773 ** Output       : None
1774 ** Return Value :
1775 ** Calls        :
1776 ** Called By    :
1777 **
1778 **  History        :
1779 **  1.Date         : 2010/12/10
1780 **    Author       : Samsung
1781 **    Modification : Created function
1782 **
1783 ******************************/
1784 void mf_callback_launch_send_cb(void *data, Evas_Object *obj, void *event_info)
1785 {
1786         mf_debug();
1787         struct appdata *ap = (struct appdata *)data;
1788         assert(ap);
1789
1790         if (ap->mf_FileRecordList.selected_files && mf_util_get_eina_list_len(ap->mf_FileRecordList.selected_files) > 0) {
1791                 switch (ap->mf_Status.more) {
1792                 case MORE_SENDVIABLUETOOTH:
1793                 case MORE_SENDVIAEMAIL:
1794                 case MORE_SENDVIAMESSAGE:
1795                         mf_share_launch_multi_file(data);
1796                         break;
1797                 default:
1798                         break;
1799                 }
1800         } else {
1801                 const char *message = GET_SYS_STR(MF_LABEL_NOTHING_SELECTED);
1802                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL);
1803         }
1804         ap->mf_Status.more = MORE_EDIT;
1805 }
1806
1807 /******************************
1808 ** Prototype    : __mf_callback_idle_launch_send_cb
1809 ** Description  :
1810 ** Input        : void *data
1811 ** Output       : None
1812 ** Return Value :
1813 ** Calls        :
1814 ** Called By    :
1815 **
1816 **  History        :
1817 **  1.Date         : 2010/12/10
1818 **    Author       : Samsung
1819 **    Modification : Created function
1820 **
1821 ******************************/
1822 static int __mf_callback_idle_launch_send_cb(void *data)
1823 {
1824         struct appdata *ap = (struct appdata *)data;
1825         assert(ap);
1826
1827         mf_callback_launch_send_cb(ap, NULL, NULL);
1828         return 0;
1829 }
1830
1831
1832 /******************************
1833 ** Prototype    : mf_callback_send_view_cb
1834 ** Description  :
1835 ** Input        : void *data
1836 **                Evas_Object *obj
1837 **                void *event_info
1838 ** Output       : None
1839 ** Return Value :
1840 ** Calls        :
1841 ** Called By    :
1842 **
1843 **  History        :
1844 **  1.Date         : 2010/12/10
1845 **    Author       : Samsung
1846 **    Modification : Created function
1847 **
1848 ******************************/
1849 void mf_callback_send_response_cb(void *data)
1850 {
1851         struct appdata *ap = (struct appdata *)data;
1852         assert(ap);
1853
1854         if (ap->mf_MainWindow.pContextPopup != NULL) {
1855                 evas_object_del(ap->mf_MainWindow.pContextPopup);
1856         }
1857         ap->mf_MainWindow.pContextPopup = NULL;
1858
1859         ecore_idler_add((Ecore_Task_Cb) __mf_callback_idle_launch_send_cb, ap);
1860 }
1861
1862
1863 /******************************
1864 ** Prototype    : __mf_callback_refresh_list_by
1865 ** Description  :
1866 ** Input        : void *data
1867 ** Output       : None
1868 ** Return Value :
1869 ** Calls        :
1870 ** Called By    :
1871 **
1872 **  History        :
1873 **  1.Date         : 2010/12/10
1874 **    Author       : Samsung
1875 **    Modification : Created function
1876 **
1877 ******************************/
1878 static int __mf_callback_refresh_list_by(void *data)
1879 {
1880         struct appdata *ap = (struct appdata *)data;
1881         assert(ap);
1882         Evas_Object *playout = ap->mf_MainWindow.pNaviLayout;
1883         mf_retvm_if(playout == NULL, 0, "get conformant failed");
1884         Evas_Object *newContent = NULL;
1885 #ifdef MYFILE_SPLIT_VIEW
1886         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
1887                 mf_split_view_left_genlist_refresh(ap);
1888         }
1889 #endif
1890
1891         if (ap->mf_Status.flagNoContent != EINA_TRUE) {
1892                 newContent = mf_navi_bar_content_create(ap);
1893                 mfNaviBarSetContent(ap, playout, newContent);
1894         }
1895         ap->mf_Status.more = MORE_DEFAULT;
1896         return 0;
1897 }
1898
1899 /******************************
1900 ** Prototype    : __mf_callback_list_by_response_cb
1901 ** Description  : Samsung
1902 ** Input        : void *data
1903 **                Evas_Object *obj
1904 **                void *event_info
1905 ** Output       : None
1906 ** Return Value :
1907 ** Calls        :
1908 ** Called By    :
1909 **
1910 **  History        :
1911 **  1.Date         : 2010/12/10
1912 **    Author       : Samsung
1913 **    Modification : Created function
1914 **
1915 ******************************/
1916 void mf_callback_list_by_response_cb(void *data)
1917 {
1918         struct appdata *ap = (struct appdata *)data;
1919         assert(ap);
1920
1921         if (ap->mf_MainWindow.pNormalPopup != NULL) {
1922                 evas_object_del(ap->mf_MainWindow.pNormalPopup);
1923         }
1924         ap->mf_MainWindow.pNormalPopup = NULL;
1925
1926         ecore_idler_add((Ecore_Task_Cb) __mf_callback_refresh_list_by, ap);
1927
1928 }
1929
1930 /******************************
1931 ** Prototype    : mf_callback_list_by_view_cb
1932 ** Description  :
1933 ** Input        : void *data
1934 **                Evas_Object *obj
1935 **                void *event_info
1936 ** Output       : None
1937 ** Return Value :
1938 ** Calls        :
1939 ** Called By    :
1940 **
1941 **  History        :
1942 **  1.Date         : 2010/12/10
1943 **    Author       : Samsung
1944 **    Modification : Created function
1945 **
1946 ******************************/
1947 void mf_callback_list_by_view_cb(void *data, Evas_Object * obj, void *event_info)
1948 {
1949         mf_debug();
1950         struct appdata *ap = (struct appdata *)data;
1951         assert(ap);
1952         if (ap->mf_Status.flagNaviPush) {
1953                 mf_debug("the transition of the naviframe is not finished");
1954                 return;
1955         }
1956         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
1957         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TITLE_LIST_BTN, GET_STR(LABEL_SORT_BY),
1958                                                                NULL, NULL, NULL, NULL, mf_callback_popup_deleted_cb, ap);
1959 }
1960
1961 /******************************
1962 ** Prototype    : mf_callback_edit_cb
1963 ** Description  :
1964 ** Input        : void *data
1965 **                Evas_Object *obj
1966 **                void *event_info
1967 ** Output       : None
1968 ** Return Value :
1969 ** Calls        :
1970 ** Called By    :
1971 **
1972 **  History        :
1973 **  1.Date         : 2010/12/10
1974 **    Author       : Samsung
1975 **    Modification : Created function
1976 **
1977 ******************************/
1978 #ifdef MYFILE_SPLIT_VIEW
1979 static void __mf_callback_edit_init(void *data)
1980 {
1981         MF_TRACE_BEGIN;
1982         mf_retm_if(data == NULL, "data is NULL");
1983
1984         struct appdata *ap = (struct appdata*)data;
1985         //ap->mf_MainWindow.pEditView.pBox = NULL;
1986         ap->mf_MainWindow.pEditView.pGenlist = NULL;
1987         ap->mf_MainWindow.pEditView.pGengrid = NULL;
1988         //ap->mf_MainWindow.pEditView.pSelectAllCheckBox = NULL;
1989         //ap->mf_MainWindow.pEditView.pSelectAllLayout = NULL;
1990         //ap->mf_MainWindow.pEditView.pPathInfo = NULL;
1991         //ap->mf_MainWindow.pEditView.pInfoBox = NULL;
1992         ap->mf_MainWindow.pEditView.bSelectAllChecked = FALSE;;
1993         ap->mf_MainWindow.pEditView.iTotalCount = 0;
1994         ap->mf_MainWindow.pEditView.iCheckedCount = 0;
1995         MF_TRACE_END;
1996 }
1997
1998 #endif
1999
2000 static void __mf_callback_set_select_all_total_count(void *data)
2001 {
2002
2003         MF_TRACE_BEGIN;
2004         mf_retm_if(data == NULL, "data is NULL");
2005
2006         struct appdata *ap = (struct appdata*)data;
2007         int folder_len = 0;
2008         int file_len = 0;
2009
2010         folder_len = eina_list_count(ap->mf_FileOperation.folder_list);
2011         file_len = eina_list_count(ap->mf_FileOperation.file_list);
2012         ap->mf_MainWindow.pEditView.iTotalCount = (folder_len + file_len);
2013 }
2014
2015 static void __mf_callback_save_edit_view_status(void *data)
2016 {
2017         MF_TRACE_BEGIN;
2018         mf_retm_if(data == NULL, "data is NULL");
2019
2020         struct appdata *ap = (struct appdata*)data;
2021         myfileNaviBar *pNavi_s = NULL;
2022         Eina_List *l = NULL;
2023         void *item = NULL;
2024         /*backup the edit point for every navigation bar to get recovery */
2025         EINA_LIST_FOREACH(ap->mf_MainWindow.plistNaviBar, l, item) {
2026                 pNavi_s = (myfileNaviBar *) item;
2027                 if(pNavi_s == NULL)
2028                         continue;
2029
2030                 if (pNavi_s->pre_operation.path != NULL)
2031                         g_string_free(pNavi_s->pre_operation.path, TRUE);
2032                         pNavi_s->pre_operation.path = g_string_new(pNavi_s->pCurrentPath);
2033
2034                 if (pNavi_s->naviFlagInUse == TRUE) {
2035                         pNavi_s->naviFlagEditStart = TRUE;
2036                         pNavi_s->naviFlagEditJoin = TRUE;
2037                 } else {
2038                         pNavi_s->naviFlagEditStart = FALSE;
2039                 }
2040         }
2041         ap->mf_Status.preViewType = ap->mf_Status.view_type;
2042
2043         MF_TRACE_END;
2044 }
2045
2046
2047 void mf_callback_edit_cb(void *data, Evas_Object * obj, void *event_info)
2048 {
2049         MF_TRACE_BEGIN;
2050         struct appdata *ap = (struct appdata *)data;
2051         assert(ap);
2052         myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
2053         mf_retm_if(pNavi_s == NULL, "get navigation bar in use failed");
2054
2055         ap->mf_Status.more = MORE_EDIT;
2056         mf_callback_remove_dir_watch();
2057 #ifdef MYFILE_SPLIT_VIEW
2058         __mf_callback_edit_init(ap);
2059 #endif
2060         /*backup the edit point for every navigation bar to get recovery */
2061         __mf_callback_save_edit_view_status(ap);
2062 #ifdef MYFILE_USB_OTG
2063         /* if start from OTG, set node editstart flag */
2064         if (mf_fm_svc_wrapper_get_location(ap->mf_Status.path->str)== MYFILE_OTG) {
2065                 char *dev_in_use = mf_otg_get_node_in_use(ap);
2066                 mf_otg_set_node_editstart_flag(ap, dev_in_use, TRUE);
2067         }
2068 #endif
2069
2070         mf_navi_bar_create_edit_view(ap);
2071
2072         mf_navi_bar_edit_list_update(ap);
2073
2074         __mf_callback_set_select_all_total_count(ap);
2075         ap->mf_MainWindow.pEditView.bSelectAllChecked = EINA_FALSE;
2076         //elm_check_state_pointer_set(ap->mf_MainWindow.pEditView.pSelectAllCheckBox, &ap->mf_MainWindow.pEditView.bSelectAllChecked);
2077
2078         /*disable all the tab item if tab exists */
2079         MF_TRACE_END;
2080 }
2081
2082
2083 /******************************
2084 ** Prototype    : mf_callback_icu_update_cb
2085 ** Description  :
2086 ** Input        : void *data
2087 ** Output       : int
2088 ** Return Value :
2089 ** Calls        :
2090 ** Called By    :
2091 **
2092 **  History        :
2093 **  1.Date         : 2011/06/30
2094 **    Author       : Samsung
2095 **    Modification : Created function
2096 **/
2097 void mf_callback_icu_update_cb(void *data)
2098 {
2099         ug_send_event(UG_EVENT_REGION_CHANGE);
2100
2101         mf_debug("region changed");
2102         assert(data);
2103         struct appdata *ap = (struct appdata *)data;
2104
2105         if (ap->mf_Status.flagIcuInit == FALSE)
2106                 return;
2107         /* finalize the previous icu session */
2108         mf_util_icu_finalize(ap);
2109         /* start a new icu session*/
2110         mf_util_icu_init(ap);
2111         /* check if we should refresh the list */
2112         int iSortTypeValue = 0;
2113         mf_util_get_vconf_value(VCONF_TYPE_SORT_TYPE, &iSortTypeValue);
2114         if (iSortTypeValue != MYFILE_SORT_BY_DATE_R2O && iSortTypeValue != MYFILE_SORT_BY_DATE_O2R) {
2115                 return ;
2116         }
2117
2118         if (ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.more == MORE_INTERNAL_COPY || ap->mf_Status.more == MORE_INTERNAL_MOVE)
2119                 return ;
2120
2121         myfileNaviBar *pNaviInUse = mf_navi_bar_get_in_use(ap);
2122         if (pNaviInUse == NULL || ap->mf_MainWindow.pNaviLayout == NULL)
2123                 return ;
2124
2125         /*get current genlist */
2126         Evas_Object *currgenlist = ap->mf_MainWindow.pNaviGenlist;
2127         if (currgenlist == NULL)
2128                 return ;
2129
2130         evas_object_del(currgenlist);
2131         /*create new genlist */
2132         Evas_Object *newgenlist = mf_navi_bar_content_create(ap);
2133         mfNaviBarSetContent(ap, ap->mf_MainWindow.pNaviLayout, newgenlist);
2134
2135         return ;
2136 }
2137
2138
2139 /******************************
2140 ** Prototype    : mf_callback_new_folder_create_cb
2141 ** Description  :
2142 ** Input        : void *data
2143 **                Evas_Object *obj
2144 **                void *event_info
2145 ** Output       : None
2146 ** Return Value :
2147 ** Calls        :
2148 ** Called By    :
2149 **
2150 **  History        :
2151 **  1.Date         : 2010/12/10
2152 **    Author       : Samsung
2153 **    Modification : Created function
2154 **
2155 ******************************/
2156 void mf_callback_new_folder_create_cb(void *data, Evas_Object * obj, void *event_info)
2157 {
2158         mf_debug();
2159         struct appdata *ap = (struct appdata *)data;
2160         assert(ap);
2161
2162
2163         if (ap->mf_Status.flagNaviPush) {
2164                 mf_debug("the transition of the naviframe is not finished");
2165                 return;
2166         }
2167         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
2168
2169         if (ap->mf_Status.more == MORE_CREATE_FOLDER)
2170                 return;
2171         int ret = 0;
2172         if (ap->mf_Status.folder_count >= MAX_FOLDER_COUNT) {
2173                 const char *message = GET_STR(MF_MSG_FOLDER_NUM_MAX);
2174                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL);
2175                 return;
2176         }
2177         ap->mf_Status.preMore = ap->mf_Status.more;
2178         ap->mf_Status.more = MORE_CREATE_FOLDER;
2179
2180         ret = mf_util_check_disk_space(ap);
2181         if (ret == MYFILE_ERR_NO_FREE_SPACE) {
2182                 ap->mf_Status.more = MORE_DEFAULT;
2183                 return;
2184         }
2185
2186         mf_navi_bar_create_new_folder_view(ap);
2187         mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
2188
2189 }
2190
2191
2192 void mf_callback_rename_create_cb(void *data, Evas_Object * obj, void *event_info)
2193 {
2194         MF_TRACE_BEGIN;
2195         mf_retm_if(data == NULL, "data is NULL");
2196
2197         mfItemData_s *params = (mfItemData_s *) data;
2198         struct appdata *ap = (struct appdata *)params->ap;
2199
2200         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
2201
2202         if (ap->mf_Status.more == MORE_THUMBNAIL_RENAME)
2203                 return;
2204         mf_widget_unset_part_content(ap->mf_MainWindow.pNaviLayout, "sel_contents");
2205
2206         SAFE_FREE_OBJ(ap->mf_MainWindow.pLabelLayout);
2207         int ret = 0;
2208
2209         ap->mf_Status.preMore = ap->mf_Status.more;
2210         ap->mf_Status.more = MORE_THUMBNAIL_RENAME;
2211
2212         ret = mf_util_check_disk_space(ap);
2213
2214         mf_navi_bar_create_rename_view(params);
2215         mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
2216         MF_TRACE_END;
2217
2218 }
2219
2220 void mf_callback_max_len_reached_cb(void *data, Evas_Object * obj, void *event_info)
2221 {
2222         MF_TRACE_BEGIN;
2223         struct appdata *ap = (struct appdata *)data;
2224         mf_retm_if(ap == NULL, "ap is NULL");
2225         mf_popup_indicator_popup(ap, mf_util_get_text(MF_LABEL_MAX_CHARACTER_REACHED));
2226         MF_TRACE_END;
2227 }
2228
2229
2230
2231
2232 /******************************
2233 ** Prototype    : mf_callback_init_operation_cancel
2234 ** Description  : Samsung
2235 ** Input        : void *data
2236 ** Output       : None
2237 ** Return Value :
2238 ** Calls        :
2239 ** Called By    :
2240 **
2241 **  History        :
2242 **  1.Date         : 2010/12/10
2243 **    Author       : Samsung
2244 **    Modification : Created function
2245 **
2246 ******************************/
2247 void mf_callback_init_operation_cancel(void *data)
2248 {
2249         MF_TRACE_BEGIN;
2250         struct appdata *ap = (struct appdata *)data;
2251         mf_retm_if(ap == NULL, "ap is NULL");
2252
2253         if (ap->mf_FileOperation.pCancel) {
2254                 mf_cancel_free(ap->mf_FileOperation.pCancel);
2255                 ap->mf_FileOperation.pCancel = NULL;
2256         }
2257
2258         ap->mf_FileOperation.pCancel = mf_cancel_new();
2259         MF_TRACE_END;
2260 }
2261
2262 /******************************
2263 ** Prototype    : __mf_callback_idle_refresh
2264 ** Description  : Samsung
2265 ** Input        : void *data
2266 ** Output       : None
2267 ** Return Value :
2268 ** Calls        :
2269 ** Called By    :
2270 **
2271 **  History        :
2272 **  1.Date         : 2010/12/10
2273 **    Author       : Samsung
2274 **    Modification : Created function
2275 **
2276 ******************************/
2277 static int __mf_callback_idle_refresh(void *data)
2278 {
2279         MF_TRACE_BEGIN;
2280         struct appdata *ap = (struct appdata *)data;
2281         mf_retvm_if(ap == NULL, 0, "ap is NULL");
2282         mf_util_refresh_screen(ap);
2283
2284         MF_TRACE_END;
2285         return ECORE_CALLBACK_CANCEL;
2286 }
2287
2288
2289 /******************************
2290 ** Prototype    : __mf_callback_progress_bar_state_cb
2291 ** Description  : Samsung
2292 ** Input        : void *data
2293 ** Output       : None
2294 ** Return Value :
2295 ** Calls        :
2296 ** Called By    :
2297 **
2298 **  History        :
2299 **  1.Date         : 2010/12/10
2300 **    Author       : Samsung
2301 **    Modification : Created function
2302 **
2303 ******************************/
2304 static void __mf_callback_progress_bar_state_cb(void *data)
2305 {
2306         MF_TRACE_BEGIN;
2307         struct appdata *ap = (struct appdata *)data;
2308         mf_retm_if(ap == NULL, "ap is NULL");
2309
2310         mf_fo_msg *msg = ap->mf_FileOperation.pMessage;
2311         char lable[10] = { '\0', };
2312         double value = 0.0;
2313         char count_label[10] = { '\0' };
2314         int count = 0;
2315         int total_count = 0;
2316         Evas_Object *layout = ap->mf_MainWindow.pProgressLayout;
2317         mf_retm_if(layout == NULL, "layout is NULL");
2318
2319         value = (double)msg->current_size / msg->total_size;
2320         elm_progressbar_value_set(ap->mf_FileOperation.progress_bar, value);
2321
2322         snprintf(lable, sizeof(lable), "%d%s", (int)(value * 100), "%");
2323
2324         edje_object_part_text_set(elm_layout_edje_get(layout), "elm.text.left", lable);
2325
2326
2327         total_count = ap->mf_FileOperation.iTotalCount;
2328         count = msg->current_index;
2329
2330         if (count <= total_count) {
2331                 snprintf(count_label, sizeof(count_label), "%d/%d", count, total_count);
2332         }
2333         edje_object_part_text_set(elm_layout_edje_get(layout), "elm.text.right", count_label);
2334
2335         MF_TRACE_END;
2336 }
2337
2338
2339
2340 /******************************
2341 ** Prototype    : mf_callback_progress_bar_cancel_cb
2342 ** Description  : Samsung
2343 ** Input        : void *data
2344 **                Evas_Object *obj
2345 **                void *event_info
2346 ** Output       : None
2347 ** Return Value :
2348 ** Calls        :
2349 ** Called By    :
2350 **
2351 **  History        :
2352 **  1.Date         : 2010/12/10
2353 **    Author       : Samsung
2354 **    Modification : Created function
2355 **
2356 ******************************/
2357 void mf_callback_progress_bar_cancel_cb(void *data, Evas_Object * obj, void *event_info)
2358 {
2359         MF_TRACE_BEGIN;
2360         struct appdata *ap = (struct appdata *)data;
2361         mf_retm_if(ap == NULL, "ap is NULL");
2362
2363         mf_cancel_do_cancel(ap->mf_FileOperation.pCancel);
2364         mf_msg_request_handled_send();
2365
2366         MF_TRACE_END;
2367 }
2368
2369
2370 /******************************
2371 ** Prototype    : mfCopyCB
2372 ** Description  :
2373 ** Input        : void *data
2374 **                Evas_Object *obj
2375 **                void *event_info
2376 ** Output       : None
2377 ** Return Value :
2378 ** Calls        :
2379 ** Called By    :
2380 **
2381 **  History        :
2382 **  1.Date         : 2010/12/10
2383 **    Author       : Samsung
2384 **    Modification : Created function
2385 **
2386 ******************************/
2387 void mf_callback_copy_move_cb(void *data, Evas_Object * obj, void *event_info)
2388 {
2389         MF_TRACE_BEGIN;
2390         struct appdata *ap = (struct appdata *)data;
2391         mf_retm_if(ap == NULL, "ap is NULL");
2392         mf_retm_if(event_info == NULL, "event_info is NULL");
2393
2394         if (ap->mf_Status.flagNaviPush) {
2395                 mf_debug("the transition of the naviframe is not finished");
2396                 return;
2397         }
2398
2399
2400         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2401         const char *label = elm_object_item_text_get(item);
2402
2403         printf("label is [%s]\n", label);
2404         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
2405         if (label) {
2406                 ap->mf_Status.flagFolderSelect = FALSE;
2407                 ap->mf_Status.flagFileSelect = FALSE;
2408
2409                 if (ap->mf_FileRecordList.value_saver != NULL) {
2410                         mf_util_free_eina_list_with_data(&ap->mf_FileRecordList.value_saver, MYFILE_TYPE_GSTRING);
2411                         ap->mf_FileRecordList.value_saver = NULL;
2412                 }
2413                 ap->mf_FileRecordList.value_saver = mf_util_get_all_selected(ap);
2414
2415                 if (mf_util_get_eina_list_len(ap->mf_FileRecordList.value_saver) < 1) {
2416                         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT_BTN, NULL, GET_SYS_STR(MF_LABEL_NOTHING_SELECTED),
2417                                                                                GET_SYS_STR(MF_BUTTON_LABEL_OK), NULL, NULL, mf_callback_warning_popup_cb, ap);
2418                         return;
2419                 }
2420
2421                 if (ap->mf_FileOperation.source != NULL) {
2422                         g_string_free(ap->mf_FileOperation.source, TRUE);
2423                         ap->mf_FileOperation.source = NULL;
2424                 }
2425                 ap->mf_FileOperation.source = g_string_new(ap->mf_Status.path->str);
2426                 if (g_strcmp0(label, GET_SYS_STR(LABEL_MOVE)) == 0) {
2427                         ap->mf_Status.more = MORE_INTERNAL_MOVE;
2428                 } else if (g_strcmp0(label, GET_SYS_STR(LABEL_COPY)) == 0) {
2429                         ap->mf_Status.more = MORE_INTERNAL_COPY;
2430                 } else {
2431                         return;
2432                 }
2433
2434                 if (ap->mf_MainWindow.pLabelLayout) {
2435                         mf_widget_unset_part_content(ap->mf_MainWindow.pNaviLayout, "sel_contents");
2436                         if (ap->mf_MainWindow.pLabelLayout)
2437                                 evas_object_del(ap->mf_MainWindow.pLabelLayout);
2438                         ap->mf_MainWindow.pLabelLayout = NULL;
2439                 }
2440                 /*pop select view*/
2441                 /*set Navigation Bar for Destination selection */
2442                 ap->mf_Status.view_type = mf_view_root;
2443 #ifdef MYFILE_SPLIT_VIEW
2444                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
2445                         mf_split_view_unset_right_content(ap);
2446                         mf_widget_unset_main_layout_content(ap->mf_MainWindow.pMainLayout);
2447                         mf_split_view_hide(ap);
2448                         evas_object_show(ap->mf_MainWindow.pMainLayout);
2449                         elm_object_part_content_set(ap->mf_MainWindow.pMainLayout, "elm.swallow.content", ap->mf_MainWindow.pNaviBar);
2450                 }
2451 #endif
2452                 mf_widget_refresh_view(ap);
2453         }
2454         MF_TRACE_END;
2455 }
2456
2457
2458 /******************************
2459 ** Prototype    : mf_callback_paste_here_cb
2460 ** Description  :
2461 ** Input        : void *data
2462 **                Evas_Object *obj
2463 **                void *event_info
2464 ** Output       : None
2465 ** Return Value :
2466 ** Calls        :
2467 ** Called By    :
2468 **
2469 **  History        :
2470 **  1.Date         : 2010/12/10
2471 **    Author       : Samsung
2472 **    Modification : Created function
2473 **
2474 ******************************/
2475 void mf_callback_paste_here_cb(void *data, Evas_Object * obj, void *event_info)
2476 {
2477         MF_TRACE_BEGIN;
2478         struct appdata *ap = (struct appdata *)data;
2479         mf_retm_if(ap == NULL, "ap is NULL");
2480
2481         if (ap->mf_Status.flagNaviPush) {
2482                 mf_debug("the transition of the naviframe is not finished");
2483                 return;
2484         }
2485
2486         int source_len = 0;
2487         int dest_len = 0;
2488         GList *pSourceList = NULL;
2489         int count = 0;
2490         gchar *pDestPath = NULL;
2491
2492         mf_retm_if(ap->mf_FileOperation.source == NULL, "ap->mf_FileOperation.source is NULL");
2493         mf_retm_if(ap->mf_FileOperation.source->str == NULL, "ap->mf_FileOperation.source is NULL");
2494
2495         mf_retm_if(ap->mf_Status.path == NULL, "ap->mf_Status.path is NULL");
2496         mf_retm_if(ap->mf_Status.path->str == NULL, "ap->mf_Status.path->str is NULL");
2497
2498         ap->mf_Status.more = MORE_DATA_COPYING;
2499         ap->mf_FileOperation.destination = ap->mf_Status.path;
2500
2501         if (ap->mf_FileOperation.source && ap->mf_FileOperation.source->str) {
2502                 source_len = strlen(ap->mf_FileOperation.source->str);
2503         }
2504
2505         if (ap->mf_FileOperation.destination && ap->mf_FileOperation.destination->str) {
2506                 dest_len = strlen(ap->mf_FileOperation.destination->str);
2507         }
2508
2509         if (source_len == 0 || dest_len == 0) {
2510                 MF_TRACE_END;
2511                 return;
2512         }
2513         /*glib api change */
2514
2515         if (!mf_util_check_forbidden_operation(ap)) {
2516                 return;
2517         }
2518         if (source_len == dest_len && strcmp(ap->mf_FileOperation.destination->str, ap->mf_FileOperation.source->str) == 0) {
2519                 ap->mf_FileOperation.refresh_type = TRUE;
2520         } else {
2521                 ap->mf_FileOperation.refresh_type = FALSE;
2522         }
2523
2524         mf_util_merge_eina_list_to_glist(ap->mf_FileRecordList.value_saver, &pSourceList);
2525
2526         if (pSourceList) {
2527                 count = g_list_length(pSourceList);
2528         } else {
2529                 MF_TRACE_END;
2530                 return;
2531         }
2532
2533         ap->mf_FileOperation.iTotalCount = count;
2534         pDestPath = g_strdup(ap->mf_Status.path->str);
2535         if (pDestPath == NULL) {
2536                 g_list_free(pSourceList);
2537                 pSourceList = NULL;
2538                 MF_TRACE_END;
2539                 return;
2540         }
2541
2542         mf_callback_init_operation_cancel(ap);
2543         ap->mf_FileOperation.iRequestType = MF_REQ_NONE;
2544
2545         ap->mf_FileOperation.pSourceList = pSourceList;
2546
2547         if (mf_copy_copy_items(pSourceList, pDestPath, ap->mf_FileOperation.pCancel, TRUE, ap) == 0) {
2548                 ap->mf_FileOperation.iOperationSuccessFlag = TRUE;
2549                 mf_callback_remove_dir_watch();
2550                 ap->mf_MainWindow.pProgressPopup = mf_popup_create_pb_popup(ap, GET_SYS_STR(MF_MSG_COPYING), count, mf_callback_progress_bar_cancel_cb, ap);
2551         } else {
2552                 mf_util_exception_func(ap);
2553         }
2554
2555         g_free(pDestPath);
2556         pDestPath = NULL;
2557
2558         MF_TRACE_END;
2559 }
2560
2561
2562 /******************************
2563 ** Prototype    : mf_move_here_cb
2564 ** Description  :
2565 ** Input        : void *data
2566 **                Evas_Object *obj
2567 **                void *event_info
2568 ** Output       : None
2569 ** Return Value :
2570 ** Calls        :
2571 ** Called By    :
2572 **
2573 **  History        :
2574 **  1.Date         : 2010/12/10
2575 **    Author       : Samsung
2576 **    Modification : Created function
2577 **
2578 ******************************/
2579 void mf_callback_move_here_cb(void *data, Evas_Object * obj, void *event_info)
2580 {
2581         MF_TRACE_BEGIN;
2582         struct appdata *ap = (struct appdata *)data;
2583         mf_retm_if(ap == NULL, "ap is NULL");
2584         if (ap->mf_Status.flagNaviPush) {
2585                 mf_debug("the transition of the naviframe is not finished");
2586                 return;
2587         }
2588
2589         int source_len = 0;
2590         int dest_len = 0;
2591         GList *pSourceList = NULL;
2592         int count = 0;
2593         gchar *pDestPath = NULL;
2594
2595         mf_retm_if(ap->mf_FileOperation.source == NULL, "ap->mf_FileOperation.source is NULL");
2596         mf_retm_if(ap->mf_FileOperation.source->str == NULL, "ap->mf_FileOperation.source is NULL");
2597
2598         mf_retm_if(ap->mf_Status.path == NULL, "ap->mf_Status.path is NULL");
2599         mf_retm_if(ap->mf_Status.path->str == NULL, "ap->mf_Status.path->str is NULL");
2600         ap->mf_Status.more = MORE_DATA_MOVING;
2601
2602         ap->mf_FileOperation.destination = ap->mf_Status.path;
2603
2604         if (ap->mf_FileOperation.source && ap->mf_FileOperation.source->str) {
2605                 source_len = strlen(ap->mf_FileOperation.source->str);
2606         }
2607
2608         if (ap->mf_FileOperation.destination && ap->mf_FileOperation.destination->str) {
2609                 dest_len = strlen(ap->mf_FileOperation.destination->str);
2610         }
2611
2612         if (source_len == 0 || dest_len == 0) {
2613                 MF_TRACE_END;
2614                 return;
2615         }
2616         /*glib api change */
2617         if (!mf_util_check_forbidden_operation(ap)) {
2618                 return;
2619         } else {
2620                 ap->mf_FileOperation.refresh_type = FALSE;
2621         }
2622
2623         mf_util_merge_eina_list_to_glist(ap->mf_FileRecordList.value_saver, &pSourceList);
2624
2625         if (pSourceList) {
2626                 count = g_list_length(pSourceList);
2627         } else {
2628                 MF_TRACE_END;
2629                 return;
2630         }
2631
2632         ap->mf_FileOperation.iTotalCount = count;
2633         pDestPath = g_strdup(ap->mf_Status.path->str);
2634         if (pDestPath == NULL) {
2635                 g_list_free(pSourceList);
2636                 pSourceList = NULL;
2637                 MF_TRACE_END;
2638                 return;
2639         }
2640
2641         mf_callback_init_operation_cancel(ap);
2642         ap->mf_FileOperation.iRequestType = MF_REQ_NONE;
2643
2644         ap->mf_FileOperation.pSourceList = pSourceList;
2645         if (mf_move_move_items(pSourceList, pDestPath, ap->mf_FileOperation.pCancel, true, ap) == 0) {
2646                 ap->mf_FileOperation.iOperationSuccessFlag = TRUE;
2647                 mf_callback_remove_dir_watch();
2648                 ap->mf_MainWindow.pProgressPopup = mf_popup_create_pb_popup(ap, GET_SYS_STR(MF_MSG_MOVING), count, mf_callback_progress_bar_cancel_cb, ap);
2649         } else {
2650                 mf_util_exception_func(ap);
2651         }
2652         g_free(pDestPath);
2653         pDestPath = NULL;
2654 }
2655
2656 /******************************
2657 ** Prototype    : __mf_callback_confirm_delete
2658 ** Description  :
2659 ** Input        : void *data
2660 **                Evas_Object *obj
2661 **                void *event_info
2662 ** Output       : None
2663 ** Return Value :
2664 ** Calls        :
2665 ** Called By    :
2666 **
2667 **  History        :
2668 **  1.Date         : 2010/12/10
2669 **    Author       : Samsung
2670 **    Modification : Created function
2671 **
2672 ******************************/
2673 static void __mf_callback_confirm_delete(void *data, Evas_Object * obj, void *event_info)
2674 {
2675         struct appdata *ap = (struct appdata *)data;
2676         mf_retm_if(ap == NULL, "ap is NULL");
2677
2678         Evas_Object *btn = (Evas_Object *)obj;
2679         const char *label = elm_object_text_get(btn);
2680
2681         if (g_strcmp0(label, GET_SYS_STR(LABEL_CANCEL)) == 0 ) {
2682                 evas_object_del(ap->mf_MainWindow.pNormalPopup);
2683                 ap->mf_MainWindow.pNormalPopup = NULL;
2684                 return;
2685         } else if (g_strcmp0(label, GET_SYS_STR(LABEL_DELETE)) == 0) {
2686                 if (ap->mf_MainWindow.pNormalPopup) {
2687                         evas_object_del(ap->mf_MainWindow.pNormalPopup);
2688                         ap->mf_MainWindow.pNormalPopup = NULL;
2689                 }
2690
2691                 if (ap->mf_MainWindow.pLabelLayout) {
2692                         mf_widget_unset_part_content(ap->mf_MainWindow.pNaviLayout, "sel_contents");
2693                         if (ap->mf_MainWindow.pLabelLayout)
2694                                 evas_object_del(ap->mf_MainWindow.pLabelLayout);
2695                         ap->mf_MainWindow.pLabelLayout = NULL;
2696                 }
2697
2698                 ap->mf_FileOperation.refresh_type = TRUE;
2699
2700                 /*setting item check */
2701                 Eina_List *selected_list = mf_util_get_all_selected(ap);
2702
2703                 if (ap->mf_FileRecordList.value_saver != NULL) {
2704                         mf_util_free_eina_list_with_data(&ap->mf_FileRecordList.value_saver, MYFILE_TYPE_GSTRING);
2705                         ap->mf_FileRecordList.value_saver = NULL;
2706                 }
2707                 ap->mf_FileRecordList.value_saver = selected_list;
2708
2709                 if (mf_util_get_eina_list_len(ap->mf_FileRecordList.value_saver) < 1) {
2710                         ap->mf_MainWindow.pNormalPopup =
2711                                 mf_popup_create_popup(ap, POPMODE_TEXT_BTN, NULL, GET_SYS_STR(MF_LABEL_NOTHING_SELECTED),
2712                                                       GET_SYS_STR(MF_BUTTON_LABEL_OK), NULL, NULL, mf_callback_warning_popup_cb, ap);
2713                 } else {
2714                         GList *pSourceList = NULL;
2715                         int count = 0;
2716
2717                         mf_util_merge_eina_list_to_glist(ap->mf_FileRecordList.value_saver, &pSourceList);
2718                         if (pSourceList) {
2719                                 count = g_list_length(pSourceList);
2720                         } else {
2721                                 MF_TRACE_END;
2722                                 return;
2723                         }
2724
2725                         ap->mf_FileOperation.iTotalCount = count;
2726                         mf_callback_init_operation_cancel(ap);
2727                         ap->mf_Status.more = MORE_DELETE;
2728                         ap->mf_FileOperation.iRequestType = MF_REQ_NONE;
2729
2730                         ap->mf_FileOperation.pSourceList = pSourceList;
2731                         mf_callback_remove_dir_watch();
2732
2733                         if (mf_delete_items(pSourceList, ap->mf_FileOperation.pCancel, TRUE, ap) == 0) {
2734                                 ap->mf_FileOperation.iOperationSuccessFlag = TRUE;
2735                                 mf_callback_remove_dir_watch();
2736                                 ap->mf_MainWindow.pProgressPopup =
2737                                         mf_popup_create_pb_popup(ap, GET_SYS_STR(MF_MSG_DELETING), count, mf_callback_progress_bar_cancel_cb, ap);
2738                         } else {
2739                                 mf_util_exception_func(ap);
2740                         }
2741                 }
2742         }
2743 }
2744
2745 /******************************
2746 ** Prototype    : mf_callback_delete_cb
2747 ** Description  :
2748 ** Input        : void *data
2749 **                Evas_Object *obj
2750 **                void *event_info
2751 ** Output       : None
2752 ** Return Value :
2753 ** Calls        :
2754 ** Called By    :
2755 **
2756 **  History        :
2757 **  1.Date         : 2010/12/10
2758 **    Author       : Samsung
2759 **    Modification : Created function
2760 **
2761 ******************************/
2762 void mf_callback_delete_cb(void *data, Evas_Object * obj, void *event_info)
2763 {
2764         struct appdata *ap = (struct appdata *)data;
2765         assert(ap);
2766         if (ap->mf_Status.flagNaviPush) {
2767                 mf_debug("the transition of the naviframe is not finished");
2768                 return;
2769         }
2770         mf_debug("delete clicked\n");
2771         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TITLE_TEXT_TWO_BTN,
2772                                                                NULL,
2773                                                                GET_SYS_STR(MF_BUTTON_LABEL_DEL),
2774                                                                GET_SYS_STR(LABEL_DELETE), GET_SYS_STR(LABEL_CANCEL), NULL, __mf_callback_confirm_delete, ap);
2775 }
2776
2777
2778 /******************************
2779 ** Prototype    : mf_callback_thread_pipe_cb
2780 ** Description  :
2781 ** Input        : void *data
2782 **                void *buffer
2783 **                unsigned int nbyte
2784 ** Output       : None
2785 ** Return Value :
2786 ** Calls        :
2787 ** Called By    :
2788 **
2789 **  History        :
2790 **  1.Date         : 2010/12/10
2791 **    Author       : Samsung
2792 **    Modification : Created function
2793 **
2794 ******************************/
2795 void mf_callback_operation_request_rename_cb(void *data, Evas_Object * obj, void *event_info)
2796 {
2797         MF_TRACE_BEGIN;
2798         struct appdata *ap = (struct appdata *)data;
2799         mf_retm_if(ap == NULL, "ap is NULL");
2800
2801         mf_fo_request *request = ap->mf_FileOperation.pRequest;
2802
2803         if (ap->mf_MainWindow.pProgressPopup) {
2804                 evas_object_show(ap->mf_MainWindow.pProgressPopup);
2805         }
2806
2807         ap->mf_FileOperation.iRequestType = MF_REQ_RENAME;
2808         mf_request_set_result(request, MF_REQ_RENAME);
2809         MF_TRACE_END;
2810
2811 }
2812
2813 void mf_callback_operation_request_replace_cb(void *data, Evas_Object * obj, void *event_info)
2814 {
2815         MF_TRACE_BEGIN;
2816         struct appdata *ap = (struct appdata *)data;
2817         mf_retm_if(ap == NULL, "ap is NULL");
2818
2819         mf_fo_request *request = ap->mf_FileOperation.pRequest;
2820
2821         if (ap->mf_MainWindow.pProgressPopup) {
2822                 evas_object_show(ap->mf_MainWindow.pProgressPopup);
2823         }
2824
2825         ap->mf_FileOperation.iRequestType = MF_REQ_MERGE;
2826         if (ap->mf_FileOperation.refresh_type == TRUE) {
2827                 mf_request_set_result(request, MF_REQ_SKIP);
2828         } else {
2829                 mf_request_set_result(request, MF_REQ_MERGE);
2830         }
2831         MF_TRACE_END;
2832
2833 }
2834
2835 void mf_callback_operation_request_cancel_cb(void *data, Evas_Object * obj, void *event_info)
2836 {
2837         MF_TRACE_BEGIN;
2838         struct appdata *ap = (struct appdata *)data;
2839         mf_retm_if(ap == NULL, "ap is NULL");
2840
2841         mf_fo_request *request = ap->mf_FileOperation.pRequest;
2842
2843         if (ap->mf_MainWindow.pProgressPopup) {
2844                 evas_object_show(ap->mf_MainWindow.pProgressPopup);
2845         }
2846
2847         mf_request_set_result(request, MF_REQ_CANCEL);
2848         MF_TRACE_END;
2849
2850 }
2851
2852
2853 void mf_callback_thread_pipe_cb(void *data, void *buffer, unsigned int nbyte)
2854 {
2855         MF_TRACE_BEGIN;
2856         mf_debug(":::::::::: Main thread id = %d ::::::::::", (int)pthread_self());
2857         struct appdata *ap = (struct appdata *)data;
2858         mf_retm_if(ap == NULL, "ap is NULL");
2859
2860         mf_fo_msg *pPipeMsg = (mf_fo_msg *) buffer;
2861         char *message = NULL;
2862         int error_type = 0;
2863
2864         if (!MYFILE_MAGIC_CHECK(pPipeMsg, MYFILE_MAGIC_PIPE_DATA)) {
2865                 mf_error(":::::::::::::p_pipe_data ERROR:::::::::::::");
2866                 return;
2867         }
2868         ap->mf_FileOperation.pMessage = pPipeMsg;
2869         ap->mf_FileOperation.pRequest = pPipeMsg->request;
2870         ap->mf_FileOperation.sync_pipe = pPipeMsg->pipe;
2871         mf_debug("::::::::::: pPipeMsg->msg_type is [%d]", pPipeMsg->msg_type);
2872
2873         mf_util_set_pm_lock(ap, EINA_TRUE);
2874         switch (pPipeMsg->msg_type) {
2875         case MF_MSG_NONE:
2876         case MF_MSG_SKIP:
2877         case MF_MSG_SYNC:
2878                 mf_msg_request_handled_send();
2879                 break;
2880         case MF_MSG_CANCELLED:
2881                 if (ap->mf_MainWindow.pProgressPopup) {
2882                         evas_object_del(ap->mf_MainWindow.pProgressPopup);
2883                         ap->mf_MainWindow.pProgressPopup = NULL;
2884                 }
2885                 ap->mf_MainWindow.pFinishPopup = mf_popup_create_popup(ap, POPMODE_TEXT_NOT_DISABLED, NULL,
2886                                                                        "Canceling...", NULL, NULL, NULL, NULL, NULL);
2887                 mf_msg_request_handled_send();
2888                 ap->mf_FileOperation.iOperationSuccessFlag = FALSE;
2889                 break;
2890         case MF_MSG_DOING:
2891                 if (ap->mf_Status.view_type == mf_view_root_category && (ap->mf_Status.more == MORE_DELETE || ap->mf_Status.more == MORE_IDLE_DELETE)) {
2892                         mf_util_remove_item_from_list_by_name(&ap->mf_FileOperation.category_list, pPipeMsg->current_real);
2893                 }
2894                 __mf_callback_progress_bar_state_cb(ap);
2895                 mf_msg_request_handled_send();
2896                 break;
2897         case MF_MSG_REQUEST:
2898                 if (ap->mf_FileOperation.iRequestType == MF_REQ_RENAME) {
2899                         mf_request_set_result(pPipeMsg->request, MF_REQ_RENAME);
2900
2901                 } else if (ap->mf_FileOperation.iRequestType == MF_REQ_MERGE) {
2902                         if (ap->mf_FileOperation.refresh_type == TRUE) {
2903                                 mf_request_set_result(pPipeMsg->request, MF_REQ_SKIP);
2904                         } else {
2905                                 mf_request_set_result(pPipeMsg->request, MF_REQ_MERGE);
2906                         }
2907                 } else {
2908                         ap->mf_FileOperation.iRequestType = MF_REQ_RENAME;
2909                         mf_request_set_result(pPipeMsg->request, MF_REQ_RENAME);
2910                 }
2911                 break;
2912         case MF_MSG_ERROR:
2913                 error_type = FO_ERROR_CHECK(pPipeMsg->error_code);
2914                 switch (error_type) {
2915                 case MF_FO_ERR_PERMISSION:
2916                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_PERMISSION_ERR), NULL);
2917                         break;
2918                 case MF_FO_ERR_ARGUMENT:
2919                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_ARG_ERR), NULL);
2920                         break;
2921                 case MF_FO_ERR_FAULT:
2922                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_FAULT_ERR), NULL);
2923                         break;
2924                 case MF_FO_ERR_TYPE:
2925                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_FILE_TYPE_ERR), NULL);
2926                         break;
2927                 case MF_FO_ERR_MAX_OPEN:
2928                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_MAX_OPEN_ERR), NULL);
2929                         break;
2930                 case MF_FO_ERR_SPACE:
2931                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_NO_SPACE), NULL);
2932                         break;
2933                 case MF_FO_ERR_RO:
2934                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_RO_ERR), NULL);
2935                         break;
2936                 case MF_FO_ERR_LOOP:
2937                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_LOOP_ERR), NULL);
2938                         break;
2939                 case MF_FO_ERR_MEM:
2940                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_MEM_ERR), NULL);
2941                         break;
2942                 case MF_FO_ERR_NOT_EXIST:
2943                         message = g_strconcat("Operation failed<br>", GET_SYS_STR(MF_LABEL_FILE_NOT_EXIST), NULL);
2944                         break;
2945                 case MF_FO_ERR_LONG_NAME:
2946                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_LONG_NAME_ERR), NULL);
2947                         break;
2948                 case MF_FO_ERR_BIG_SIZE:
2949                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_BIG_SIZE_ERR), NULL);
2950                         break;
2951                 case MF_FO_ERR_UNKNOWN:
2952                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_UNKNOWN_ERR), NULL);
2953                         break;
2954                 case MF_FO_ERR_IO:
2955                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_IO_ERR), NULL);
2956                         break;
2957                 default:
2958                         message = g_strconcat("Operation failed<br>", GET_STR(MF_MSG_DEFAULT_ERR), NULL);
2959                         break;
2960                 }
2961
2962                 if (ap->mf_MainWindow.pProgressPopup) {
2963                         evas_object_del(ap->mf_MainWindow.pProgressPopup);
2964                         ap->mf_MainWindow.pProgressPopup = NULL;
2965                 }
2966
2967                 if (ap->mf_MainWindow.pFinishPopup) {
2968                         evas_object_del(ap->mf_MainWindow.pFinishPopup);
2969                         ap->mf_MainWindow.pFinishPopup = NULL;
2970                 }
2971
2972                 SAFE_FREE_CHAR(ap->mf_FileOperation.pOperationMsg);
2973                 if (error_type ==  MF_FO_ERR_SPACE) {
2974                         ap->mf_FileOperation.pOperationMsg = message;
2975                 } else {
2976                         if (ap->mf_Status.more == MORE_DATA_COPYING) {
2977                                 ap->mf_FileOperation.pOperationMsg = g_strdup(GET_STR(MF_MSG_COPY_FAILED));
2978                         } else if (ap->mf_Status.more == MORE_DATA_MOVING) {
2979                                 ap->mf_FileOperation.pOperationMsg = g_strdup(GET_SYS_STR(MF_MSG_MOVE_FAILED));
2980                         } else if (ap->mf_Status.more == MORE_DELETE || ap->mf_Status.more == MORE_IDLE_DELETE) {
2981                                 ap->mf_FileOperation.pOperationMsg = g_strdup(GET_SYS_STR(MF_LABEL_DELETE_FAILED));
2982                         } else {
2983                                 ap->mf_FileOperation.pOperationMsg = message;
2984                         }
2985                 }
2986
2987
2988                 ap->mf_FileOperation.pGenlistItem = NULL;
2989                 g_free(message);
2990                 ap->mf_FileOperation.iOperationSuccessFlag = FALSE;
2991                 mf_msg_request_handled_send();
2992                 break;
2993         case MF_MSG_END:
2994
2995                 if (ap->mf_FileOperation.source) {
2996                         g_string_free(ap->mf_FileOperation.source, TRUE);
2997                         ap->mf_FileOperation.source = NULL;
2998                 }
2999                 if (ap->mf_FileOperation.pSourceList) {
3000                         g_list_free(ap->mf_FileOperation.pSourceList);
3001                         ap->mf_FileOperation.pSourceList = NULL;
3002                 }
3003                 if (ap->mf_MainWindow.pProgressPopup) {
3004                         evas_object_del(ap->mf_MainWindow.pProgressPopup);
3005                         ap->mf_MainWindow.pProgressPopup = NULL;
3006                 }
3007                 ecore_idler_add((Ecore_Task_Cb)__mf_callback_idle_refresh, ap);
3008                 if (pPipeMsg->pipe) {
3009                         ecore_pipe_del(pPipeMsg->pipe);
3010                         pPipeMsg->pipe = NULL;
3011                 }
3012                 mf_msg_request_handled_send();
3013
3014                 mf_util_set_pm_lock(ap, EINA_FALSE);
3015                 if (ap->mf_FileRecordList.value_saver != NULL) {
3016                         mf_util_free_eina_list_with_data(&ap->mf_FileRecordList.value_saver, MYFILE_TYPE_GSTRING);
3017                         ap->mf_FileRecordList.value_saver = NULL;
3018                 }
3019                 break;
3020         default:
3021                 mf_msg_request_handled_send();
3022                 break;
3023         }
3024
3025 }
3026
3027
3028 void mf_callback_exception_popup_cb(void *data)
3029 {
3030         struct appdata *ap = (struct appdata *)data;
3031         mf_retm_if(ap == NULL, "ap is NULL");
3032
3033         if (ap->mf_MainWindow.pNormalPopup) {
3034                 evas_object_del(ap->mf_MainWindow.pNormalPopup);
3035                 ap->mf_MainWindow.pNormalPopup = NULL;
3036         }
3037
3038         mf_callback_cancel_cb(ap, NULL, NULL);
3039 }
3040
3041 /******         Memory card connection/removal handler          ******/
3042 static void __mf_callback_mmc_connected(void *data)
3043 {
3044         struct appdata *ap = (struct appdata *)data;
3045         mf_retm_if(ap == NULL, "appdata is NULL");
3046         mf_retm_if(ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL, "mf_Status.path is NULL");
3047
3048         Evas_Object *entry = NULL;
3049         ap->mf_Status.iStorageState |= MYFILE_MMC;
3050
3051         if (ap->mf_Status.more == MORE_CREATE_FOLDER || ap->mf_Status.more == MORE_SEARCH || (ap->mf_Status.more == MORE_RENAME && ap->mf_Status.preMore == MORE_SEARCH))
3052                 return;
3053
3054         if (ap->mf_Status.view_type != mf_view_root) {
3055                 return;
3056         }
3057
3058         mf_util_action_storage_insert(ap, GET_SYS_STR(MF_LABEL_MMC));
3059         if (ap->mf_Status.more == MORE_RENAME) {
3060                 entry = ap->mf_MainWindow.pEntry;
3061                 if (entry != NULL) {
3062                         elm_object_focus_set(entry, EINA_TRUE);
3063                 }
3064         }
3065         mf_navi_bar_title_set(ap);
3066
3067 }
3068
3069 static void __mf_callback_mmc_remove_view_operation(void *data, int optStorage)
3070 {
3071         struct appdata *ap = (struct appdata *)data;
3072         mf_retm_if(ap == NULL, "appdata is NULL");
3073
3074         Evas_Object *parent = NULL;
3075         const char *labelStorage = NULL;
3076         if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_LIST || ap->mf_Status.flagViewType == MF_VIEW_SYTLE_LIST_DETAIL) {
3077                 parent = ap->mf_MainWindow.pNaviGenlist;
3078         } else {
3079                 parent = ap->mf_MainWindow.pNaviGengrid;
3080         }
3081         switch (optStorage) {
3082         case MYFILE_PHONE:
3083                 labelStorage = PHONE_FOLDER;
3084                 break;
3085         case MYFILE_MMC:
3086                 labelStorage = MEMORY_FOLDER;
3087                 break;
3088         case MYFILE_OTG:
3089                 labelStorage = OTG_FOLDER;
3090                 break;
3091         default:
3092                 break;
3093         }
3094         mf_widget_item_remove(parent, labelStorage, ap->mf_Status.flagViewType);
3095 #ifdef MYFILE_SPLIT_VIEW
3096         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3097                 if (optStorage == MYFILE_MMC) {
3098                         elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3099                         ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3100                 }
3101         }
3102 #endif
3103
3104 }
3105
3106 static void __mf_callback_mmc_remove_category_view_items(void *data, int optStorage)
3107 {
3108         struct appdata *ap = (struct appdata *)data;
3109         mf_retm_if(ap == NULL, "appdata is NULL");
3110
3111         Evas_Object *parent = NULL;
3112         if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_LIST || ap->mf_Status.flagViewType == MF_VIEW_SYTLE_LIST_DETAIL) {
3113                 parent = ap->mf_MainWindow.pNaviGenlist;
3114         } else {
3115                 parent = ap->mf_MainWindow.pNaviGengrid;
3116         }
3117         mf_widget_items_remove(parent, optStorage, ap->mf_Status.flagViewType);
3118         mf_util_remove_item_from_list_by_location(&ap->mf_FileOperation.category_list, optStorage);
3119 }
3120
3121 static void __mf_callback_mmc_removed(void *data, MF_STORAGE storage)
3122 {
3123         struct appdata *ap = (struct appdata *)data;
3124         mf_retm_if(ap == NULL, "appdata is NULL");
3125         mf_retm_if(ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL, "mf_Status.path is NULL");
3126
3127         Evas_Object *entry = NULL;
3128         char *labelStorage = NULL;
3129         MF_STORAGE optStorage = MYFILE_NONE;
3130         myfileNaviBar *pNaviInUseStruct = NULL;
3131         myfileNaviBar *pNaviToShowStruct = NULL;
3132         Evas_Object *pNaviBarStorageView = NULL;
3133         bool bEditStartFlag = FALSE;
3134
3135         optStorage = storage;
3136         switch (optStorage) {
3137         case MYFILE_PHONE:
3138                 labelStorage = GET_SYS_STR(MF_LABEL_PHONE);
3139                 break;
3140         case MYFILE_MMC:
3141                 labelStorage = GET_SYS_STR(MF_LABEL_MMC);
3142                 break;
3143         default:
3144                 break;
3145         }
3146         /*1.2.1 check if mmc is editstar navi */
3147         pNaviBarStorageView = ap->mf_MainWindow.pNaviBar;
3148
3149         mf_debug("before remove is [%d]", ap->mf_Status.iStorageState);
3150         ap->mf_Status.iStorageState = (ap->mf_Status.iStorageState ^ optStorage);
3151         mf_debug("after remove is [%d]", ap->mf_Status.iStorageState);
3152
3153         /*3 factors; */
3154         /*
3155          **     1.      status                          ap->mf_Status.more
3156          **     2.      is storage in Use       ap->mf_Status.path
3157          **     3.      is source path in storage in inter-storage operation    flagEditStartView
3158          */
3159
3160         if (ap->mf_Status.view_type == mf_view_root) {
3161                 if(mf_fm_svc_wrapper_get_location(ap->mf_Status.path->str) != optStorage) {
3162                         switch (ap->mf_Status.more) {
3163                         case MORE_DEFAULT:
3164                                 mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3165                                 __mf_callback_mmc_remove_view_operation(ap, optStorage);
3166                                 break;
3167                         case MORE_INTERNAL_COPY_MOVE:
3168                         case MORE_INTERNAL_COPY:
3169                         case MORE_INTERNAL_MOVE:
3170                                 bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3171                                 if (bEditStartFlag == TRUE) {
3172                                         pNaviToShowStruct = mf_navi_bar_recover_list(ap);
3173                                         mf_navi_bar_refresh_recovered_view(ap, pNaviToShowStruct);
3174                                 } else {
3175                                         __mf_callback_mmc_remove_view_operation(ap, optStorage);
3176                                 }
3177                                 break;
3178                         default:
3179                                 break;
3180                         }
3181                 }else {
3182                         switch (ap->mf_Status.more) {
3183                         case MORE_DEFAULT:
3184                                 ap->mf_Status.more = MORE_DEFAULT;
3185                                 mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3186                                 __mf_callback_mmc_remove_view_operation(ap, optStorage);
3187                                 break;
3188                         case MORE_INTERNAL_COPY_MOVE:
3189                         case MORE_INTERNAL_COPY:
3190                         case MORE_INTERNAL_MOVE:
3191                                 bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3192                                 if (bEditStartFlag == TRUE) {
3193                                         mf_navi_bar_recover_list(ap);
3194                                 }
3195
3196                                 pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3197 #ifdef MYFILE_SPLIT_VIEW
3198
3199                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3200                                         if (optStorage == MYFILE_MMC) {
3201                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3202                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3203                                         }
3204                                 }
3205 #endif
3206
3207                                 mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3208                                 break;
3209                         default:
3210                                 break;
3211                         }
3212                 }
3213         } else if (ap->mf_Status.view_type == mf_view_root_category) {
3214                 switch (ap->mf_Status.more) {
3215                 case MORE_DEFAULT:
3216                 case MORE_EDIT:
3217                 case MORE_RENAME:
3218                         mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3219                         __mf_callback_mmc_remove_category_view_items(ap, optStorage);
3220                         break;
3221                 default:
3222                         break;
3223                 }
3224         } else if(mf_fm_svc_wrapper_get_location(ap->mf_Status.path->str) != optStorage) {
3225                 switch (ap->mf_Status.more) {
3226                 case MORE_DEFAULT:
3227                 case MORE_EDIT:
3228                 case MORE_IDLE_DELETE:
3229                 case MORE_DELETE:
3230                 case MORE_RENAME:
3231                         /*      not a inter-storage operation */
3232                         mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3233                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3234 #ifdef MYFILE_SPLIT_VIEW
3235                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3236                                         if (optStorage == MYFILE_MMC) {
3237                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3238                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3239                                         }
3240                                 }
3241 #endif
3242
3243                         } else {
3244 #ifdef MYFILE_SPLIT_VIEW
3245                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3246                                         if (optStorage == MYFILE_MMC) {
3247                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3248                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3249                                         }
3250                                 }
3251 #endif
3252                         }
3253
3254                         if (ap->mf_Status.more == MORE_RENAME) {
3255                                 entry = ap->mf_MainWindow.pEntry;
3256                                 if (entry != NULL) {
3257                                         elm_object_focus_set(entry, EINA_TRUE);
3258                                 }
3259                         }
3260                         break;
3261                 case MORE_SEARCH:
3262                 case MORE_THUMBNAIL_RENAME:
3263                         mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3264                         break;
3265                 case MORE_CREATE_FOLDER:
3266                         if (ap->mf_Status.preMore == MORE_DEFAULT) {
3267                                 mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3268                                 break;
3269                         } else if (ap->mf_Status.preMore == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.preMore == MORE_INTERNAL_COPY
3270                                    || ap->mf_Status.preMore == MORE_INTERNAL_MOVE) {
3271                                 bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3272                                 if (bEditStartFlag == TRUE) {
3273                                         ap->mf_Status.more = MORE_DEFAULT;
3274                                         pNaviToShowStruct = mf_navi_bar_recover_list(ap);
3275                                         mf_navi_bar_refresh_recovered_view(ap, pNaviToShowStruct);
3276                                 }
3277                         }
3278                         if (bEditStartFlag == TRUE) {
3279 #ifdef MYFILE_SPLIT_VIEW
3280                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3281                                         if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
3282                                                 mf_navi_bar_reset_panes_main(ap);
3283                                         }
3284                                 }
3285 #endif
3286                         }
3287                         break;
3288                 case MORE_INTERNAL_COPY:
3289                 case MORE_INTERNAL_MOVE:
3290                 case MORE_INTERNAL_COPY_MOVE:
3291                         bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3292                         if (bEditStartFlag == TRUE) {
3293                                 pNaviToShowStruct = mf_navi_bar_recover_list(ap);
3294                                 mf_navi_bar_refresh_recovered_view(ap, pNaviToShowStruct);
3295                         }
3296
3297                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3298 #ifdef MYFILE_SPLIT_VIEW
3299                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3300                                         if (optStorage == MYFILE_MMC) {
3301                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3302                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3303                                         }
3304                                 }
3305 #endif
3306
3307                         } else {
3308 #ifdef MYFILE_SPLIT_VIEW
3309                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3310                                         if (optStorage == MYFILE_MMC) {
3311                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3312                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3313                                         }
3314                                 }
3315 #endif
3316                         }
3317                         break;
3318
3319                 case MORE_DATA_COPYING:
3320                 case MORE_DATA_MOVING:
3321                         bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3322                         if (bEditStartFlag == TRUE) {
3323                                 ap->mf_Status.flagStorageRemoved = EINA_TRUE;
3324
3325                                 ap->mf_MainWindow.pMmcRemovedPopup = mf_popup_create_popup(ap, POPMODE_TEXT_NOT_DISABLED, NULL,
3326                                                                                            "Mmc removed...", NULL, NULL, NULL, NULL, NULL);
3327                         } else {
3328                                 ap->mf_Status.flagStorageRemoved = EINA_FALSE;
3329                         }
3330
3331                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3332 #ifdef MYFILE_SPLIT_VIEW
3333                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3334                                         if (optStorage == MYFILE_MMC) {
3335                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3336                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3337                                         }
3338                                 }
3339 #endif
3340
3341                         } else {
3342 #ifdef MYFILE_SPLIT_VIEW
3343                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3344                                         if (optStorage == MYFILE_MMC) {
3345                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3346                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3347                                         }
3348                                 }
3349 #endif
3350                         }
3351
3352                         break;
3353                 default:
3354                         break;
3355                 }
3356         } else {
3357                 switch (ap->mf_Status.more) {
3358                 case MORE_DEFAULT:
3359                         ap->mf_Status.more = MORE_DEFAULT;
3360                         mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3361                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3362                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3363 #ifdef MYFILE_SPLIT_VIEW
3364                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3365                                         if (optStorage == MYFILE_MMC) {
3366                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3367                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3368                                         }
3369                                 }
3370 #endif
3371
3372                         } else {
3373 #ifdef MYFILE_SPLIT_VIEW
3374                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3375                                         if (optStorage == MYFILE_MMC) {
3376                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3377                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3378                                         }
3379                                 }
3380 #endif
3381                         }
3382                         /*set status path && refresh the screen */
3383                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3384                         break;
3385                 case MORE_SEARCH:
3386                 case MORE_THUMBNAIL_RENAME:
3387                         if (ap->mf_FileOperation.search_IME_hide_timer != NULL) {
3388                                 ecore_timer_del(ap->mf_FileOperation.search_IME_hide_timer);
3389                                 ap->mf_FileOperation.search_IME_hide_timer = NULL;
3390                         }
3391                         ap->mf_Status.more = MORE_DEFAULT;
3392                         ap->mf_Status.preMore = MORE_DEFAULT;
3393                         mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3394
3395 #ifdef MYFILE_SPLIT_VIEW
3396                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3397                                 if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
3398                                         mf_navi_bar_reset_panes_main(ap);
3399                                 }
3400                         }
3401 #endif
3402                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3403                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3404
3405                         break;
3406                 case MORE_EDIT:
3407                         bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3408                         if (bEditStartFlag == TRUE) {
3409                                 mf_navi_bar_recover_list(ap);
3410                         }
3411
3412                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3413                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3414 #ifdef MYFILE_SPLIT_VIEW
3415                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3416                                         if (optStorage == MYFILE_MMC) {
3417                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3418                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3419                                         }
3420                                 }
3421 #endif
3422
3423                         } else {
3424 #ifdef MYFILE_SPLIT_VIEW
3425                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3426                                         if (optStorage == MYFILE_MMC) {
3427                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3428                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3429                                         }
3430                                 }
3431 #endif
3432                         }
3433                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3434                         break;
3435                 case MORE_IDLE_DELETE:
3436
3437                         ap->mf_MainWindow.pMmcRemovedPopup = mf_popup_create_popup(ap, POPMODE_TEXT_NOT_DISABLED, NULL,
3438                                                                                    "Mmc removed...", NULL, NULL, NULL, NULL, NULL);
3439                         /*ToDo: check whether get the error before this; */
3440                         if (ap->mf_FileOperation.pCancel) {
3441                                 mf_cancel_do_cancel(ap->mf_FileOperation.pCancel);
3442                         }
3443
3444                         mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3445
3446                         ap->mf_Status.flagStorageRemoved = EINA_TRUE;
3447
3448                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3449                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3450 #ifdef MYFILE_SPLIT_VIEW
3451                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3452                                         if (optStorage == MYFILE_MMC) {
3453                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3454                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3455                                         }
3456                                 }
3457 #endif
3458
3459                         } else {
3460 #ifdef MYFILE_SPLIT_VIEW
3461                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3462                                         if (optStorage == MYFILE_MMC) {
3463                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3464                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3465                                         }
3466                                 }
3467 #endif
3468                         }
3469                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3470                         break;
3471                 case MORE_RENAME:
3472                         if (ap->mf_Status.preMore == MORE_DEFAULT) {
3473                                 ap->mf_Status.more = MORE_DEFAULT;
3474                                 mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3475                         } else if (ap->mf_Status.preMore == MORE_EDIT) {
3476                                 mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3477                                 ap->mf_Status.more = MORE_DEFAULT;
3478                                 mf_navi_bar_recover_list(ap);
3479                         }
3480
3481                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3482                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3483
3484                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3485 #ifdef MYFILE_SPLIT_VIEW
3486                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3487                                         if (optStorage == MYFILE_MMC) {
3488                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3489                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3490                                         }
3491                                 }
3492 #endif
3493
3494                         } else {
3495 #ifdef MYFILE_SPLIT_VIEW
3496                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3497                                         if (optStorage == MYFILE_MMC) {
3498                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3499                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3500                                         }
3501                                 }
3502 #endif
3503                         }
3504                         break;
3505                 case MORE_CREATE_FOLDER:
3506                         if (ap->mf_MainWindow.pEditField != NULL) {
3507                                 evas_object_hide(ap->mf_MainWindow.pEditField);
3508                         }
3509                         if (ap->mf_Status.preMore == MORE_DEFAULT) {
3510                                 ap->mf_Status.more = MORE_DEFAULT;
3511                                 mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3512                         } else if (ap->mf_Status.preMore == MORE_INTERNAL_COPY_MOVE || ap->mf_Status.preMore == MORE_INTERNAL_COPY
3513                                    || ap->mf_Status.preMore == MORE_INTERNAL_MOVE) {
3514                                 bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3515                                 if (bEditStartFlag == TRUE) {
3516                                         ap->mf_Status.more = MORE_DEFAULT;
3517                                         pNaviToShowStruct = mf_navi_bar_recover_list(ap);
3518                                         mf_navi_bar_refresh_recovered_view(ap, pNaviToShowStruct);
3519                                 } else {
3520                                         ap->mf_Status.more = ap->mf_Status.preMore;
3521                                 }
3522
3523                         }
3524
3525                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3526                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3527 #ifdef MYFILE_SPLIT_VIEW
3528                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3529                                 if (ap->mf_Status.view_type != mf_view_root_category && ap->mf_Status.view_type != mf_view_root) {
3530                                         mf_navi_bar_reset_panes_main(ap);
3531                                 }
3532                         }
3533 #endif
3534
3535                         break;
3536                 case MORE_INTERNAL_COPY:
3537                 case MORE_INTERNAL_MOVE:
3538                 case MORE_INTERNAL_COPY_MOVE:
3539                         bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3540                         if (bEditStartFlag == TRUE) {
3541                                 mf_navi_bar_recover_list(ap);
3542                         }
3543
3544                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3545
3546                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3547 #ifdef MYFILE_SPLIT_VIEW
3548                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3549                                         if (optStorage == MYFILE_MMC) {
3550                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3551                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3552                                         }
3553                                 }
3554 #endif
3555
3556                         } else {
3557 #ifdef MYFILE_SPLIT_VIEW
3558                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3559                                         if (optStorage == MYFILE_MMC) {
3560                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3561                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3562                                         }
3563                                 }
3564 #endif
3565                         }
3566                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3567                         break;
3568
3569                 case MORE_DATA_COPYING:
3570                 case MORE_DATA_MOVING:
3571                         ap->mf_MainWindow.pMmcRemovedPopup = mf_popup_create_popup(ap, POPMODE_TEXT_NOT_DISABLED, NULL,
3572                                                                                    "Mmc removed...", NULL, NULL, NULL, NULL, NULL);
3573                         bEditStartFlag = mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3574                         if (bEditStartFlag == TRUE) {
3575                                 ap->mf_Status.flagStorageRemoved = EINA_TRUE;
3576                         } else {
3577                                 ap->mf_Status.flagStorageRemoved = EINA_FALSE;
3578                         }
3579
3580                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3581                         /*reset the path for the navigation bar to show*/
3582                         if (ap->mf_Status.path != NULL) {
3583                                 g_string_free(ap->mf_Status.path, TRUE);
3584                                 ap->mf_Status.path = NULL;
3585                         }
3586                         ap->mf_Status.path = g_string_new(pNaviInUseStruct->pCurrentPath);
3587
3588                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3589                         /*check navigation bar count to decide the main layout content*/
3590                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3591 #ifdef MYFILE_SPLIT_VIEW
3592                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3593                                         if (optStorage == MYFILE_MMC) {
3594                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3595                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3596                                         }
3597                                 }
3598 #endif
3599
3600                         } else {
3601 #ifdef MYFILE_SPLIT_VIEW
3602                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3603                                         if (optStorage == MYFILE_MMC) {
3604                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3605                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3606                                         }
3607                                 }
3608 #endif
3609                         }
3610                         break;
3611                 case MORE_DELETE:
3612                         ap->mf_MainWindow.pMmcRemovedPopup = mf_popup_create_popup(ap, POPMODE_TEXT_NOT_DISABLED, NULL,
3613                                                                                    "Mmc removed...", NULL, NULL, NULL, NULL, NULL);
3614                         if (ap->mf_FileOperation.pCancel) {
3615                                 mf_cancel_do_cancel(ap->mf_FileOperation.pCancel);
3616                         }
3617                         mf_navi_bar_remove_list_item_by_label(ap, labelStorage);
3618                         pNaviInUseStruct = mf_navi_bar_get_in_use(ap);
3619
3620                         if (ap->mf_Status.iStorageState == MYFILE_PHONE) {
3621 #ifdef MYFILE_SPLIT_VIEW
3622                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3623                                         if (optStorage == MYFILE_MMC) {
3624                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3625                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3626                                         }
3627                                 }
3628 #endif
3629
3630                         } else {
3631 #ifdef MYFILE_SPLIT_VIEW
3632                                 if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
3633                                         if (optStorage == MYFILE_MMC) {
3634                                                 elm_object_item_del(ap->mf_MainWindow.sSplitData.mmc_item);
3635                                                 ap->mf_MainWindow.sSplitData.mmc_item = NULL;
3636                                         }
3637                                 }
3638 #endif
3639                         }
3640                         mf_navi_bar_refresh_recovered_view(ap, pNaviInUseStruct);
3641                         break;
3642                 default:
3643                         break;
3644                 }
3645
3646         }
3647         if (ap->mf_MainWindow.pMmcRemovedPopup) {
3648                 mf_debug();
3649                 evas_object_del(ap->mf_MainWindow.pMmcRemovedPopup);
3650                 ap->mf_MainWindow.pMmcRemovedPopup = NULL;
3651         }
3652         mf_navi_bar_title_set(ap);
3653
3654 }
3655 static void __mf_callback_storage_changed_cb(keynode_t *key, void *data)
3656 {
3657         struct appdata *ap = (struct appdata *)data;
3658         mf_retm_if(ap == NULL, "appdata is NULL");
3659         mf_retm_if(ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL, "mf_Status.path is NULL");
3660         int optStorage = MYFILE_NONE;
3661
3662         if (VCONF_TYPE_INT == vconf_keynode_get_type(key)
3663             && VCONFKEY_SYSMAN_MMC_MOUNTED == vconf_keynode_get_int(key)) {
3664                 if (!(ap->mf_Status.iStorageState & MYFILE_MMC)) {
3665                         __mf_callback_mmc_connected(ap);
3666                 }
3667                 return;
3668         }
3669
3670         if (VCONFKEY_SYSMAN_MMC_REMOVED == vconf_keynode_get_int(key)
3671             || VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED == vconf_keynode_get_int(key)) {
3672                 mf_debug("mmc removed");
3673                 optStorage = MYFILE_MMC;
3674                 ap->mf_Status.flagStorageRemoved = EINA_TRUE;
3675         }
3676
3677         if (optStorage == MYFILE_NONE) {
3678                 mf_debug("get removed storage failed\n");
3679                 return;
3680         }
3681         /*here we handle the remove action */
3682         if (ap->mf_Status.iStorageState & optStorage) {
3683                 __mf_callback_mmc_removed(ap, optStorage);
3684         }
3685         return;
3686 }
3687
3688
3689 int mf_callback_set_mmc_state_cb(void *data)
3690 {
3691         struct appdata *ap = (struct appdata *)data;
3692         int mmc_state = 0;
3693         mf_retvm_if(ap == NULL, -1, "appdata is NULL");
3694
3695         mf_util_is_mmc_on(&mmc_state);
3696         return vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, __mf_callback_storage_changed_cb, ap);
3697 }
3698 /******         end of Memory card connection/removal handler   ******/
3699
3700 /******         USB otg connection/removal handler              ******/
3701 #ifdef MYFILE_USB_OTG
3702 static void __mf_callback_otg_removal_cb(keynode_t *key, void *data)
3703 {
3704         struct appdata *ap = (struct appdata *)data;
3705         mf_retm_if(ap == NULL, "appdata is NULL");
3706         mf_retm_if(ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL, "mf_Status.path is NULL");
3707
3708         myfileNaviBar *pNaviStorageStruct = NULL;
3709         Evas_Object *pNaviBarStorageView = NULL;
3710         bool bAllRemovedFlag = FALSE;   /*all otg devices are removed*/
3711         /* first generated the removed node list */
3712         mf_otg_generate_removed_list(ap);
3713         int count_original = eina_list_count(ap->mf_FileOperation.otg_dev_list);
3714         int count_removed = eina_list_count(ap->mf_FileOperation.otg_dev_removed_list);
3715         if(count_original > count_removed)
3716                 bAllRemovedFlag = FALSE;
3717         else
3718                 bAllRemovedFlag = TRUE;
3719         /*1.2.1 check if otg is editstar navi */
3720         pNaviStorageStruct = mf_navi_bar_get_struct_by_label(ap, GET_STR(MF_LABEL_OTG));
3721         pNaviBarStorageView = ap->mf_MainWindow.pNaviBar;
3722
3723         /*3 factors; */
3724         /*
3725          **     1.      status                          ap->mf_Status.more
3726          **     2.      is storage in Use       ap->mf_Status.path
3727          **     3.      is source path in storage in inter-storage operation    flagEditStartView
3728          */
3729
3730         if (bAllRemovedFlag == TRUE) {  /*1. otg storage all removed*/
3731                                         /*we should check if tab bar need to be removed */
3732                 switch (ap->mf_Status.more) {
3733                 case MORE_DEFAULT:
3734                         mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_NOR_POPUP_DEL);
3735                         break;
3736                 case MORE_SEARCH:
3737                         if (pNaviStorageStruct && pNaviStorageStruct->naviFlagInUse == TRUE) {
3738                                 if (ap->mf_FileOperation.sync_pipe != NULL) {
3739                                         ecore_pipe_del(ap->mf_FileOperation.sync_pipe);
3740                                         ap->mf_FileOperation.sync_pipe = NULL;
3741                                 }
3742
3743                                 if (ap->mf_FileOperation.search_IME_hide_timer != NULL) {
3744                                         ecore_timer_del(ap->mf_FileOperation.search_IME_hide_timer);
3745                                         ap->mf_FileOperation.search_IME_hide_timer = NULL;
3746                                 }
3747
3748                                 if (ap->mf_Status.search_handler > 0) {
3749                                         mf_search_stop(ap->mf_Status.search_handler);
3750                                 }
3751
3752                                 if (ap->mf_Status.search_handler > 0) {
3753                                         mf_search_finalize(&ap->mf_Status.search_handler);
3754                                 }
3755
3756                         }
3757                         mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_NOR_POPUP_DEL);
3758                         break;
3759                 case MORE_EDIT:
3760                         mf_debug();
3761                         if (pNaviStorageStruct && pNaviStorageStruct->naviFlagInUse == TRUE)
3762                                 mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_TABBAR_ENABLE | MF_OTG_OPT_THEME_RESET | MF_OTG_OPT_NOR_POPUP_DEL);
3763                         else
3764                                 mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_THEME_RESET | MF_OTG_OPT_NOR_POPUP_DEL);
3765                         break;
3766                 case MORE_IDLE_DELETE:
3767                 case MORE_DELETE:
3768                         mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_NONE);
3769                         break;
3770                 case MORE_RENAME:
3771                 case MORE_CREATE_FOLDER:
3772                         if (pNaviStorageStruct && (pNaviStorageStruct->naviFlagInUse == TRUE || pNaviStorageStruct->naviFlagEditStart == TRUE))
3773                                 mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_TABBAR_ENABLE | MF_OTG_OPT_NOR_POPUP_DEL);
3774                         else
3775                                 mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_NONE);
3776                         break;
3777                 case MORE_INTERNAL_COPY:
3778                 case MORE_INTERNAL_MOVE:
3779                 case MORE_INTERNAL_COPY_MOVE:
3780                         mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_NONE);
3781                         break;
3782                 case MORE_DATA_COPYING:
3783                 case MORE_DATA_MOVING:
3784                         mf_otg_dev_all_removed_update(ap, MF_OTG_OPT_REQ_POPUP_DEL);
3785                         break;
3786                 default:
3787                         break;
3788                 }
3789         } else {        /*otg storages part removed*/
3790                         /*we don't need to check tab bar status*/
3791                 mf_debug("not all removed");
3792                 switch (ap->mf_Status.more) {
3793                 case MORE_DEFAULT:
3794                         mf_otg_dev_removed_update(ap, MF_OTG_OPT_NOR_POPUP_DEL);
3795                         break;
3796                 case MORE_SEARCH:
3797                         mf_otg_dev_removed_update(ap, MF_OTG_OPT_NOR_POPUP_DEL);
3798                         break;
3799                 case MORE_EDIT:
3800                         if (pNaviStorageStruct && pNaviStorageStruct->naviFlagInUse == TRUE)
3801                                 mf_otg_dev_removed_update(ap, MF_OTG_OPT_TABBAR_ENABLE | MF_OTG_OPT_THEME_RESET | MF_OTG_OPT_NOR_POPUP_DEL);
3802                         else
3803                                 mf_otg_dev_removed_update(ap, MF_OTG_OPT_THEME_RESET | MF_OTG_OPT_NOR_POPUP_DEL);
3804                         break;
3805                 case MORE_IDLE_DELETE:
3806                 case MORE_DELETE:
3807                         mf_otg_dev_removed_update(ap, MF_OTG_OPT_NONE);
3808                         break;
3809                 case MORE_RENAME:
3810                 case MORE_CREATE_FOLDER:
3811                         if (pNaviStorageStruct && (pNaviStorageStruct->naviFlagInUse == TRUE || pNaviStorageStruct->naviFlagEditStart == TRUE))
3812                                 mf_otg_dev_removed_update(ap, MF_OTG_OPT_TABBAR_ENABLE | MF_OTG_OPT_NOR_POPUP_DEL);
3813                         else
3814                                 mf_otg_dev_removed_update(ap, MF_OTG_OPT_NONE);
3815                         break;
3816                 case MORE_INTERNAL_COPY:
3817                 case MORE_INTERNAL_MOVE:
3818                 case MORE_INTERNAL_COPY_MOVE:
3819                         mf_otg_dev_removed_update(ap, MF_OTG_OPT_NONE);
3820                         break;
3821                 case MORE_DATA_COPYING:
3822                 case MORE_DATA_MOVING:
3823                         mf_otg_dev_removed_update(ap, MF_OTG_OPT_REQ_POPUP_DEL);
3824                         break;
3825                 default:
3826                         break;
3827                 }
3828         }
3829
3830         mf_debug("before remove is [%d]", ap->mf_Status.iStorageState);
3831         if(bAllRemovedFlag == TRUE)
3832                 ap->mf_Status.iStorageState = (ap->mf_Status.iStorageState ^ MYFILE_OTG);
3833         mf_debug("after remove is [%d]", ap->mf_Status.iStorageState);
3834 }
3835
3836
3837 static void __mf_callback_otg_connected_cb(keynode_t *key, void *data)
3838 {
3839         struct appdata *ap = (struct appdata *)data;
3840         mf_retm_if(ap == NULL, "appdata is NULL");
3841         mf_retm_if(ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL, "mf_Status.path is NULL");
3842         Evas_Object *entry = NULL;
3843
3844         /* otg-dev-list update */
3845         mf_debug("before update: [%d]", eina_list_count(ap->mf_FileOperation.otg_dev_list));
3846         mf_otg_list_update(ap, true);
3847         mf_debug("after update: [%d]", eina_list_count(ap->mf_FileOperation.otg_dev_list));
3848         /* we have 2 cases:
3849          * 1. otg tab already exists -- update the genlist
3850          * 2. otg tab does not exist -- add tab
3851         */
3852         if (ap->mf_Status.iStorageState & MYFILE_OTG) {
3853                 mf_debug("path is %s", ap->mf_Status.path->str);
3854                 if (g_strcmp0(ap->mf_Status.path->str, OTG_FOLDER) == 0) {
3855                         mf_debug();
3856                         mf_util_ex_disk_list_update(ap);
3857                         mf_debug();
3858                 }
3859         } else {
3860                 mf_debug();
3861                 ap->mf_Status.iStorageState |= MYFILE_OTG;
3862                 mf_util_action_storage_insert(ap, GET_STR(MF_LABEL_OTG));
3863                 mf_debug();
3864         }
3865
3866         mf_debug();
3867         if (ap->mf_Status.more == MORE_RENAME) {
3868                 entry = ap->mf_MainWindow.pEntry;
3869                 if (entry != NULL) {
3870                         elm_object_focus_set(entry, EINA_TRUE);
3871                 }
3872         }
3873         return;
3874 }
3875
3876 void mf_callback_set_otg_state_cb(void *data)
3877 {
3878         struct appdata *ap = (struct appdata *)data;
3879         mf_retm_if(ap == NULL, "appdata is NULL");
3880         mf_retm_if(ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL, "mf_Status.path is NULL");
3881
3882         mf_debug("path is %s", ap->mf_Status.path->str);
3883
3884         if (ap->mf_FileOperation.otg_dev_list != NULL) {
3885                 mf_otg_list_clean(ap, MF_OTG_LIST_DEV);
3886         }
3887
3888         mf_otg_init(ap);
3889         vconf_notify_key_changed(VCONFKEY_SYSMAN_ADDED_USB_STORAGE, __mf_callback_otg_connected_cb, ap);
3890         vconf_notify_key_changed(VCONFKEY_SYSMAN_REMOVED_USB_STORAGE, __mf_callback_otg_removal_cb, ap);
3891 }
3892 #endif
3893 /******         end of USB otg connection/removal handler       ******/
3894
3895
3896 static GString *__mf_callback_dir_pipe_get_parent(GString *path)
3897 {
3898
3899         mf_retvm_if(path == NULL, NULL, "path is NULL");
3900         mf_retvm_if(path->str == NULL, NULL, "path->str is NULL");
3901
3902         if (ecore_file_exists(path->str)) {
3903                 return path;
3904         } else if (mf_fm_svc_wrapper_is_root_path(path->str)) {
3905                 return path;
3906         } else {
3907                 GString *parent = mf_fm_svc_wrapper_get_file_parent_path(path);
3908                 SAFE_FREE_GSTRING(path);
3909                 __mf_callback_dir_pipe_get_parent(parent);
3910         }
3911         return path;
3912 }
3913 static void __mf_callback_dir_pipe_cb(void *data, void *buffer, unsigned int nbyte)
3914 {
3915         MF_TRACE_BEGIN;
3916         struct appdata *ap = (struct appdata *)data;
3917         mf_retm_if(ap == NULL, "appdata is NULL");
3918
3919         if (ap->mf_Status.more != MORE_DEFAULT)
3920                         return;
3921         if (ap->mf_Status.view_type == mf_view_root || ap->mf_Status.view_type == mf_view_root_category) {
3922                 return;
3923         }
3924         if (g_strcmp0(ap->mf_Status.monitor_path, ap->mf_Status.path->str)) {
3925                 return;
3926         }
3927         if (buffer) {
3928                 mf_dir_event_t *msg = (mf_dir_event_t *) buffer;
3929                 mf_debug("event : %d, name : %s", msg->event, msg->name);
3930
3931                 int iIsNoContent = 0;
3932                 Evas_Object *newContent = NULL;
3933
3934                 iIsNoContent = ap->mf_Status.flagNoContent;
3935                 mfItemData_s *itemData = NULL;
3936                 Elm_Object_Item *it = NULL;
3937                 GString *parent = NULL;
3938                 GString *current = NULL;
3939                 Evas_Object *parent_obj = NULL;
3940                 char *path = NULL;
3941                 int count = 0;
3942
3943                 switch (msg->event) {
3944                 case MF_INOTI_CREATE:
3945                 case MF_INOTI_MOVE_IN:
3946                         if(msg->name) {
3947                                 path = g_strconcat(ap->mf_Status.path->str, "/", msg->name, NULL);
3948                                 int file_type = 0;
3949                                 if (mf_file_attr_is_dir(path)) {
3950                                         file_type = FILE_TYPE_DIR;
3951                                 } else {
3952                                         file_type = FILE_TYPE_FILE;
3953                                 }
3954                                 fsNodeInfo *pNode = mf_util_generate_pnode(path, file_type);
3955                                 if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_LIST || ap->mf_Status.flagViewType == MF_VIEW_SYTLE_LIST_DETAIL) {
3956                                         if (ap->mf_MainWindow.pNaviGenlist == NULL) {
3957                                                 ap->mf_MainWindow.pNaviGenlist = mf_widget_create_genlist(ap->mf_MainWindow.pNaviBar);
3958                                                 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,right", mf_genlist_gl_mode_sweep_set, ap);
3959                                                 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,left", mf_genlist_gl_mode_sweep_unset, ap);
3960                                                 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,up", mf_genlist_gl_mode_cancel, ap);
3961                                                 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,down", mf_genlist_gl_mode_cancel, ap);
3962                                                 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "selected", mf_genlist_gl_selected, ap);
3963
3964                                                 evas_object_del(elm_object_part_content_unset(ap->mf_MainWindow.pNaviLayout, "content"));
3965                                                 elm_object_part_content_set(ap->mf_MainWindow.pNaviLayout, "content", ap->mf_MainWindow.pNaviGenlist);
3966                                         }
3967                                         parent_obj = ap->mf_MainWindow.pNaviGenlist;
3968                                 } else {
3969                                         if (ap->mf_MainWindow.pNaviGengrid == NULL) {
3970                                                 ap->mf_MainWindow.pNaviGengrid = mf_gengrid_create_grid(ap->mf_MainWindow.pNaviBar);
3971                                                 evas_object_del(elm_object_part_content_unset(ap->mf_MainWindow.pNaviLayout, "content"));
3972                                                 elm_object_part_content_set(ap->mf_MainWindow.pNaviLayout, "content", ap->mf_MainWindow.pNaviGengrid);
3973                                         }
3974                                         parent_obj = ap->mf_MainWindow.pNaviGengrid;
3975                                 }
3976                                 mf_widget_item_append(parent_obj, pNode, ap);
3977
3978                                 if (pNode != NULL) {
3979                                         SAFE_FREE_CHAR(pNode->path);
3980                                         SAFE_FREE_CHAR(pNode->name);
3981                                         SAFE_FREE_CHAR(pNode->ext);
3982                                         free(pNode);
3983                                         pNode = NULL;
3984                                 }
3985                         }
3986                         /*1 TODO:  add new item to list */
3987                         if (ap->mf_Status.more == MORE_DEFAULT && iIsNoContent) {
3988                                 mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, CTRL_DISABLE_NOCONTENT_VIEW, false);
3989                                 //mf_ctrl_bar_item_set_disable(ap->mf_MainWindow.pNaviCtrlBar, CTRL_DISABLE_NOCONTENT_VIEW, false);
3990                         }
3991                         break;
3992                 case MF_INOTI_DELETE:
3993                 case MF_INOTI_MOVE_OUT:
3994                         path = g_strconcat(ap->mf_Status.path->str, "/", msg->name, NULL);
3995                         if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_LIST || ap->mf_Status.flagViewType == MF_VIEW_SYTLE_LIST_DETAIL) {
3996                                 it = elm_genlist_first_item_get(ap->mf_MainWindow.pNaviGenlist);
3997                                 while (it) {
3998                                         itemData = elm_object_item_data_get(it);
3999                                         if (itemData->m_ItemName == NULL || itemData->m_ItemName->str == NULL) {
4000                                                 mf_debug();
4001                                                 continue;
4002                                         }
4003                                         if (g_strcmp0(path, itemData->m_ItemName->str) == 0) {
4004                                                 elm_object_item_del(it);
4005                                                 break;
4006                                         }
4007
4008                                         it = elm_genlist_item_next_get(it);
4009                                 }
4010                                 count = elm_genlist_items_count(ap->mf_MainWindow.pNaviGenlist);
4011                                 ap->mf_Status.flagNoContent = !count;
4012
4013                         } else {
4014                                 it = elm_gengrid_first_item_get(ap->mf_MainWindow.pNaviGengrid);
4015                                 while (it) {
4016                                         itemData = elm_object_item_data_get(it);
4017                                         if (itemData->m_ItemName == NULL || itemData->m_ItemName->str == NULL) {
4018                                                 continue;
4019                                         }
4020                                         if (g_strcmp0(path, itemData->m_ItemName->str) == 0) {
4021                                                 elm_object_item_del(it);
4022                                                 break;
4023                                         }
4024
4025                                         it = elm_gengrid_item_next_get(it);
4026                                 }
4027                                 count = elm_gengrid_items_count(ap->mf_MainWindow.pNaviGengrid);
4028                                 ap->mf_Status.flagNoContent = !count;
4029
4030                         }
4031                         /*1 TODO:  remove item from list */
4032                         if (ap->mf_Status.more == MORE_DEFAULT && ap->mf_Status.flagNoContent) {
4033                                 mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, CTRL_DISABLE_NOCONTENT_VIEW, true);
4034                         }
4035                         break;
4036                 case MF_INOTI_MODIFY:
4037 #ifdef MYFILE_SPLIT_VIEW
4038                         //todo: optmize the refresh
4039                         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
4040                                 mf_widget_refresh_view(ap);
4041                         }
4042                         else
4043 #endif
4044                         {
4045                                 newContent = mf_navi_bar_content_create(ap);
4046                                 Evas_Object *pConformant = mfNaviBarConformGet(ap);
4047                                 mfNaviBarSetContent(ap, pConformant, newContent);
4048                         }
4049                         /*1 TODO:  update item in list */
4050                         break;
4051                 case MF_INOTI_DELETE_SELF:
4052                 case MF_INOTI_MOVE_SELF:
4053                 {
4054                         current = g_string_new(ap->mf_Status.path->str);
4055                         parent = __mf_callback_dir_pipe_get_parent(current);
4056
4057                         myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
4058
4059                         g_string_free(ap->mf_Status.path, TRUE);
4060                         ap->mf_Status.path = NULL;
4061                         ap->mf_Status.path = parent;
4062 #ifdef MYFILE_USB_OTG
4063                         /* if click items under otg root path, it means some disk take into use*/
4064                         int storage = mf_fm_svc_wrapper_is_root_path(ap->mf_Status.path->str);
4065                         if (storage == MYFILE_OTG) {    /* a usb disk take into use */
4066                                 char *dev_in_use = mf_otg_get_node_in_use(ap);
4067                                 if (dev_in_use != NULL)
4068                                         mf_otg_set_node_using_flag(ap, dev_in_use, FALSE);
4069                         }
4070 #endif
4071                         if (pNavi_s->pCurrentPath != NULL) {
4072                                 free(pNavi_s->pCurrentPath);
4073                                 pNavi_s->pCurrentPath = NULL;
4074                         }
4075                         pNavi_s->pCurrentPath = g_strdup(parent->str);
4076
4077
4078
4079                         mf_widget_refresh_view(ap);
4080                 }
4081                         break;
4082                 default:
4083                         mf_error("Unknown event");
4084                         break;
4085                 }
4086
4087
4088                 if (msg->name)
4089                         free(msg->name);
4090                 SAFE_FREE_CHAR(path);
4091                 mf_inotify_handle_request_handled_send();
4092         }
4093 }
4094
4095 static void __mf_callback_dir_update_cb(mf_inotify_event event, char *name, void *data)
4096 {
4097         struct appdata *ap = (struct appdata *)data;
4098         mf_retm_if(ap == NULL, "appdata is NULL");
4099
4100         mf_debug("event : %d, name : %s", event, name);
4101
4102         mf_dir_event_t buffer;
4103
4104         buffer.event = event;
4105         buffer.name = strdup(name);
4106
4107         ecore_pipe_write(ap->mf_FileOperation.inotify_pipe, &buffer, sizeof(buffer));
4108
4109         return;
4110 }
4111
4112 int mf_callback_add_dir_watch(const char *path, void *data)
4113 {
4114         mf_retvm_if(data == NULL, 0, "data is NULL");
4115
4116         struct appdata *ap = (struct appdata *)data;
4117         SAFE_FREE_CHAR(ap->mf_Status.monitor_path);
4118         ap->mf_Status.monitor_path = g_strdup(path);
4119         return mf_inotify_handle_add_watch(path, __mf_callback_dir_update_cb, data);
4120 }
4121
4122 int mf_callback_remove_dir_watch(void)
4123 {
4124         return mf_inotify_handle_rm_watch();
4125 }
4126
4127 int mf_callback_create_dir_monitor(void *data)
4128 {
4129         struct appdata *ap = (struct appdata *)data;
4130         mf_retvm_if(ap == NULL, -1, "appdata is NULL");
4131
4132         if (ap->mf_FileOperation.inotify_pipe)
4133                 ecore_pipe_del(ap->mf_FileOperation.inotify_pipe);
4134
4135         ap->mf_FileOperation.inotify_pipe = ecore_pipe_add(__mf_callback_dir_pipe_cb, (const void *)ap);
4136
4137         return mf_inotify_handle_init_inotify();
4138 }
4139
4140 void mf_callback_destory_dir_monitor(void *data)
4141 {
4142         struct appdata *ap = (struct appdata *)data;
4143         mf_retm_if(ap == NULL, "appdata is NULL");
4144
4145         if (ap->mf_FileOperation.inotify_pipe) {
4146                 ecore_pipe_del(ap->mf_FileOperation.inotify_pipe);
4147                 ap->mf_FileOperation.inotify_pipe = NULL;
4148         }
4149
4150         mf_inotify_handle_finalize_inotify();
4151
4152         return;
4153 }
4154
4155 void mf_callback_backbutton_clicked_cb(void *data, Evas_Object *obj, void *event_info)
4156 {
4157         mf_retm_if(data == NULL, "data is NULL");
4158         struct appdata *ap = (struct appdata *)data;
4159
4160         if (ap->mf_Status.more == MORE_DEFAULT) {
4161                 if (ap->mf_Status.view_type == mf_view_root) {
4162                         Evas_Object *win = ap->mf_MainWindow.pWindow;
4163                         elm_win_lower(win);
4164                 } else if (ap->mf_Status.view_type == mf_view_root_category) {
4165                         ap->mf_Status.view_type = mf_view_root;
4166                         mf_widget_refresh_view(ap);
4167                 } else {
4168                         mf_callback_upper_click_cb(ap, NULL, NULL);
4169                 }
4170         } else {
4171                 mf_callback_cancel_cb(ap, NULL, NULL);
4172         }
4173 }
4174
4175 void mf_callback_new_folder_changed_cb(void *data, Evas_Object *obj, void *event_info)
4176 {
4177         MF_TRACE_BEGIN;
4178         struct appdata *ap = (struct appdata *)data;
4179         mf_retm_if(ap == NULL, "ap is null");
4180
4181         Eina_Bool entry_empty = elm_entry_is_empty(ap->mf_MainWindow.pEntry);
4182
4183         if (entry_empty) {
4184                 elm_object_signal_emit(ap->mf_MainWindow.pEditField, "elm,state,eraser,hide", "elm");
4185         } else {
4186                 elm_object_signal_emit(ap->mf_MainWindow.pEditField, "elm,state,eraser,show", "elm");
4187         }
4188         MF_TRACE_END;
4189
4190 }
4191 void mf_callback_imf_changed_cb(void *data, Evas_Object *obj, void *event_info)
4192 {
4193         MF_TRACE_BEGIN;
4194         struct appdata *ap = (struct appdata *)data;
4195         mf_retm_if(ap == NULL, "ap is null");
4196
4197         const char *entry_data = NULL;
4198         char *name = NULL;
4199         char new_str[MYFILE_FILE_NAME_LEN_MAX] = { '\0', };
4200
4201         entry_data = elm_entry_entry_get(ap->mf_MainWindow.pEntry);
4202         mf_retm_if(entry_data == NULL, "entry_data is null");
4203         name = elm_entry_markup_to_utf8(entry_data);
4204         mf_retm_if(name == NULL, "name is null");
4205
4206         Eina_Bool entry_empty = elm_entry_is_empty(ap->mf_MainWindow.pEntry);
4207
4208         if (entry_empty) {
4209                 elm_object_signal_emit(ap->mf_MainWindow.pEditField, "elm,state,eraser,hide", "elm");
4210         } else {
4211                 elm_object_signal_emit(ap->mf_MainWindow.pEditField, "elm,state,eraser,show", "elm");
4212         }
4213
4214         if (mf_file_attr_is_valid_name(name) != MYFILE_ERR_NONE) {
4215                 strncpy(new_str, name, MYFILE_FILE_NAME_LEN_MAX - 1);
4216                 if (strlen(name) > 0)
4217                         new_str[strlen(name) - 1] = '\0';
4218                 elm_entry_entry_set(ap->mf_MainWindow.pEntry, new_str);
4219                 elm_entry_cursor_end_set(ap->mf_MainWindow.pEntry);
4220                 elm_object_focus_set(ap->mf_MainWindow.pEntry, EINA_FALSE);
4221
4222                 if (ap->mf_MainWindow.pNormalPopup) {
4223                         SAFE_FREE_OBJ(ap->mf_MainWindow.pNormalPopup);
4224                 }
4225                 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, GET_STR(MF_MSG_RENAME_ILLEGAL_CHAR), NULL, NULL,
4226                                                                        NULL, mf_popup_show_vk_cb, ap);
4227         }
4228         SAFE_FREE_CHAR(name);
4229         MF_TRACE_END;
4230 }
4231
4232
4233 void mf_callback_rename_button_callback(void *data, Evas_Object * obj, void *event_info)
4234 {
4235         MF_TRACE_BEGIN;
4236         mfItemData_s *params = (mfItemData_s *)data;
4237         mf_retm_if(params == NULL, "input data is NULL");
4238
4239         struct appdata *ap = (struct appdata *)params->ap;
4240         mf_retm_if(ap == NULL, "input ap is NULL");
4241
4242         Elm_Object_Item *it = params->item;
4243         mf_retm_if(it == NULL, "input item is NULL");
4244
4245         myfileNaviBar *pNavi_toshow = NULL;
4246         pNavi_toshow = mf_navi_bar_get_in_use(ap);
4247         mf_retm_if(pNavi_toshow == NULL, "get navi in use failed");
4248
4249         if (ap->mf_Status.more == MORE_RENAME) {
4250                 mf_callback_rename_save_cb(ap, NULL, NULL);
4251         }
4252         mf_genlist_sweep_item_recover(ap->mf_MainWindow.pNaviGenlist);
4253
4254         ap->mf_Status.preMore = ap->mf_Status.more;
4255         ap->mf_Status.more = MORE_RENAME;
4256         elm_genlist_item_flip_set(it, EINA_TRUE);
4257         elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_NONE);
4258         ap->mf_FileOperation.rename_item = it;
4259
4260         if (ap->mf_Status.preMore == MORE_DEFAULT) {
4261
4262                 mf_navi_bar_set_upper_item_disable(ap, true);
4263                 mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, CTRL_DISABLE_DEFAULT_ALL, true);
4264                 //mf_ctrl_bar_item_set_disable(ap->mf_MainWindow.pNaviCtrlBar, CTRL_DISABLE_DEFAULT_ALL, TRUE);
4265         } else {
4266                 ap->mf_Status.iCtrlDisableItem = mf_navi_bar_button_get_disable(ap->mf_MainWindow.pNaviItem);
4267                 mf_debug("ap->mf_Status.iCtrlDisableItem is [%d]", ap->mf_Status.iCtrlDisableItem);
4268                 mf_navi_bar_button_set_disable(ap->mf_MainWindow.pNaviItem, CTRL_DISABLE_EDIT_ALL, true);
4269                 //mf_ctrl_bar_item_set_disable(ap->mf_MainWindow.pNaviCtrlBar, CTRL_DISABLE_EDIT_ALL, TRUE);
4270         }
4271
4272
4273         MF_TRACE_END;
4274 }
4275 void mf_callback_detail_ctx_cb(void *data, Evas_Object * obj, void *event_info)
4276 {
4277         mf_retm_if(data == NULL, "data is NULL");
4278         mfItemData_s *itemData = (mfItemData_s *)data;
4279         struct appdata* ap = (struct appdata *)itemData->ap;
4280         mf_retm_if(ap == NULL, "ap is NULL");
4281
4282         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
4283         mf_launch_load_ug(ap, itemData->m_ItemName->str, MF_LOAD_UG_DETAIL, NULL);
4284 }
4285 static void __mf_callback_delete_in_idle(void *data, Evas_Object * obj, void *event_info)
4286 {
4287         struct appdata *ap = (struct appdata *)data;
4288
4289         Evas_Object *btn = (Evas_Object *)obj;
4290         const char *label = elm_object_text_get(btn);
4291
4292         if (g_strcmp0(label, GET_SYS_STR(LABEL_CANCEL)) == 0 ) {
4293                 SAFE_FREE_OBJ(ap->mf_MainWindow.pNormalPopup);
4294                 return;
4295         } else if (g_strcmp0(label, GET_SYS_STR(LABEL_DELETE)) == 0 ) {
4296                 SAFE_FREE_OBJ(ap->mf_MainWindow.pNormalPopup);
4297
4298                 GList *pSourceList = NULL;
4299                 int count = 0;
4300
4301                 mf_util_merge_eina_list_to_glist(ap->mf_FileRecordList.value_saver, &pSourceList);
4302
4303                 if (pSourceList) {
4304                         count = g_list_length(pSourceList);
4305                 } else {
4306                         MF_TRACE_END;
4307                         return;
4308                 }
4309                 mf_callback_init_operation_cancel(ap);
4310                 ap->mf_FileOperation.iTotalCount = count;
4311                 ap->mf_Status.preMore = ap->mf_Status.more;
4312                 ap->mf_Status.more = MORE_IDLE_DELETE;
4313                 ap->mf_FileOperation.pSourceList = pSourceList;
4314                 ap->mf_FileOperation.iOperationSuccessFlag = TRUE;
4315                 mf_delete_items(pSourceList, ap->mf_FileOperation.pCancel, TRUE, ap);
4316                 SAFE_FREE_OBJ(ap->mf_MainWindow.pProgressPopup);
4317                 ap->mf_MainWindow.pProgressPopup = mf_popup_create_pb_popup(ap, GET_SYS_STR(MF_MSG_DELETING), count, mf_callback_progress_bar_cancel_cb, ap);
4318         }
4319 }
4320
4321 void mf_callback_delete_button_cb(void *data, Evas_Object * obj, void *event_info)
4322 {
4323
4324         mfItemData_s *params = (mfItemData_s *) data;
4325         struct appdata *ap = (struct appdata *)params->ap;
4326
4327         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
4328
4329         if (ap->mf_FileRecordList.value_saver != NULL) {
4330                 mf_util_free_eina_list_with_data(&ap->mf_FileRecordList.value_saver, MYFILE_TYPE_GSTRING);
4331                 ap->mf_FileRecordList.value_saver = NULL;
4332         }
4333         ap->mf_FileRecordList.value_saver = eina_list_append(ap->mf_FileRecordList.value_saver, g_string_new(params->m_ItemName->str));
4334         SAFE_FREE_OBJ(ap->mf_MainWindow.pNormalPopup);
4335         ap->mf_FileOperation.idle_delete_item = params->item;
4336         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TITLE_TEXT_TWO_BTN,
4337                                                                NULL,
4338                                                                GET_SYS_STR(MF_BUTTON_LABEL_DEL),
4339                                                                GET_SYS_STR(LABEL_DELETE), GET_SYS_STR(LABEL_CANCEL),
4340                                                                NULL, __mf_callback_delete_in_idle, ap);
4341 }
4342
4343 void mf_callback_view_as_cb(void *data, Evas_Object * obj, void *event_info)
4344 {
4345         MF_TRACE_BEGIN;
4346         mf_retm_if(data == NULL, "data is NULL");
4347
4348         struct appdata *ap = (struct appdata *)data;
4349
4350         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
4351         ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_VIEW_AS_LIST, GET_STR(LABEL_VIEW_AS), NULL, NULL, NULL, NULL, mf_callback_popup_deleted_cb, ap);
4352 }
4353 void mf_callback_view_style_cb(void *data, Evas_Object * obj, void *event_info)
4354 {
4355         MF_TRACE_BEGIN;
4356         mf_retm_if(data == NULL, "data is NULL");
4357
4358         struct appdata *ap = (struct appdata *)data;
4359
4360         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
4361         if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_LIST) {
4362                 ap->mf_Status.flagViewType = MF_VIEW_STYLE_THUMBNAIL;
4363         } else {
4364                 ap->mf_Status.flagViewType = MF_VIEW_STYLE_LIST;
4365         }
4366
4367         mf_util_set_view_style(ap->mf_Status.flagViewType);
4368
4369         if (ap->mf_Status.flagNoContent != EINA_TRUE) {
4370                 mf_widget_refresh_view(ap);
4371         }
4372         MF_TRACE_END;
4373 }
4374
4375 void mf_callback_home_button_pressed_cb(void *data, Evas_Object * obj, void *event_info)
4376 {
4377         MF_TRACE_BEGIN;
4378         mf_retm_if(data == NULL, "data is NULL");
4379
4380         Evas_Object *home_button_ic = (Evas_Object *)data;
4381         elm_image_file_set(home_button_ic, MF_TITLE_ICON_HOME_PRESS, NULL);
4382 }
4383
4384 void mf_callback_home_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info)
4385 {
4386         MF_TRACE_BEGIN;
4387         mf_retm_if(data == NULL, "data is NULL");
4388
4389         Evas_Object *home_button_ic = (Evas_Object *)data;
4390         elm_image_file_set(home_button_ic, MF_TITLE_ICON_HOME, NULL);
4391 }
4392
4393 void mf_callback_select_all_button_pressed_cb(void *data, Evas_Object * obj, void *event_info)
4394 {
4395         MF_TRACE_BEGIN;
4396         mf_retm_if(data == NULL, "data is NULL");
4397
4398         Evas_Object *select_all_button_ic = (Evas_Object *)data;
4399         elm_image_file_set(select_all_button_ic, MF_TITLE_ICON_SELECT_ALL_PRESS, NULL);
4400 }
4401
4402 void mf_callback_select_all_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info)
4403 {
4404         MF_TRACE_BEGIN;
4405         mf_retm_if(data == NULL, "data is NULL");
4406
4407         Evas_Object *select_all_button_ic = (Evas_Object *)data;
4408         elm_image_file_set(select_all_button_ic, MF_TITLE_ICON_SELECT_ALL, NULL);
4409 }
4410
4411 void mf_callback_home_button_cb(void *data, Evas_Object * obj, void *event_info)
4412 {
4413         MF_TRACE_BEGIN;
4414         mf_retm_if(data == NULL, "data is NULL");
4415
4416         struct appdata *ap = (struct appdata *)data;
4417         int storage = MYFILE_PHONE;
4418         myfileNaviBar *pNavi_s = NULL;
4419
4420
4421         pNavi_s = mf_navi_bar_get_in_use(ap);
4422         mf_retm_if(pNavi_s == NULL, "pNavi_s is NULL");
4423
4424         mf_callback_remove_dir_watch();
4425
4426         if (ap->mf_Status.more == MORE_RENAME) {
4427                 mf_callback_destory_rename(ap);
4428         }
4429
4430         ap->mf_Status.view_type = mf_view_root;
4431 #ifdef MYFILE_SPLIT_VIEW
4432
4433         if (ap->mf_Status.rotation_type == MF_ROTATE_LANDSCAPE) {
4434                 mf_navi_bar_set_panes_navi_to_main(ap);
4435
4436         }
4437 #endif
4438         storage = mf_fm_svc_wrapper_get_location(ap->mf_Status.path->str);
4439         switch (storage) {
4440                 case MYFILE_PHONE:
4441                         SAFE_FREE_GSTRING(ap->mf_Status.path);
4442                         ap->mf_Status.path = g_string_new(PHONE_FOLDER);
4443                         break;
4444                 case MYFILE_MMC:
4445                         SAFE_FREE_GSTRING(ap->mf_Status.path);
4446                         ap->mf_Status.path = g_string_new(MEMORY_FOLDER);
4447                         break;
4448                 case MYFILE_OTG:
4449                         SAFE_FREE_GSTRING(ap->mf_Status.path);
4450                         ap->mf_Status.path = g_string_new(OTG_FOLDER);
4451                         break;
4452                 default:
4453                         return;
4454         }
4455 #ifdef MYFILE_USB_OTG
4456         /* if click items under otg root path, it means some disk take into use*/
4457         if (storage == MYFILE_OTG) {    /* a usb disk take into use */
4458                 char *dev_in_use = mf_otg_get_node_in_use(ap);
4459                 if (dev_in_use != NULL)
4460                         mf_otg_set_node_using_flag(ap, dev_in_use, FALSE);
4461         }
4462 #endif
4463         SAFE_FREE_CHAR(pNavi_s->pCurrentPath);
4464         pNavi_s->pCurrentPath = g_strdup(ap->mf_Status.path->str);
4465
4466         if (ap->mf_MainWindow.pNaviItem) {
4467                 mf_navi_bottom_item_del(&ap->mf_MainWindow.pNaviItem);
4468         }
4469         mf_widget_refresh_view(ap);
4470         MF_TRACE_END;
4471 }
4472
4473 void mf_callback_more_button_cb(void *data, Evas_Object * obj, void *event_info)
4474 {
4475         MF_TRACE_BEGIN;
4476         mf_retm_if(data == NULL, "data is NULL");
4477         struct appdata *ap = (struct appdata *)data;
4478         ap->mf_Status.navi_item_selected = MF_NAVI_BTN_MORE;
4479         mf_context_popup_create_more(ap, obj);
4480         return;
4481 }
4482
4483 void mf_callback_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
4484 {
4485         elm_entry_entry_set(data, "");
4486 }
4487
4488 void mf_callback_list_by_button_callback(void *data, Evas_Object * obj, void *event_info)
4489 {
4490         assert(data);
4491         assert(obj);
4492         struct appdata *ap = (struct appdata *)data;
4493
4494         Evas_Object *btn = (Evas_Object *)obj;
4495         const char *label = elm_object_text_get(btn);
4496         int iListBySortType = 0;
4497
4498         if (g_strcmp0(label, GET_STR(MF_LABEL_DESCENDING)) == 0 ) {
4499                 switch(ap->mf_Status.iSelectedSortType) {
4500                         case 0:
4501                                 iListBySortType = MYFILE_SORT_BY_NAME_Z2A;
4502                                 break;
4503                         case 1:
4504                                 iListBySortType = MYFILE_SORT_BY_DATE_R2O;
4505                                 break;
4506
4507                         case 2:
4508                                 iListBySortType = MYFILE_SORT_BY_SIZE_L2S;
4509                                 break;
4510                         case 3:
4511                                 iListBySortType = MYFILE_SORT_BY_TYPE_Z2A;
4512                                 break;
4513                         default:
4514                                 iListBySortType = MYFILE_SORT_BY_DATE_R2O;
4515                                 break;
4516                 }
4517         } else if(g_strcmp0(label, GET_STR(MF_LABEL_ASCENDING)) == 0 ) {
4518                 switch(ap->mf_Status.iSelectedSortType) {
4519                         case 0:
4520                                 iListBySortType = MYFILE_SORT_BY_NAME_A2Z;
4521                                 break;
4522                         case 1:
4523                                 iListBySortType = MYFILE_SORT_BY_DATE_O2R;
4524                                 break;
4525
4526                         case 2:
4527                                 iListBySortType = MYFILE_SORT_BY_SIZE_S2L;
4528                                 break;
4529                         case 3:
4530                                 iListBySortType = MYFILE_SORT_BY_TYPE_A2Z;
4531                                 break;
4532                         default:
4533                                 iListBySortType = MYFILE_SORT_BY_DATE_O2R;
4534                                 break;
4535                 }
4536
4537         }
4538         mf_util_set_sort_type(iListBySortType);
4539         mf_callback_list_by_response_cb(ap);
4540 }
4541
4542 void mf_callback_sbeam_cb(void *user_data)
4543 {
4544         MF_TRACE_BEGIN;
4545         mf_retm_if(user_data == NULL, "user_data is NULL");
4546
4547         struct appdata *ap = (struct appdata *)user_data;
4548
4549         if (ap->mf_FileRecordList.selected_files) {
4550                 mf_util_free_eina_list_with_data(&ap->mf_FileRecordList.selected_files, MYFILE_TYPE_GSTRING);
4551         }
4552         ap->mf_FileRecordList.selected_files = mf_util_get_all_selected(ap);
4553
4554         Eina_List *files = NULL;
4555
4556         if (ap->mf_Status.more == MORE_EDIT) {
4557                 files = mf_util_get_all_selected(ap);
4558         }
4559
4560         mf_sbeam_share_files(ap->mf_MainWindow.pWindow, files);
4561         mf_util_free_eina_list_with_data(&files, MYFILE_TYPE_GSTRING);
4562         files = NULL;
4563 }
4564
4565 void mf_callback_extension_cb(void *data, Evas_Object * obj, void *event_info)
4566 {
4567         MF_TRACE_BEGIN;
4568         mf_retm_if(data == NULL, "user_data is NULL");
4569
4570         struct appdata *ap = (struct appdata *)data;
4571
4572         Evas_Object *playout = ap->mf_MainWindow.pNaviLayout;
4573         mf_retm_if(playout == NULL, "get conformant failed");
4574         Evas_Object *newContent = NULL;
4575         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
4576         const char *label = elm_object_item_text_get(item);
4577         if (g_strcmp0(label, GET_STR(MF_LABEL_SHOW_EXTENSION)) == 0) {
4578                 mf_util_set_extension_state(MF_EXTENSION_SHOW);
4579                 ap->mf_Status.iExtensionState = MF_EXTENSION_SHOW;
4580         } else if (g_strcmp0(label, GET_STR(MF_LABEL_HIDE_EXTENSION)) == 0) {
4581                 mf_util_set_extension_state(MF_EXTENSION_HIDE);
4582                 ap->mf_Status.iExtensionState = MF_EXTENSION_HIDE;
4583         } else {
4584                 SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
4585                 return;
4586         }
4587         SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
4588         if (ap->mf_Status.flagNoContent != EINA_TRUE) {
4589                 newContent = mf_navi_bar_content_create(ap);
4590                 mfNaviBarSetContent(ap, playout, newContent);
4591
4592         }
4593         ap->mf_Status.more = MORE_DEFAULT;
4594 }
4595
4596 /******************************
4597 ** Prototype    : mf_callback_nofity_show_callback
4598 ** Description  :
4599 ** Input        : void *data
4600 **                Evas_Object *obj
4601 **                void *event_info
4602 ** Output       : None
4603 ** Return Value :
4604 ** Calls        :
4605 ** Called By    :
4606 **
4607 **  History        :
4608 **  1.Date         : 2010/12/10
4609 **    Author       : Samsung
4610 **    Modification : Created function
4611 **
4612 ******************************/
4613 void mf_callback_nofity_show_callback(void *data, Evas *e, Evas_Object *obj, void *event_info)
4614 {
4615         struct appdata *ap = (struct appdata *)data;
4616         mf_retm_if(ap == NULL, "ap is NULL");
4617         edje_object_signal_emit(_EDJ(ap->mf_MainWindow.pLabelLayout), "elm,state,show,default", "elm");
4618         return;
4619 }
4620
4621 /******************************
4622 ** Prototype    : mf_callback_nofity_hide_callback
4623 ** Description  :
4624 ** Input        : void *data
4625 **                Evas_Object *obj
4626 **                void *event_info
4627 ** Output       : None
4628 ** Return Value :
4629 ** Calls        :
4630 ** Called By    :
4631 **
4632 **  History        :
4633 **  1.Date         : 2010/12/10
4634 **    Author       : Samsung
4635 **    Modification : Created function
4636 **
4637 ******************************/
4638 void mf_callback_nofity_hide_callback(void *data, Evas *e, Evas_Object *obj, void *event_info)
4639 {
4640         struct appdata *ap = (struct appdata *)data;
4641         mf_retm_if(ap == NULL, "invalid parameter ap is NULL");
4642
4643         edje_object_signal_emit(_EDJ(ap->mf_MainWindow.pLabelLayout), "elm,state,hide,default", "elm");
4644         return;
4645 }
4646
4647 void mf_callback_operation_timeout_cb(void *data, Evas_Object *obj, void *event_info)
4648 {
4649         MF_TRACE_BEGIN;
4650         struct appdata *ap = (struct appdata *)data;
4651         assert(ap);
4652
4653         if (obj) {
4654                 evas_object_del(obj);
4655                 ap->mf_MainWindow.pLabelLayout = NULL;
4656                 ap->mf_MainWindow.pOperationNotify = NULL;
4657         }
4658         MF_TRACE_END;
4659         return;
4660 }
4661
4662 Eina_Bool mf_callback_popup_del_idler_cb(void *data)
4663 {
4664         MF_TRACE_BEGIN;
4665         mf_retvm_if(data == NULL, ECORE_CALLBACK_CANCEL, "data is NULL");
4666         struct appdata *ap = (struct appdata *)data;
4667         SAFE_FREE_OBJ(ap->mf_MainWindow.pNormalPopup);
4668         ap->mf_Status.popup_del_idler = NULL;
4669
4670         return ECORE_CALLBACK_CANCEL;
4671 }
4672
4673 #ifdef MYFILE_MOTION_FEATURE
4674
4675 void mf_callback_motion_double_tap(Evas_Object *genlist)
4676 {
4677         MF_TRACE_BEGIN;
4678         mf_retm_if(genlist == NULL, "genlist is NULL");
4679         Elm_Object_Item *item = elm_genlist_first_item_get(genlist);
4680         elm_genlist_item_bring_in(item, ELM_GENLIST_ITEM_SCROLLTO_TOP);
4681
4682 }
4683 #endif
4684
4685 void mf_callback_profile_changed_cb(void *data, Evas_Object * obj, void *event_info)
4686 {
4687         MF_TRACE_BEGIN;
4688         mf_retm_if(data == NULL, "data is NULL");
4689         struct appdata *ap = (struct appdata *)data;
4690         const char *profile = elm_config_profile_get();
4691
4692         if (!strcmp(profile, "desktop")) {
4693                 elm_object_item_part_content_set(ap->mf_MainWindow.pNaviItem, "prev_btn", NULL);
4694                 elm_win_indicator_mode_set(ap->mf_MainWindow.pWindow, ELM_WIN_INDICATOR_HIDE);
4695         }
4696         else {   // mobile
4697                 Evas_Object *btn = elm_button_add(ap->mf_MainWindow.pNaviBar);
4698                 elm_object_style_set(btn, "naviframe/end_btn/default");
4699                 evas_object_smart_callback_add(btn, "clicked", mf_callback_backbutton_clicked_cb, ap);
4700                 elm_object_item_part_content_set(ap->mf_MainWindow.pNaviItem, "prev_btn", btn);
4701
4702                 elm_win_indicator_mode_set(ap->mf_MainWindow.pWindow, ELM_WIN_INDICATOR_SHOW);
4703         }
4704 }
4705
4706 void mf_callback_share_cb(void *data, Evas_Object * obj, void *event_info)
4707 {
4708         MF_TRACE_BEGIN;
4709         mf_retm_if(data == NULL, "data is NULL");
4710         struct appdata *ap = (struct appdata *)data;
4711         int share_mode = 0;
4712         int file_mode = 0;
4713
4714
4715         if (ap->mf_FileRecordList.selected_files) {
4716                 mf_util_free_eina_list_with_data(&ap->mf_FileRecordList.selected_files, MYFILE_TYPE_GSTRING);
4717         }
4718         ap->mf_FileRecordList.selected_files = mf_util_get_all_selected(ap);
4719
4720         file_mode = mf_share_mode_get(ap->mf_FileRecordList.selected_files);
4721
4722         if ((file_mode & SHARE_FILE_MODE_OTHERS) || ((file_mode & SHARE_FILE_MODE_IMAGE) && (file_mode & SHARE_FILE_MODE_VIDEO))) {
4723                 share_mode = SHARE_MODE_NORMAL;
4724         } else if (file_mode & SHARE_FILE_MODE_MULTI_IMAGE) {
4725                 share_mode = SHARE_MODE_MULTI_IMAGE;
4726         } else if (file_mode & SHARE_FILE_MODE_MULTI_VIDEO) {
4727                 share_mode = SHARE_MODE_MULTI_VIDEO;
4728         } else if (file_mode & SHARE_FILE_MODE_IMAGE) {
4729                 share_mode = SHARE_MODE_IMAGE;
4730         } else if (file_mode & SHARE_FILE_MODE_VIDEO) {
4731                 share_mode = SHARE_MODE_VIDEO;
4732         } else {
4733                 share_mode = SHARE_MODE_NORMAL;
4734         }
4735         mf_context_popup_create_share(ap, share_mode, obj);
4736 }
4737
4738 void mf_callback_thumb_created_cb(media_content_error_e error, const char *path, void *user_data)
4739 {
4740         mf_retm_if(user_data == NULL, "user_data is NULL");
4741         mf_retm_if(path == NULL, "path is NULL");
4742         mfItemData_s *pListData = (mfItemData_s *)user_data;
4743         mf_retm_if(pListData->item == NULL, "pListData->item is NULL");
4744
4745         if (ecore_file_exists(path)) {
4746                 mf_debug("Update item with new thumbnail[%s]", path);
4747                 SAFE_FREE_CHAR(pListData->thumb_path);
4748                 pListData->thumb_path = g_strdup(path);
4749                 if (pListData->ap->mf_Status.flagViewType == MF_VIEW_STYLE_THUMBNAIL) {
4750                         elm_gengrid_item_update(pListData->item);
4751                 } else {
4752                         elm_genlist_item_update(pListData->item);
4753                 }
4754         } else {
4755                 mf_debug("Invalid thumb path!");
4756         }
4757 }
4758
4759 bool mf_callback_create_thumbnail(void *data, media_thumbnail_completed_cb callback)
4760 {
4761         mf_retvm_if(data == NULL, -1, "filter is NULL");
4762         mfItemData_s *pListData = (mfItemData_s *)data;
4763
4764         int ret = -1;
4765
4766         ret = media_info_create_thumbnail(pListData->media, callback,
4767                                           pListData);
4768         if (ret != MEDIA_CONTENT_ERROR_NONE) {
4769                 mf_debug("Failed to create thumbnail!");
4770                 return -1;
4771         }
4772         return 0;
4773
4774         return false;
4775 }
4776 void mf_callback_entry_button_pressed_cb(void *data, Evas_Object * obj, void *event_info)
4777 {
4778         MF_TRACE_BEGIN;
4779         mf_retm_if(data == NULL, "data is NULL");
4780
4781         Evas_Object *entry_button_ic = (Evas_Object *)data;
4782         elm_image_file_set(entry_button_ic, MF_ICON_ENTRY_FOLDER_PRESS, NULL);
4783 }
4784
4785 void mf_callback_entry_button_unpressed_cb(void *data, Evas_Object * obj, void *event_info)
4786 {
4787         MF_TRACE_BEGIN;
4788         mf_retm_if(data == NULL, "data is NULL");
4789
4790         Evas_Object *entry_button_ic = (Evas_Object *)data;
4791         elm_image_file_set(entry_button_ic, MF_ICON_ENTRY_FOLDER, NULL);
4792 }
4793
4794 void mf_callback_entry_cb(void *data, Evas_Object * obj, void *event_info)
4795 {
4796         mf_retm_if(data == NULL, "data is NULL");
4797         mfItemData_s *pItemData = (mfItemData_s *)data;
4798
4799         struct appdata *ap = pItemData->ap;
4800
4801         if (ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL) {
4802                 return;
4803         }
4804
4805         if (ap->mf_Status.flagNaviPush) {
4806                 mf_debug("the transition of the naviframe is not finished");
4807                 return;
4808         }
4809
4810         GString *path = mf_fm_svc_wrapper_get_file_parent_path(pItemData->m_ItemName);
4811         mf_retm_if(path == NULL, "path is NULL");
4812         mf_retm_if(path->str == NULL, "path->str is NULL");
4813
4814         int error_code = 0;
4815         int mmc_card = 0;
4816         bool result = FALSE;
4817
4818         myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
4819         mf_retm_if(pNavi_s == NULL, "get navi structure failed");
4820
4821         error_code = mf_util_is_mmc_on(&mmc_card);
4822         if (ap->mf_Status.more == MORE_DEFAULT
4823             || ap->mf_Status.more == MORE_INTERNAL_COPY
4824             || ap->mf_Status.more == MORE_INTERNAL_MOVE
4825             || ap->mf_Status.more == MORE_INTERNAL_COPY_MOVE) {
4826                 if (mf_fm_svc_wrapper_is_dir(path)) {
4827
4828 #ifdef MYFILE_USB_OTG
4829                         /* if click items under otg root path, it means some disk take into use*/
4830                         error_code = 0;
4831                         error_code = mf_file_attr_is_disk_link(path->str, &result);
4832                         if (error_code == 0 && result == TRUE) {        /* a usb disk take into use */
4833                                 /*
4834                                 **we don't need to set the previous device flag to be false
4835                                 **because click cannot jump from one device to another
4836                                 */
4837                                 mf_otg_set_node_using_flag(ap, path->str,TRUE);
4838                         }
4839 #endif
4840                         /*set new path */
4841                         if (ap->mf_Status.path != NULL) {
4842                                 g_string_free(ap->mf_Status.path, TRUE);
4843                                 ap->mf_Status.path = NULL;
4844                         }
4845                         ap->mf_Status.path = path;
4846
4847                         if (pNavi_s->pCurrentPath != NULL) {
4848                                 free(pNavi_s->pCurrentPath);
4849                                 pNavi_s->pCurrentPath = NULL;
4850                         }
4851                         pNavi_s->pCurrentPath = g_strdup(path->str);
4852                         ap->mf_Status.view_type = mf_view_normal;
4853                         mf_widget_refresh_view(ap);
4854                 }
4855         }
4856 }
4857
4858 void mf_callback_imf_preedit_change_cb(void *data, Evas_Object *obj, void *event_info)
4859 {
4860         mf_retm_if(data == NULL, "data is NULL");
4861         struct appdata *ap = (struct appdata *)data;
4862
4863         Eina_Bool entry_empty = elm_entry_is_empty(ap->mf_MainWindow.pEntry);
4864
4865         if (entry_empty) {
4866                 elm_object_signal_emit(ap->mf_MainWindow.pEditField, "elm,state,eraser,hide", "elm");
4867         } else {
4868                 elm_object_signal_emit(ap->mf_MainWindow.pEditField, "elm,state,eraser,show", "elm");
4869         }
4870
4871         return;
4872 #if 0
4873         SAFE_FREE(view_data->editing_text);
4874         const char *preedit_str = elm_entry_entry_get(obj);
4875         view_data->editing_text = g_strdup(preedit_str);
4876 #endif
4877 }
4878 void mf_callback_imf_hide_cb(void *data, Evas_Object *obj, void *event_info)
4879 {
4880         Evas_Object *entry = (Evas_Object *)data;
4881         elm_object_focus_set(entry, EINA_FALSE);
4882 }
4883
4884 void mf_callback_naviframe_title_clicked_cb(void *data, Evas_Object *obj, void *event_info)
4885 {
4886         Elm_Object_Item *navi_it = event_info;
4887         if (!navi_it) return;
4888
4889
4890         Evas_Object *label = elm_object_item_part_content_get(navi_it, "elm.swallow.title");
4891         if (!label)
4892                 return;
4893         elm_label_slide_go(label);
4894 }
4895
4896
4897
4898