2 * Copyright 2013 Samsung Electronics Co., Ltd
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
8 * http://floralicense.org/license/
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.
24 #include <media_content.h>
26 #include <Elementary.h>
27 #ifdef MYFILE_MOTION_FEATURE
28 #include "mf-sensor.h"
36 #include "mf-callback.h"
37 #include "mf-widget.h"
38 #include "mf-gadget.h"
39 #include "mf-fm-svc-wrapper.h"
43 #include "mf-launch.h"
44 #include "mf-language-mgr.h"
45 #include "mf-s-beam.h"
47 #define MF_B_KEY_PATH "path"
49 GString *phone_folder_as_param;
51 static bool __mf_main_create_app(void *data);
52 static void __mf_main_terminate_app(void *data);
53 static void __mf_main_stop_app(void *data);
54 static void __mf_main_resume_app(void *data);
55 static void __mf_main_reset_app(service_h service, void *data);
56 static void __mf_main_storage_status_get(void *data);
58 static void __mf_main_data_init(void *data)
61 mf_retm_if(data == NULL, "data is NULL");
63 struct appdata *ap = (struct appdata *)data;
64 /*set state value for create content*/
65 ap->mf_Status.more = MORE_DEFAULT;
66 ap->mf_Status.path = g_string_new(PHONE_FOLDER);
67 ap->mf_SharedGadget.ug = NULL;
68 ap->mf_Status.iStorageState = MYFILE_PHONE;
69 ap->mf_Status.iFolderSortType = MYFILE_SORT_BY_DATE_R2O;
70 ap->mf_Status.flagLCDLock = EINA_FALSE;
71 ap->mf_Status.rotation_type = MF_ROTATE_PORTRAIT;
72 ap->mf_Status.flagNaviPush = EINA_FALSE;
74 /* region format related */
75 ap->mf_Status.flagIcuInit = FALSE;
76 ap->mf_Status.generator = NULL;
77 ap->mf_Status.formatter = NULL;
78 ap->mf_Status.flagRootView = EINA_TRUE;
79 ap->mf_Status.flagIME = EINA_TRUE;
80 ap->mf_Status.view_type = mf_view_root;
81 ap->mf_Status.preViewType = mf_view_root;
82 mf_util_get_vconf_value(VCONF_TYPE_NFC_ENABLE, &ap->mf_Status.iNFCState);
83 mf_util_get_vconf_value(VCONF_TYPE_VIEW_STYLE, &ap->mf_Status.flagViewType);
84 mf_util_get_vconf_value(VCONF_TYPE_EXTENSION_STATE, &ap->mf_Status.iExtensionState);
90 /******************************
91 ** Prototype : mf_main_load_edj
93 ** Input : Evas_Object *parent
102 ** 1.Date : 2010/12/10
104 ** Modification : Created function
106 ******************************/
107 Evas_Object *mf_main_load_edj(Evas_Object * parent, const char *file, const char *group)
113 eo = elm_layout_add(parent);
114 elm_object_focus_set(eo, EINA_FALSE);
116 r = elm_layout_file_set(eo, file, group);
122 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
128 #ifdef MYFILE_MOTION_FEATURE
129 static void __mf_app_doubletap_cb(unsigned long long timestamp, void *data)
132 mf_widget_first_item_bring_in(data);
136 /******************************
137 ** Prototype : __mf_main_del_win
139 ** Input : void *data
148 ** 1.Date : 2010/12/10
150 ** Modification : Created function
152 ******************************/
153 static void __mf_main_del_win(void *data, Evas_Object * obj, void *event)
158 /******************************
159 ** Prototype : __mf_main_create_win
161 ** Input : const char *name
168 ** 1.Date : 2010/12/10
170 ** Modification : Created function
172 ******************************/
173 static Evas_Object *__mf_main_create_win(const char *name)
178 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
179 elm_object_focus_set(eo, EINA_FALSE);
180 elm_win_autodel_set(eo, 1);
182 elm_win_title_set(eo, name);
183 evas_object_smart_callback_add(eo, "delete,request", __mf_main_del_win, NULL);
184 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
185 evas_object_resize(eo, w, h);
188 evas_object_show(eo);
196 static Evas_Object *__mf_main_create_bg(Evas_Object *win)
198 mf_retv_if(win == NULL, NULL);
199 Evas_Object *bg = elm_bg_add(win);
200 elm_object_focus_set(bg, EINA_FALSE);
202 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
204 elm_win_resize_object_add(win, bg);
206 evas_object_show(bg);
212 /******************************
213 ** Prototype : __mf_main_capture_idle_img
215 ** Input : void *data
222 ** 1.Date : 2010/12/10
224 ** Modification : Created function
226 ******************************/
228 static int __mf_main_check_path_vaild(const char *dir, int *dir_type)
230 mf_retvm_if(dir == NULL, -1, "dir is NULL");
231 mf_retvm_if(dir_type == NULL, -1, "state is NULL");
233 if (g_file_test(dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)
234 && strncmp(dir, ".", 1)) {
235 if (strncmp(dir, PHONE_FOLDER, strlen(PHONE_FOLDER)) == 0) {
236 *dir_type = MYFILE_PHONE;
237 } else if (strncmp(dir, MEMORY_FOLDER, strlen(MEMORY_FOLDER)) == 0) {
238 *dir_type = MYFILE_MMC;
239 #ifdef MYFILE_USB_OTG
240 } else if (strncmp(dir, OTG_FOLDER, strlen(OTG_FOLDER)) == 0){
241 *dir_type = MYFILE_OTG;
244 *dir_type = MYFILE_NONE;
247 *dir_type = MYFILE_NONE;
252 static void __mf_main_bundle_parse(service_h service, void *data)
257 struct appdata *ap = (struct appdata *)data;
259 service_get_extra_data (service, "path", &ap->mf_Bundle.path);
260 service_get_extra_data (service, "select_type", &ap->mf_Bundle.select_type);
261 service_get_extra_data (service, "file_type", &ap->mf_Bundle.file_type);
262 service_get_extra_data (service, "marked_mode", &ap->mf_Bundle.marked_mode);
263 service_get_extra_data (service, "drm_type", &ap->mf_Bundle.drm_type);
267 static void __mf_main_view_create(void *data)
271 MF_TA_ACUM_ITEM_BEGIN(" mf_main_view_create", 0);
272 struct appdata *ap = (struct appdata *)data;
273 //MF_TA_ACUM_ITEM_END(" create_to_reset", 0);
275 //create phone navibar struct
277 MF_TA_ACUM_ITEM_BEGIN(" mf_widget_refresh_view", 0);
278 mf_widget_refresh_view(ap);
279 MF_TA_ACUM_ITEM_END(" mf_widget_refresh_view", 0);
280 MF_TA_ACUM_ITEM_END(" mf_main_view_create", 0);
284 Eina_Bool __mf_main_prop_change(void *data, int ev_type, void *ev)
289 Ecore_X_Event_Window_Property *event = ev;
291 if (event->win != ecore_x_window_root_first_get())
292 return ECORE_CALLBACK_PASS_ON;
294 if (event->atom != ecore_x_atom_get("FONT_TYPE_change")) {
295 return ECORE_CALLBACK_PASS_ON;
298 return ECORE_CALLBACK_PASS_ON;
302 __mf_main_app_init_idler_cb(void *data)
306 struct appdata *ap = (struct appdata *)data;
307 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_app_init_idler_cb", 0);
310 SAFE_FREE_ECORE_EVENT(ap->mf_MainWindow.font_event);
312 ap->mf_MainWindow.font_event = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY,
313 __mf_main_prop_change,
316 SAFE_FREE_ECORE_EVENT(ap->mf_MainWindow.event);
317 ap->mf_MainWindow.event = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
318 (Ecore_Event_Handler_Cb)mousedown_cb, ap);
320 //MF_TA_ACUM_ITEM_BEGIN(" mmc callback set", 0);
321 mf_callback_set_mmc_state_cb(ap);
322 //MF_TA_ACUM_ITEM_END(" mmc callback set", 0);
323 #ifdef MYFILE_USB_OTG
324 //MF_TA_ACUM_ITEM_BEGIN(" otg callback set", 0);
325 mf_callback_set_otg_state_cb(ap);
326 //MF_TA_ACUM_ITEM_END(" otg callback set", 0);
328 ap->mf_Status.app_init_idler = NULL;
330 if (mf_sbeam_init()) {
331 mf_sbeam_set_callback(mf_callback_sbeam_cb, ap);
334 #ifdef MYFILE_MOTION_FEATURE
335 if(!mf_sensor_init()){
336 if(!mf_sensor_set_callback(MF_MOTION_DOUBLETAP, __mf_app_doubletap_cb, ap)){
337 mf_sensor_start(MF_MOTION_DOUBLETAP);
340 ap->mf_Status.doubletab_event_handler = mf_callback_motion_double_tap;
343 MF_TA_ACUM_ITEM_END(" __mf_main_app_init_idler_cb", 0);
345 return ECORE_CALLBACK_CANCEL;
348 static int __mf_main_remake_app(service_h service, void *data)
352 MF_TA_ACUM_ITEM_BEGIN(" mf_main_remake_app", 0);
353 struct appdata *ap = (struct appdata *)data;
354 MF_TA_ACUM_ITEM_BEGIN(" check mass storage state", 0);
356 /*if myfile state is not normal, it is not handled argument*/
357 if (ap->mf_Status.more != MORE_DEFAULT) {
358 mf_warnig("Fail to handle budle, current myfiles stat is %d", ap->mf_Status.more);
361 MF_TA_ACUM_ITEM_END(" check mass storage state", 0);
362 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_view_create", 0);
364 __mf_main_view_create(ap);
365 MF_TA_ACUM_ITEM_END(" __mf_main_view_create", 0);
369 /**************pre-condition test to launch myfile app******************/
370 MF_TA_ACUM_ITEM_END(" mf_main_remake_app", 0);
372 MF_TA_ACUM_ITEM_END(" Myfiles Launch Time", 0);
378 /* system operation callbacks */
379 /******************************
380 ** Prototype : _keydown_event
382 ** Input : void *data
391 ** 1.Date : 2010/12/10
393 ** Modification : Created function
395 ******************************/
396 #define TEMP_ENDKEY_ROLLBACK
398 static Eina_Bool __mf_main_keydown_event_callback(void *data, int type, void *event)
400 Ecore_Event_Key *ev = event;
401 struct appdata *ap = (struct appdata *)data;
402 mf_retvm_if(ev == NULL, ECORE_CALLBACK_RENEW, "Ecore_Event_Key is NULL");
403 mf_retvm_if(ap == NULL, ECORE_CALLBACK_RENEW, "appdata is NULL");
405 if (!strcmp(ev->keyname, KEY_END)) {
406 #ifdef TEMP_ENDKEY_ROLLBACK
407 if (ap->mf_Status.more != MORE_DEFAULT) {
408 if (ap->mf_MainWindow.pProgressPopup != NULL) {
409 if (ap->mf_Status.more == MORE_DATA_COPYING
410 || ap->mf_Status.more == MORE_DATA_MOVING
411 || ap->mf_Status.more == MORE_DELETE || ap->mf_Status.more == MORE_IDLE_DELETE) {
412 mf_callback_progress_bar_cancel_cb(ap, NULL, NULL);
416 if (ap->mf_FileOperation.search_IME_hide_timer != NULL) {
417 ecore_timer_del(ap->mf_FileOperation.search_IME_hide_timer);
418 ap->mf_FileOperation.search_IME_hide_timer = NULL;
423 if (ap->mf_SharedGadget.ug != NULL) {
425 ug_send_key_event(UG_KEY_EVENT_END);
427 if (ap->mf_MainWindow.pContextPopup != NULL) {
429 evas_object_del(ap->mf_MainWindow.pContextPopup);
430 ap->mf_MainWindow.pContextPopup = NULL;
432 if (ap->mf_Status.more == MORE_DEFAULT) {
434 if (mf_fm_svc_wrapper_is_root_path(ap->mf_Status.path->str)) {
437 mf_callback_upper_folder_cb(ap);
440 if (ap->mf_MainWindow.pNormalPopup == NULL) {
441 mf_callback_cancel_cb(ap, NULL, NULL);
443 if (ap->mf_Status.more ==
445 || ap->mf_Status.more ==
446 MORE_DATA_MOVING || ap->mf_Status.more == MORE_DELETE || ap->mf_Status.more == MORE_IDLE_DELETE) {
447 mf_callback_progress_bar_cancel_cb(ap, NULL, NULL);
456 return ECORE_CALLBACK_RENEW;
459 /******************************
460 ** Prototype : __mf_main_create_app
462 ** Input : void *data
469 ** 1.Date : 2010/12/10
471 ** Modification : Created function
473 ******************************/
474 static void __mf_main_storage_status_get(void *data)
476 mf_retm_if(data == NULL, "data is NULL");
477 struct appdata *ap = (struct appdata*)data;
481 MF_TA_ACUM_ITEM_BEGIN(" storage check", 0);
482 error_code = mf_util_is_mmc_on(&mmc_card);
483 if (error_code == 0 && mmc_card == 1) {
484 ap->mf_Status.iStorageState |= MYFILE_MMC;
486 /*check if usb otg mounted */
487 #ifdef MYFILE_USB_OTG
489 error_code = mf_util_is_otg_on(&otg);
490 mf_debug("error code is %d, org is %d", error_code, otg);
491 if (error_code == 0 && otg == 1) {
493 ap->mf_Status.iStorageState |= MYFILE_OTG;
496 MF_TA_ACUM_ITEM_END(" storage check", 0);
499 bool __mf_main_create_app(void *data)
502 struct appdata *ap = (struct appdata *)data;
505 MF_TA_ACUM_ITEM_END(" main-to-create", 0);
508 MF_TA_ACUM_ITEM_BEGIN(" g_thread_init", 0);
509 if (!g_thread_supported()) {
512 MF_TA_ACUM_ITEM_END(" g_thread_init", 0);
513 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_create_app", 0);
515 MF_TA_ACUM_ITEM_BEGIN(" mf_language_mgr_create", 0);
516 mf_language_mgr_create();
517 MF_TA_ACUM_ITEM_END(" mf_language_mgr_create", 0);
520 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_data_init", 0);
521 __mf_main_data_init(ap);
522 MF_TA_ACUM_ITEM_END(" __mf_main_data_init", 0);
524 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_create_win", 0);
526 ap->mf_MainWindow.pWindow = __mf_main_create_win(PACKAGE);
527 mf_retvm_if(ap->mf_MainWindow.pWindow == NULL, -1, "Fail to __mf_main_create_win()");
529 evas_object_geometry_get(ap->mf_MainWindow.pWindow, NULL, NULL, &ap->mf_MainWindow.root_w, &ap->mf_MainWindow.root_h);
531 MF_TA_ACUM_ITEM_END(" __mf_main_create_win", 0);
533 #ifdef MYFILE_SPLIT_VIEW
534 if(mf_util_is_rotation_lock() == 0) {
535 mf_debug("rotation is locked");
536 ap->mf_Status.rotation_type = MF_ROTATE_PORTRAIT;
537 ap->mf_Status.rotation_angle = 0;
539 app_device_orientation_e rotate_mode;
541 rotate_mode = app_get_device_orientation();
543 mf_util_rotate_state_set(ap, rotate_mode);
549 /**************start to launch myfile app******************/
552 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_create_bg", 0);
553 ap->mf_MainWindow.pBackGround = __mf_main_create_bg(ap->mf_MainWindow.pWindow);
554 MF_TA_ACUM_ITEM_END(" __mf_main_create_bg", 0);
556 ap->mf_MainWindow.pConformant = mf_widget_create_conform(ap->mf_MainWindow.pWindow);
557 elm_win_resize_object_add(ap->mf_MainWindow.pWindow, ap->mf_MainWindow.pConformant);
559 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_create_layout_main", 0);
560 ap->mf_MainWindow.pMainLayout = mf_widget_create_layout_main(ap->mf_MainWindow.pConformant);
561 MF_TA_ACUM_ITEM_END(" __mf_main_create_layout_main", 0);
563 elm_object_content_set(ap->mf_MainWindow.pConformant, ap->mf_MainWindow.pMainLayout);
564 elm_win_conformant_set(ap->mf_MainWindow.pWindow, EINA_TRUE);
565 elm_win_indicator_mode_set(ap->mf_MainWindow.pWindow, ELM_WIN_INDICATOR_SHOW);
567 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_storage_status_get", 0);
568 __mf_main_storage_status_get(ap);
569 MF_TA_ACUM_ITEM_END(" __mf_main_storage_status_get", 0);
572 MF_TA_ACUM_ITEM_BEGIN(" create phone naviframe struct", 0);
573 mf_widget_phone_storage_init(ap);
574 MF_TA_ACUM_ITEM_END(" create phone naviframe struct", 0);
576 //create landscape/portrait view
577 MF_TA_ACUM_ITEM_BEGIN(" mf_widget_create", 0);
578 mf_widget_create(ap);
579 MF_TA_ACUM_ITEM_END(" mf_widget_create", 0);
581 MF_TA_ACUM_ITEM_BEGIN(" set_view_to_mainlayout", 0);
584 elm_object_part_content_set(ap->mf_MainWindow.pMainLayout, "elm.swallow.content", ap->mf_MainWindow.pNaviBar);
585 #ifdef MYFILE_SPLIT_VIEW
586 mf_widget_set_main_layout_content(ap);
588 MF_TA_ACUM_ITEM_END(" set_view_to_mainlayout", 0);
591 /*Create content frame of Main Layout*/
592 MF_TA_ACUM_ITEM_BEGIN(" media_content_connect", 0);
593 ret = media_content_connect();
594 mf_retvm_if(ret < 0, -1, "Fail to media_content_connect()");
595 MF_TA_ACUM_ITEM_END(" media_content_connect", 0);
598 MF_TA_ACUM_ITEM_BEGIN(" mf_callback_create_dir_monitor", 0);
599 ret = mf_callback_create_dir_monitor(ap);
600 mf_retvm_if(ret < 0, -1, "Fail to mf_callback_create_dir_monitor()");
601 MF_TA_ACUM_ITEM_END(" mf_callback_create_dir_monitor", 0);
603 MF_TA_ACUM_ITEM_BEGIN(" app_init_idler", 0);
604 ap->mf_Status.app_init_idler = ecore_idler_add(__mf_main_app_init_idler_cb, ap);
605 MF_TA_ACUM_ITEM_END(" app_init_idler", 0);
607 evas_object_smart_callback_add(ap->mf_MainWindow.pWindow, "profile,changed", mf_callback_profile_changed_cb, ap);
609 __mf_main_remake_app(NULL, ap);
611 MF_TA_ACUM_ITEM_END(" __mf_main_create_app", 0);
612 MF_TA_ACUM_ITEM_BEGIN(" create_to_reset", 0);
616 ap->mf_Status.b_run_background = false; /* 20121008 added for fix PLM P121001-0404 temporary */
621 static void __mf_main_reset_app(service_h service, void *data)
624 MF_TA_ACUM_ITEM_END(" create_to_reset", 0);
627 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_reset_app", 0);
628 struct appdata *ap = (struct appdata *)data;
629 char *operation = NULL;
631 MF_TA_ACUM_ITEM_BEGIN(" service_get_operation", 0);
633 service_get_operation(service, &operation);
634 MF_TA_ACUM_ITEM_END(" service_get_operation", 0);
637 if (g_strcmp0(operation, SERVICE_OPERATION_PICK) == 0) {
638 __mf_main_bundle_parse(service, ap);
639 /*launch myfile ug here*/
640 ap->mf_SharedGadget.ug = mf_launch_load_ug_myfile(ap);
642 service_clone(&ap->mf_Bundle.recv_service, service);
645 char *launch_type_str = NULL;
646 service_get_extra_data(service, "launch-type", &launch_type_str);
647 if(launch_type_str &&!strcasecmp(launch_type_str, "shortcut")) {
648 SAFE_FREE_CHAR(ap->mf_Bundle.path);
649 SAFE_FREE_CHAR(ap->mf_Bundle.select_type);
650 SAFE_FREE_CHAR(ap->mf_Bundle.file_type);
651 SAFE_FREE_CHAR(ap->mf_Bundle.marked_mode);
652 SAFE_FREE_CHAR(ap->mf_Bundle.drm_type);
653 ap->mf_Bundle.path = g_strdup(PHONE_FOLDER);
654 ap->mf_Bundle.select_type = g_strdup("SHORTCUT");
655 ap->mf_SharedGadget.ug = mf_launch_load_ug_myfile(ap);
656 SAFE_FREE_CHAR(ap->mf_Bundle.path);
657 SAFE_FREE_CHAR(ap->mf_Bundle.select_type);
661 service_get_extra_data (service, "path", &uri);
662 mf_debug("======== uri is [%s]", uri);
663 if (uri && ecore_file_exists(uri)) {
664 MF_TA_ACUM_ITEM_BEGIN(" otg_launch", 0);
665 myfileNaviBar *pNavi_s_toshow = NULL;
666 myfileNaviBar *pNavi_s_inuse = NULL;
667 Evas_Object *pNaviBar = NULL;
668 ap->mf_Status.view_type = mf_view_normal;
669 pNavi_s_inuse = mf_navi_bar_get_in_use(ap);
670 if (pNavi_s_inuse == NULL || pNavi_s_inuse->pNaviLabel == NULL) {
675 int locate = mf_fm_svc_wrapper_get_location(uri);
676 char *storage = NULL;
679 storage = GET_SYS_STR(MF_LABEL_PHONE);
682 storage = GET_SYS_STR(MF_LABEL_MMC);
685 storage = GET_STR(MF_LABEL_OTG);
691 pNavi_s_inuse->naviFlagInUse = FALSE;
693 pNaviBar = ap->mf_MainWindow.pNaviBar;
694 pNavi_s_toshow = mf_navi_bar_get_navi_from_navilist(ap->mf_MainWindow.plistNaviBar, storage);
696 if (pNavi_s_toshow == NULL) {
697 /*2.0 get root path by storage label */
698 char *rootpath = g_strdup(uri);
699 if (rootpath == NULL) {
703 /*2.1 create the navi for the tab */
704 pNavi_s_toshow = malloc(sizeof(myfileNaviBar));
705 if (pNavi_s_toshow == NULL) {
708 mf_debug("pNavi_s_toshow is NULL");
712 memset(pNavi_s_toshow, 0, sizeof(myfileNaviBar));
714 pNavi_s_toshow->naviFlagInUse = TRUE;
715 /*2.2 set path as root path of the storage */
716 pNavi_s_toshow->pCurrentPath = g_strdup(rootpath);
717 pNavi_s_toshow->pNaviLabel = g_strdup(storage);
719 /*2.3 insert phone navi into the navi_list */
720 ap->mf_MainWindow.plistNaviBar = eina_list_append(ap->mf_MainWindow.plistNaviBar, pNavi_s_toshow);
722 if (ap->mf_Status.path != NULL) {
723 g_string_free(ap->mf_Status.path, TRUE);
724 ap->mf_Status.path = NULL;
726 ap->mf_Status.path = g_string_new(pNavi_s_toshow->pCurrentPath);
727 __mf_main_remake_app(service, ap);
732 /*2.1 get the navi of the tab */
733 pNavi_s_toshow = mf_navi_bar_get_struct_by_label(ap, storage);
734 pNavi_s_toshow->naviFlagInUse = TRUE;
736 /*2.2 set related status value. */
737 if (ap->mf_Status.path != NULL) {
738 g_string_free(ap->mf_Status.path, TRUE);
739 ap->mf_Status.path = NULL;
741 ap->mf_Status.path = g_string_new(uri);
742 SAFE_FREE_CHAR(pNavi_s_toshow->pCurrentPath);
743 pNavi_s_toshow->pCurrentPath = g_strdup(uri);
745 /*2.3 update the content to catch update */
746 /*Todo: How to ensure insert only once */
747 __mf_main_remake_app(service, ap);
749 mf_navi_bar_remove_previous_contents(ap, ap->mf_MainWindow.pNaviBar);
752 MF_TA_ACUM_ITEM_END(" otg_launch", 0);
756 /* 20121008 added for fix PLM P121001-0404 temporary { */
757 if (ap->mf_MainWindow.pWindow != NULL && ap->mf_Status.b_run_background)
760 elm_win_activate(ap->mf_MainWindow.pWindow);
761 ap->mf_Status.b_run_background = false;
769 if (ap->mf_MainWindow.pWindow) {
770 evas_object_show(ap->mf_MainWindow.pWindow);
771 elm_win_activate(ap->mf_MainWindow.pWindow);
773 MF_TA_ACUM_ITEM_END(" __mf_main_reset_app", 0);
777 static void __mf_main_resume_app(void *data)
779 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_resume_app", 0);
781 mf_retm_if(data == NULL, "data is NULL");
782 #ifdef MYFILE_SPLIT_VIEW
783 struct appdata *ap = (struct appdata *)data;
784 if (!mf_util_is_rotation_lock()) {
785 ap->mf_Status.rotation_type = MF_ROTATE_PORTRAIT;
786 ap->mf_Status.rotation_angle = 0;
788 mf_callback_app_rotate_cb(APP_DEVICE_ORIENTATION_0, ap);
791 app_device_orientation_e mode = APP_DEVICE_ORIENTATION_0 ;
792 mode = app_get_device_orientation();
793 if (mode != ap->mf_Status.rotation_type)
794 mf_callback_app_rotate_cb(mode, ap);
796 if (ap->mf_MainWindow.pWindow) {
797 evas_object_show(ap->mf_MainWindow.pWindow);
801 MF_TA_ACUM_ITEM_END(" __mf_main_resume_app", 0);
804 /******************************
805 ** Prototype : __mf_main_terminate_app
807 ** Input : void *data
814 ** 1.Date : 2010/12/10
816 ** Modification : Created function
818 ******************************/
819 void __mf_main_terminate_app(void *data)
822 struct appdata *ap = (struct appdata *)data;
825 media_content_disconnect();
826 efreet_mime_shutdown();
828 if (ap->mf_Status.search_handler)
829 mf_search_finalize(&ap->mf_Status.search_handler);
831 mf_callback_destory_dir_monitor(ap);
833 mf_ecore_idler_del(ap->mf_Status.app_init_idler);
834 mf_ecore_idler_del(ap->mf_Status.popup_del_idler);
835 mf_ecore_idler_del(ap->mf_Status.navi_content_idler);
836 SAFE_DEL_ECORE_TIMER(ap->mf_MainWindow.pPopupTimer);
837 SAFE_FREE_ECORE_EVENT(ap->mf_MainWindow.event);
838 SAFE_FREE_ECORE_EVENT(ap->mf_MainWindow.font_event);
840 #ifdef MYFILE_MOTION_FEATURE
841 mf_sensor_finalize();
844 MF_TA_ACUM_ITEM_SHOW_RESULT_TO(MF_TA_SHOW_FILE);
846 #ifdef MYFILE_USB_OTG
850 #ifdef MYFILE_CRITICAL_LOG
855 #ifdef MYFILE_SPLIT_VIEW
856 SAFE_FREE_OBJ(ap->mf_MainWindow.sSplitData.pPanes);
858 if (ap->mf_FileOperation.job_pop_list != NULL) { /*job callback must not run before*/
859 mf_util_clear_handler_list(ap);
860 ap->mf_FileOperation.job_pop_list = NULL;
863 if (ap->mf_FileOperation.job_push != NULL) { /*job callback must not run before*/
864 ecore_job_del(ap->mf_FileOperation.job_push);
865 ap->mf_FileOperation.job_push = NULL;
868 if (ap->mf_Status.flagIcuInit == TRUE)
869 mf_util_icu_finalize(ap);
871 if (ap->mf_FileOperation.sync_pipe) {
872 ecore_pipe_del(ap->mf_FileOperation.sync_pipe);
873 ap->mf_FileOperation.sync_pipe = NULL;
875 mf_util_set_pm_lock(ap, EINA_FALSE);
876 mf_language_mgr_destroy();
879 /******************************
880 ** Prototype : __mf_main_stop_app
882 ** Input : void *data
889 ** 1.Date : 2010/12/10
891 ** Modification : Created function
893 ******************************/
894 void __mf_main_stop_app(void *data)
896 MF_TA_ACUM_ITEM_BEGIN(" __mf_main_stop_app", 0);
898 struct appdata *ap = (struct appdata *)data;
901 /*check if phone navi is empty*/
902 if (mf_launch_myfile_ug_exist(ap)) {
903 /*if myfile ug exists, delete the ug*/
904 if (ap->mf_SharedGadget.ug != NULL) {
905 ug_destroy(ap->mf_SharedGadget.ug);
906 ap->mf_SharedGadget.ug = NULL;
909 /*terminate the process*/
912 if (ap->mf_SharedGadget.ug != NULL) {
913 ug_destroy(ap->mf_SharedGadget.ug);
914 ap->mf_SharedGadget.ug = NULL;
919 MF_TA_ACUM_ITEM_END(" __mf_main_stop_app", 0);
923 /******************************
934 ** 1.Date : 2010/12/10
936 ** Modification : Created function
938 ******************************/
939 static void __mf_language_changed_cb(void *user_data)
941 mf_language_mgr_update();
944 int main(int argc, char *argv[])
946 app_event_callback_s ops;
950 MF_TA_ACUM_ITEM_BEGIN(" Myfiles Launch Time", 0);
951 MF_TA_ACUM_ITEM_BEGIN(" main", 0);
953 #ifdef MYFILE_CRITICAL_LOG
954 int ret = mf_log_init();
955 if (ret != MYFILE_ERR_NONE)
956 mf_debug("initialize critical log failed");
959 memset(&ops, 0x0, sizeof(app_event_callback_s));
960 memset(&ad, 0x0, sizeof(struct appdata));
962 ops.create = __mf_main_create_app;
963 ops.terminate = __mf_main_terminate_app;
964 ops.pause = __mf_main_stop_app;
965 ops.resume = __mf_main_resume_app;
966 ops.service = __mf_main_reset_app;
967 ops.device_orientation = mf_callback_app_rotate_cb;
968 ops.region_format_changed = mf_callback_icu_update_cb;
969 ops.language_changed = __mf_language_changed_cb;
971 MF_TA_ACUM_ITEM_END(" main", 0);
972 MF_TA_ACUM_ITEM_BEGIN(" main-to-create", 0);
973 return app_efl_main(&argc, &argv, &ops, &ad);