NABI_SE isues resolved
[apps/osp/MyFiles.git] / src / MfSubFolderFileListForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (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  * @file: MfSubFolderFileListForm.cpp
19  * @brief: This file contains the implementation of SubFolderFileListForm class, which acts as a media explorer displaying a list of all the files in the sub directories of the root directory opt/Media/
20  * and defines a set of operations that can be done with the files like edit, view etc.
21  */
22
23 #include "MfSubFolderFileListForm.h"
24 #include "MfSearchForm.h"
25
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Base::Utility;
30 using namespace Tizen::Content;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Io;
33 using namespace Tizen::Locales;
34 using namespace Tizen::Media;
35 using namespace Tizen::System;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39
40 SubFolderFileListForm::SubFolderFileListForm(void)
41 : __pHomeButton(null)
42 , __pUpButton(null)
43 , __pHeader(null)
44 {
45         __counter = 0;
46 }
47
48 SubFolderFileListForm::~SubFolderFileListForm(void)
49 {
50         DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD,*this);
51         if(_pFileEventManager != null)
52         {
53                 _pFileEventManager->RemovePath(__currentDirectoryPath);
54                 delete _pFileEventManager;
55                 _pFileEventManager = null;
56         }
57
58         if (__pHomeButton != null)
59         {
60                 delete __pHomeButton;
61         }
62
63         if (__pUpButton != null)
64         {
65                 delete __pUpButton;
66         }
67 }
68
69 SubFolderFileListForm&
70 SubFolderFileListForm::operator =(const SubFolderFileListForm& pSubFolderFileListForm)
71 {
72         return *this;
73 }
74
75 SubFolderFileListForm::SubFolderFileListForm(const SubFolderFileListForm& pSubFolderFileListForm)
76 {
77         __pHomeButton = pSubFolderFileListForm.__pHomeButton;
78         __pUpButton = pSubFolderFileListForm.__pUpButton;
79         __pHeader = pSubFolderFileListForm.__pHeader;
80         _pLabelDisplayPath = pSubFolderFileListForm._pLabelDisplayPath;
81 }
82
83 bool
84 SubFolderFileListForm::Initialize(void)
85 {
86         Form::Construct(L"IDL_SUB_DIRECTORY");
87         return true;
88 }
89
90 result
91 SubFolderFileListForm::OnInitializing(void)
92 {
93         AppLogDebug("SubFolderFileListForm::Initializing");
94         result r = E_SUCCESS;
95         __counter = 0;
96         int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_FOLDER_FILE_LIST_FORM;
97         CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
98
99         String path;
100         String ThumbnailProviderPath;
101         String rootParentPath;
102         String displayPath;
103         String extensionVisibility;
104
105         SceneId currentSceneId;
106         AppResource* pAppResource = null;
107         Bitmap* pBitmapHomeButton = null;
108         Bitmap* pBitmapUpButton = null;
109         Bitmap* pBitmapHomeButtonPress = null;
110         Bitmap* pBitmapUpButtonPress = null;
111
112
113         String  SubDirectorySceneOne(L"ScnSubDirectoryForm"), SubDirecorySceneTwo(L"ScnSubDirectoryForm1");
114
115         _renameIndex = 0;
116         _renameOrCreate = SELECT_CREATE_FOLDER;
117
118
119 #if 0
120         DataBindingContext* pContext = null;
121         Bitmap* pHomeBitmap = null;
122         Bitmap* pUpBitmap = null;
123 #endif
124
125         Color formBgColor = GetBackgroundColor();
126
127         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
128
129         pAppResource = UiApp::App::GetInstance()->GetAppResource();
130         TryCatch(pAppResource != null, , "Resource manager not found!");
131
132         //Set FormBackEvent Listener
133         SetFormBackEventListener(this);
134
135         //Get the label control from IDL_SUB_DIRECTORY
136         _pLabelDisplayPath = static_cast< Label* >(GetControl("IDC_LABEL_DISPLAY_PATH"));
137         TryCatch(_pLabelDisplayPath != null, , "Label is Null");
138         _pLabelDisplayPath->SetBounds(0, 0, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL);
139
140         //pAppResource->GetString(L"IDS_MF_BUTTON_HOME", buttonHome);
141         //pAppResource->GetString(L"IDS_MF_TAB_UP", buttonUp);
142         pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
143         pAppResource->GetString(L"IDS_MF_TAB_PHONE", displayPath);
144         pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
145         pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
146         pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
147         pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
148         pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
149         extensionVisibility = fileExtenstionKeyName;
150         displayPath.Append("/");
151
152         __pHeader = GetHeader();
153
154         if (__pHeader != null)
155         {
156                 __pHomeButton = new (std::nothrow) ButtonItem();
157                 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
158                 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
159                 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
160
161                 __pUpButton = new (std::nothrow) ButtonItem();
162                 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
163                 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
164                 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
165
166                 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
167                 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
168                 __pHeader->AddActionEventListener(*this);
169                 __pHeader->Invalidate(true);
170         }
171
172         _extensionKeyName.Append(extensionVisibility);
173
174         //Pointer for FileListPresentationModel object
175         _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
176         TryCatch(_pFolderEntryPM != null, , "Content Manager not found!");
177         _pFolderEntryPM->Construct();
178
179         currentSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
180         AppLogDebug("Current Scene Id : %S", currentSceneId.GetPointer());
181
182         createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
183
184         _pFolderEntryPM->SetSourceForm(createitemsource);
185
186         _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
187         TryCatch(_pFileManager != null, , "File Manager not found!");
188
189         //String that contains the path of the file to be displayed on the ListView
190         _displayPath = displayPath;
191
192         path = BasePresentationModel::GetMediaPath();
193         __currentDirectoryPath.Append(path);
194
195         //Initialize the itemprovider class for the listview inside the popup
196         if (_pCustomListViewForPopup == null)
197         {
198                 _pCustomListViewForPopup = new (std::nothrow) CustomListViewForPopup();
199         }
200         TryCatch(_pCustomListViewForPopup != null, , "MfMyFilesApp::ListView For Popup not created!");
201
202         _pCustomListViewForPopup->SetEventListener(this);
203
204         _pBaseItemProvider = new (std::nothrow) BaseItemProvider();
205         TryCatch(_pBaseItemProvider != null, , "Failed to allocate base itemprovider");
206         _pBaseItemProvider->Construct();
207         _pBaseItemProvider->SetSourceForm(createitemsource);
208         _pBaseItemProvider->SetFolderEntryProvider(this);
209         _pBaseItemProvider->SetFooterItemStateChangeListener(this);
210
211         //Get the ListView Control from IDL_SUB_DIRECTORY and set the ItemProvider and Listener
212         _pListView = static_cast< ListView* >(GetControl("IDC_LISTVIEW"));
213         TryCatch(_pListView != null, , "__pListView is Null");
214         _pListView->AddListViewItemEventListener(*this);
215         _pListView->SetItemProvider(*_pBaseItemProvider);
216         _pListView->SetShowState(false);
217
218         _pFooter = GetFooter();
219
220         if (_pThumbnailItemProvider == null)
221         {
222                 _pThumbnailItemProvider = new (std::nothrow) ThumbnailItemProviderAndListener(__currentDirectoryPath, sourceForm);
223                 _pThumbnailItemProvider->SetFolderEntryProvider(this);
224         }
225         TryCatch(_pThumbnailItemProvider != null, , "Failed to allocate Memory to __pSubFolderThumbnailsProvider");
226
227         _pThumbnailItemProvider->SetFooterItemStateChangeListener(this);
228
229         _pIconListView = static_cast< IconListView* >(GetControl("IDC_ICONLISTVIEW_SUB_DIRECTORY_THUMBNAILS"));
230         TryCatch(_pIconListView != null, , "__pIconListviewSubThumbnails is Null");
231         _pIconListView->AddIconListViewItemEventListener(*_pThumbnailItemProvider);
232         _pIconListView->AddTouchEventListener(*this);
233         _pIconListView->SetItemProvider(*_pThumbnailItemProvider);
234         _pIconListView->SetShowState(false);
235
236         _pLongPressGestureDetector = new (std::nothrow) TouchLongPressGestureDetector();
237         _pLongPressGestureDetector->Construct();
238
239 #if 0
240         pContext = GetDataBindingContextN();
241         TryCatch(pContext != null, , "Failed to Fetch the DataBinding Context");
242
243         pContext->Bind(L"ID_DISPLAY_PATH", L"IDC_LABEL_DISPLAY_PATH", L"text", _displayPath, DATA_BINDING_DATA_TYPE_STRING, DATA_BINDING_FLOW_TWO_WAY, DATA_BINDING_TRIGGER_EXPLICIT, null, null, null);
244
245         delete pContext;
246 #endif
247
248         delete pBitmapHomeButton;
249         delete pBitmapUpButton;
250         delete pBitmapHomeButtonPress;
251         delete pBitmapUpButtonPress;
252         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
253         return r;
254
255 CATCH:
256
257         if (_pCustomListViewForPopup != null)
258         {
259                 delete _pCustomListViewForPopup;
260                 _pCustomListViewForPopup = null;
261         }
262
263         if (pBitmapHomeButton != null)
264         {
265                 delete pBitmapHomeButton;
266                 pBitmapHomeButton = null;
267         }
268
269         if (pBitmapUpButton != null)
270         {
271                 delete pBitmapUpButton;
272                 pBitmapUpButton = null;
273         }
274         if (pBitmapHomeButtonPress != null)
275         {
276                 delete pBitmapHomeButtonPress;
277                 pBitmapHomeButtonPress = null;
278         }
279         if (pBitmapUpButtonPress != null)
280         {
281                 delete pBitmapUpButtonPress;
282                 pBitmapUpButtonPress = null;
283         }
284         return r;
285 }
286
287 result
288 SubFolderFileListForm::OnTerminating(void)
289 {
290         result r = E_SUCCESS;
291         //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
292
293         _pFooter = GetFooter();
294         if (_pFooter != null)
295         {
296                 _pFooter->RemoveAllButtons();
297                 _pFooter->RemoveAllItems();
298         }
299
300         __pHeader = GetHeader();
301         if (__pHeader != null)
302         {
303                 __pHeader->RemoveAllButtons();
304                 __pHeader->RemoveAllItems();
305         }
306
307         return r;
308 }
309
310 void
311 SubFolderFileListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
312 {
313         SceneManager* pSceneManager = SceneManager::GetInstance();
314         result r = E_SUCCESS;
315         String parentPath;
316         String currentPath;
317         String delim(L"/");
318         String token;
319         String displayPath;
320 #if 0
321         AppLogDebug("Scene History");
322         bool searchHistory = CheckSearchHistory();
323         String currentPath = FolderNavigationPresentationModel::GetCurrentPath();
324         String parentPath;
325
326         SceneManager* pSceneManager = SceneManager::GetInstance();
327 #endif
328         if (CheckSearchHistory() == true)
329         {
330 #if 0
331                 parentPath = FolderNavigationPresentationModel::GetSearchPreviousPath();
332                 AppLogDebug("ParentPath is %S", parentPath.GetPointer());
333                 FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
334                 AppLogDebug("__previousSceneName is %S", __previousSceneName.GetPointer());
335
336                 //pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
337
338
339                 if (parentPath == currentPath)
340                 {
341                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
342                 }
343                 else
344                 {
345                         if (__previousSceneName == IDSCN_SUB_DIRECTORY_FORM1 || __previousSceneName == IDSCN_SUB_DIRECTORY_FORM)
346                         {
347                                 String searchPath = FolderNavigationPresentationModel::GetCurrentPath();
348
349                                 FolderNavigationPresentationModel::SetSearchPreviousPath(searchPath);
350                                 if (SceneManager::GetInstance()->IsSceneAlive(__previousSceneName))
351                                 {
352                                         r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
353                                         AppLogDebug("result is %s", GetErrorMessage(r));
354                                 }
355                                 else
356                                 {
357                                         pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
358                                         AppLogDebug("result is %s", GetErrorMessage(r));
359                                 }
360                         }
361                         else
362                         {
363                                 r = pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneName, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
364                                 AppLogDebug("result is %s", GetErrorMessage(r));
365                         }
366                 }
367 #endif
368                 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
369         }
370         else
371         {
372                 //ShowParentDirectoryView();
373                 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
374                 if (currentPath == BasePresentationModel::GetMediaPath() || currentPath == BasePresentationModel::GetSdCardPath())
375                 {
376                         FolderNavigationPresentationModel::SetCurrentFilePath(currentPath);
377                         r = ShowHomeView();
378                 }
379                 else
380                 {
381                         parentPath = FolderNavigationPresentationModel::GetParentPath();
382
383                         FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
384                         r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
385                 }
386         }
387 }
388
389 void
390 SubFolderFileListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
391                 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
392 {
393         AppLogDebug("OnSceneActivatedN ENTER");
394
395         int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
396
397         int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_FOLDER_FILE_LIST_FORM;
398         CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
399
400         result r = E_SUCCESS;
401         String parentPath;
402         String viewStyleKeyName(L"ListDisplayType");
403
404         String phone;
405         String sdCard;
406         String external;
407
408         String received_Filepath;
409         String* pReceived_Filename = null;
410         int receivedStorageType = null;
411
412         AppRegistry* pAppRegistry = null;
413         AppResource* pAppResource = null;
414         String check;
415         pAppResource = UiApp::GetInstance()->GetAppResource();
416         TryCatch(pAppResource != null, , "Failed to fetch AppResource");
417
418         //Create the FooterControls of IDL_SUB_DIRECTORY
419         r = CreateFooterControls();
420         TryCatch(r == E_SUCCESS, , "Failed to create footer controls");
421
422         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
423
424         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
425
426         pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
427         pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
428         pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", external);
429
430         phone.Append(L"/");
431         sdCard.Append(L"/");
432         external.Append(L"/");
433
434         SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
435         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
436
437         SetCurrentDirectoryFlag(false);
438
439         if (_pBaseItemProvider != null)
440         {
441                 _pBaseItemProvider->SetSourceForm(createitemsource);
442         }
443
444         if (_pFileManager != null)
445         {
446                 _pFileManager->SetFileManagingListener(this);
447         }
448
449         if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
450         {
451                 if (_renameOrCreate == SELECT_RENAME)
452                 {
453                         return;
454                 }
455         }
456
457         receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
458
459         if (_pLabelDisplayPath != null)
460         {
461                 switch (receivedStorageType)
462                 {
463                 case MEMORY_TYPE_PHONE:
464                 {
465                         _displayPath = phone;
466                         _storageType = MEMORY_TYPE_PHONE;
467                 }
468                 break;
469
470                 case MEMORY_TYPE_SD_CARD:
471                 {
472                         _displayPath = sdCard;
473                         _storageType = MEMORY_TYPE_SD_CARD;
474                 }
475                 break;
476
477                 case MEMORY_TYPE_EXTERNAL:
478                 {
479                         _displayPath = external;
480                         _storageType = MEMORY_TYPE_EXTERNAL;
481                 }
482                 break;
483
484                 default:
485                 {
486                 }
487                 break;
488                 }
489
490         }
491
492         r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
493         TryCatch(r == E_SUCCESS, , "Failed to get values from AppRegistry");
494
495         _flagViewAsStatus = listViewDisplayType;
496
497         if (_pMoreContextMenu != null)
498         {
499                 _pMoreContextMenu->SetShowState(false);
500         }
501
502
503
504 #if 0
505         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
506 #endif
507
508
509         if (pArgs != null)
510         {
511                 pReceived_Filename = static_cast< String* >(pArgs->GetAt(0));
512
513                 received_Filepath = FolderNavigationPresentationModel::GetCurrentPath();
514                 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
515
516                 if (pReceived_Filename != null)
517                 {
518                         check.Append(*pReceived_Filename);
519                         __pHeader = GetHeader();
520
521                         if (__pHeader != null)
522                         {
523                                 __pHeader->SetTitleText(check);
524                                 __pHeader->Invalidate(true);
525                         }
526                 }
527
528                 __currentDirectoryPath.Clear();
529                 __currentDirectoryPath.Append(received_Filepath);
530
531                 //Get the Directory Entries for the received Filepath.
532                 if (_pFolderEntryPM != null)
533                 {
534                         _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
535                         _pFolderEntryPM->SetFolderEntryPath(received_Filepath);
536                         _pFilenames = _pFolderEntryPM->GetFolderEntryList();
537                         TryCatch(_pFilenames != null, , "Failed to allocate Memory to __pFilenames");
538                 }
539
540
541                 if (_pThumbnailItemProvider != null)
542                 {
543                         _pThumbnailItemProvider->SetCreateItemSource(sourceForm);
544                         _pThumbnailItemProvider->SetFolderEntryProvider(this);
545                 }
546
547                 SetNextDisplayPath();
548                 SetHeaderTitleText(__currentDirectoryPath);
549
550         }
551         else
552         {
553                 //Empty Arguments Received.
554
555                 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
556                 parentPath.Append(__currentDirectoryPath);
557
558                 SetNextDisplayPath();
559                 SetHeaderTitleText(__currentDirectoryPath);
560
561                 if (_pFolderEntryPM != null)
562                 {
563                         _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
564                         _pFolderEntryPM->SetFolderEntryPath(parentPath);
565                         _pFilenames = _pFolderEntryPM->GetFolderEntryList();
566                         TryCatch(_pFilenames != null, , "Failed to allocate Memory to Filenames ArrayList");
567                 }
568
569                 if (_pThumbnailItemProvider != null)
570                 {
571                         _pThumbnailItemProvider->SetCreateItemSource(sourceForm);
572                         _pThumbnailItemProvider->SetFolderEntryProvider(this);
573                 }
574         }
575
576         //_pFileListPM->SetFileEventListener(this);
577         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
578
579
580         if (pArgs != null)
581         {
582                 pArgs->RemoveAll(false);
583                 delete pArgs;
584         }
585         return;
586
587         CATCH:
588         if (pArgs != null)
589         {
590                 pArgs->RemoveAll(false);
591                 delete pArgs;
592         }
593         return;
594 }
595
596 void
597 SubFolderFileListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
598 {
599         AppLogDebug("ENTER");
600
601         result r = E_SUCCESS;
602         SceneManager* pSceneManager = null;
603         pSceneManager = SceneManager::GetInstance();
604
605         switch (actionId)
606         {
607         case IDA_BTN_HOME:
608         {
609                 //Navigate to the TopFolderFileListForm.
610                 String homeRootPath;
611                 homeRootPath.Append(__currentDirectoryPath);
612
613                 while ((homeRootPath != BasePresentationModel::GetMediaPath()) && (homeRootPath != BasePresentationModel::GetSdCardPath()))
614                 {
615                         FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
616                         homeRootPath.Clear();
617                         homeRootPath = FolderNavigationPresentationModel::GetParentPath();
618                 }
619
620                 FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
621                 //ShowHomeView();
622                 if (CheckSearchHistory())
623                 {
624                         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
625                         //TryCatch(r == E_SUCCESS, , "scene transition failed");
626                 }
627                 else
628                 {
629                         r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
630                         //TryCatch(r == E_SUCCESS, , "scene transition failed");
631                 }
632         }
633         break;
634
635         case IDA_BTN_UP:
636         {
637                 bool searchHistory = CheckSearchHistory();
638                 String previousPath;
639                 //Navigate to the ParentForm.
640                 if (searchHistory)
641                 {
642                         __previousSceneName = SceneManager::GetInstance()->GetCurrentSceneId();
643                         AppLogDebug("__previousSceneName is %S", __previousSceneName.GetPointer());
644                         previousPath = FolderNavigationPresentationModel::GetCurrentPath();
645                         AppLogDebug("previousPath is %S", previousPath.GetPointer());
646                         FolderNavigationPresentationModel::SetSearchPreviousPath(previousPath);
647                 }
648                 ShowParentDirectoryView();
649         }
650         break;
651
652         case IDA_CONTEXT_MENU_HIDE_EXTENSION:
653         {
654                 __currentDirectoryPath.Clear();
655                 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
656                 HideFileExtension();
657         }
658
659         break;
660
661         case IDA_CONTEXT_MENU_SHOW_EXTENSION:
662         {
663                 __currentDirectoryPath.Clear();
664                 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
665                 ShowFileExtension();
666         }
667
668         break;
669
670         default:
671         {
672                 SubBaseOnActionPerformed(source, actionId);
673         }
674         break;
675         }
676         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
677 }
678
679 void
680 SubFolderFileListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
681                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
682 {
683         ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
684
685         DeviceManager::RemoveAllDeviceEventListeners();
686
687         if (_pIconListView != null)
688         {
689                 _pIconListView->RemoveGestureDetector(*_pLongPressGestureDetector);
690         }
691
692         TryReturn(_pFolderEntryPM!=null, , "FolderEntryPresentationModel is NULL") ;
693         _pFolderEntryPM->StopThumbnailManager(true);
694         _pFolderEntryPM->SetCurrentReqId(0);
695
696         if(_pFileEventManager != null)
697         {
698                 _pFileEventManager->RemovePath(__currentDirectoryPath);
699                 delete _pFileEventManager;
700                 _pFileEventManager = null;
701         }
702 }
703
704
705 void
706 SubFolderFileListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
707 {
708         //When state is changed, push the parent filepath to the stack and save the selected path as
709         //root path so that listview can be refreshed to this path the next time. If Up button is click in
710         //the mean time, refresh the root path to be pushed to the parent path (changed in ShowParentView())
711
712         AppLogDebug("ENTER");
713         String nextFilename;
714         String tempRootMediaPath;
715         String filePathToPush;
716         String searchPath;
717         bool searchHistory = false;
718         //result r = E_FAILURE;
719         DirectoryEntry* pDirStr = null;
720
721         ArrayList* pArgs = new (std::nothrow) ArrayList();
722         pArgs->Construct();
723
724
725         SceneManager* pSceneManager = SceneManager::GetInstance();
726         SceneId currentSceneId = pSceneManager->GetCurrentSceneId();
727
728         if (_pFilenames != null)
729         {
730                 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
731                 if (pDirStr != null)
732                 {
733                         //temprootmediapath gives the full file path of the selected item
734                         tempRootMediaPath = pDirStr->GetFullFilePath();
735
736                         if (pDirStr->IsDirectory())
737                         {
738                                 //Append the name of the file to the existing path
739                                 nextFilename = pDirStr->GetFileName();
740                                 _currentFileName.Clear();
741                                 _currentFileName = pDirStr->GetFileName();
742
743                                 //tempRootMediaPath.Append(L"/");
744                                 //Set the full file path as future parent filepath, changed when Up button is
745                                 //clicked..
746                                 if (__currentDirectoryPath != null)
747                                 {
748                                         __currentDirectoryPath.Clear();
749                                         //__currentDirectoryPath.Append(tempRootMediaPath);
750                                         __currentDirectoryPath = pDirStr->GetFullFilePath();
751                                 }
752                                 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
753
754                                 pArgs->Add(&nextFilename);
755
756                                 searchHistory = CheckSearchHistory();
757                                 if (searchHistory)
758                                 {
759                                         searchPath = FolderNavigationPresentationModel::GetParentPath();
760                                         FolderNavigationPresentationModel::SetSearchPreviousPath(searchPath);
761                                 }
762
763                                 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
764                         }
765                         else
766                         {
767                                 _indexTracker = index;                  //For OnFileEventOccured (RemoveCacheEntry)
768                                 _pathOfSelectedFile = tempRootMediaPath;
769                                 //It's not a directory, Launch the AppControl.
770                                 if (_pathOfSelectedFile.EndsWith(L".tpk") || _pathOfSelectedFile.EndsWith(L".wgt"))
771                                 {
772                                         String* pFileUriScheme = new (std::nothrow) String(L"file://");
773                                         pFileUriScheme->Append(_pathOfSelectedFile);
774
775                                         AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
776                                         delete pFileUriScheme;
777                                 }
778                                 else
779                                 {
780                                         CustomAppControl* pCustomAppControl = CustomAppControl::GetInstance();
781                                         if (pCustomAppControl != null)
782                                         {
783                                                 __counter = index;
784
785                                                 pCustomAppControl->SetAppControlListener(null);
786                                                 fileForAppControl = _pathOfSelectedFile;
787                                                 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(_pathOfSelectedFile);
788                                                 if (pAppControlInUse != null)
789                                                         CustomAppControl::SetAppControlInUse(pAppControlInUse);
790                                         }
791                                 }
792                         }
793                 }
794         }
795
796         return;
797
798 }
799
800 result
801 SubFolderFileListForm::ShowHomeView(void)
802 {
803         AppLogDebug("Enter");
804         SceneManager* pSceneManager = null;
805         result r = E_SUCCESS;
806         pSceneManager = SceneManager::GetInstance();
807         if (pSceneManager != null)
808         {
809                 if (CheckSearchHistory())
810                 {
811                         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
812                         TryCatch(r == E_SUCCESS, , "scene transition failed");
813                 }
814                 else
815                 {
816                         r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
817                         TryCatch(r == E_SUCCESS, , "scene transition failed");
818                 }
819         }
820
821         if (_pFolderEntryPM != null)
822         {
823                 _pFolderEntryPM->InitThumbnailManager();
824         }
825
826         AppLogDebug("Exit");
827         return r;
828 CATCH:
829         return r;
830 }
831
832 void
833 SubFolderFileListForm::SetParentDisplayPath(void)
834 {
835         //Sets the display path for the parent directory using the current path.
836
837         String dislayPath;
838         String delim(L"/");
839         String parentDisplayPath;
840         String token;
841 #if 0
842         DataBindingContext* pContext = null;
843         pContext = GetDataBindingContextN();
844
845         if (pContext != null)
846         {
847                 //Update binding on the source to fetch the current display path.
848                 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_SOURCE);
849         }
850 #endif
851
852         StringTokenizer tokenizer(_displayPath, delim);
853
854         //Use a string tokenizer to get the filepath until it's the last token, break the loop when
855         //it is the last token
856         while (tokenizer.HasMoreTokens())
857         {
858                 int tokenCount = tokenizer.GetTokenCount();
859
860                 if (tokenCount != 1)
861                 {
862                         tokenizer.GetNextToken(token);
863                         parentDisplayPath.Append(token);
864                         parentDisplayPath.Append(L"/");
865                 }
866                 else
867                 {
868                         break;
869                 }
870         }
871
872         //Set the display path to that of the generated filepath from the tokenizer
873         _displayPath = parentDisplayPath;
874
875         if (_pLabelDisplayPath != null)
876         {
877                 _pLabelDisplayPath->SetText(_displayPath);
878                 _pLabelDisplayPath->Invalidate(true);
879         }
880 #if 0
881         if (pContext != null)
882         {
883                 //Update Binding on the Target control to display the currently constructed path.
884                 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
885         }
886
887         if (pContext != null)
888         {
889                 delete pContext;
890         }
891 #endif
892 }
893
894 void
895 SubFolderFileListForm::ShowParentDirectoryView(void)
896 {
897         AppLogDebug("ENTER");
898         //Shows the files of the above/parent directory
899         CreateItemSource sourceForm = CREATE_ITEM_SOURCE_NONE;
900         int fileCount = 0;
901         int folderCount = 0;
902
903         result r = E_SUCCESS;
904
905         String displayPath;
906         String pPoppedPath;
907         String ParentPath;
908         String backUpCurrentPath;
909
910         backUpCurrentPath = FolderNavigationPresentationModel::GetCurrentPath();
911
912         displayPath = defaultPhoneBody;
913         displayPath.Append("/");
914
915
916         if (backUpCurrentPath == BasePresentationModel::GetMediaPath() || backUpCurrentPath == BasePresentationModel::GetSdCardPath() || backUpCurrentPath == BasePresentationModel::GetUsbPath())
917         {
918                 //It is the homeview, so call showhomeview
919                 r = ShowHomeView();
920                 TryCatch(r == E_SUCCESS, , "scene transition failed");
921                 //return;
922         }
923         else
924         {
925                 ParentPath = FolderNavigationPresentationModel::GetParentPath();
926
927                 //RemovePath to remove FileEventListener
928                 if(_pFileEventManager != null)
929                 {
930                         _pFileEventManager->RemovePath(__currentDirectoryPath);
931                 }
932                 __currentDirectoryPath.Clear();
933                 __currentDirectoryPath.Append(ParentPath);
934
935                 //AddPath to add FileEventListener for Parent Directory Path
936                 if(_pFileEventManager != null)
937                 {
938                         _pFileEventManager->AddPath(__currentDirectoryPath, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
939                 }
940
941                 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
942
943                 if (_pFolderEntryPM != null)
944                 {
945                         _pFolderEntryPM->GetFolderEntryCount(__currentDirectoryPath, folderCount, fileCount);
946                 }
947
948                 SetParentDisplayPath();
949                 SetHeaderTitleText(ParentPath);
950
951                 //Remove the current files from the filenames list
952                 if (_pFolderEntryPM != null)
953                 {
954                         //__pContentManager->ClearList();
955                         _pFolderEntryPM->SetFolderEntryPath(ParentPath);
956                         _pFilenames = _pFolderEntryPM->GetFolderEntryList();
957                         TryCatch(_pFilenames != null, , "Failed to fetch ArrayList from the ContentBrowser!");
958
959                         sourceForm =  _pFolderEntryPM->GetSourceForm();
960                         AppLogDebug("Current Source Form is : %d",sourceForm);
961
962                         _pFolderEntryPM->InitThumbnailManager();
963
964                 }
965
966                 SetFooterVisibility();
967
968                 //Get the files in the parent path of the current view
969
970                 //Update the icon list to view the files of the parent directory
971                 if (_pListView != null && _pListView->IsVisible())
972                 {
973                         r = _pListView->UpdateList();
974                 }
975
976                 if (_pIconListView != null && _pIconListView->IsVisible())
977                 {
978                         r = _pIconListView->UpdateList();
979                 }
980         }
981         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
982         return;
983
984 CATCH:
985         FolderNavigationPresentationModel::SetCurrentFilePath(backUpCurrentPath);
986 }
987
988
989 void
990 SubFolderFileListForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
991 {
992         AppLogDebug("Enter");
993
994         Integer* pFileProcessingResult = null;
995         String cachePath;
996
997         TryCatch(pArgs != null, , "Argument list received is invalid!");
998         pFileProcessingResult = (Integer*) pArgs->GetAt(0);
999
1000         TryCatch(pFileProcessingResult != null, , "FileProcessing Result  list is invalid!");
1001
1002         switch (pFileProcessingResult->ToInt())
1003         {
1004                 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1005                 {
1006                         AppLogDebug("FILE DELETION SUCCESSFUL");
1007                         HideFileProgressingPopup();
1008                 }
1009                 break;
1010
1011                 case FILE_MANAGING_RESULT_DELETING_FAILED:
1012                 {
1013                         HideFileProgressingPopup();
1014                 }
1015                 break;
1016                 case FILE_MANAGING_RESULT_THREAD_STOP:
1017                 {
1018                         HideFileProgressingPopup();
1019                 }
1020                 break;
1021                 default:
1022                 {
1023                         //Do Nothing.
1024                 }
1025                 break;
1026         }
1027
1028         _pFolderEntryPM->InitThumbnailManager();                        //for thumbnail issues/disappering images/defulat images etc...
1029
1030         SetFooterVisibility();
1031 CATCH:
1032         if (pArgs != null)
1033         {
1034                 pArgs->RemoveAll(true);
1035                 delete pArgs;
1036         }
1037         ///return this;
1038 }
1039
1040 void
1041 SubFolderFileListForm::OnDataBindingSourceUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
1042 {
1043         //Empty Implementation.
1044 }
1045
1046 void
1047 SubFolderFileListForm::OnDataBindingTargetUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
1048 {
1049         //Empty Implementation.
1050 }
1051
1052 void
1053 SubFolderFileListForm::OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Ui::DataBindingDestinationType destType)
1054 {
1055         //Empty Implementation.
1056 }
1057
1058 void
1059 SubFolderFileListForm::OnFileEventExecuted(const Tizen::Base::String& path, const unsigned long eventId)
1060 {
1061         AppLogDebug("ENTER");
1062
1063         int badgeNumber = 0;
1064         result r = E_SUCCESS;
1065
1066         //      Tizen::Shell::NotificationManager* pNotiMgr = null;
1067
1068         NotificationManager* pNotiMgr = null;
1069         AppResource* pAppResource = null;
1070         pAppResource = UiApp::GetInstance()->GetAppResource();
1071         TryCatch(pAppResource != null, , "Failed to fetch AppResource");
1072
1073         pNotiMgr = new (std::nothrow) NotificationManager();
1074         TryCatch(pNotiMgr != null, , "Failed to fetch AppNotificationManager");
1075
1076         pNotiMgr->Construct();
1077         badgeNumber = pNotiMgr->GetBadgeNumber();
1078         badgeNumber++;
1079
1080         if (_pFolderEntryPM != null)
1081         {
1082                 //_pFolderEntryPM->SetFileEventListener(null);
1083                 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1084                 TryCatch(_pFilenames != null, , "File Names List retrieval failed");
1085         }
1086
1087         switch (eventId)
1088         {
1089         case FILE_EVENT_TYPE_CREATE:
1090         {
1091                 if (_pListView != null && _pListView->IsVisible())
1092                 {
1093                         _pListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1094                 }
1095                 if (_pIconListView != null && _pIconListView->IsVisible())
1096                 {
1097                         _pIconListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1098                 }
1099
1100         }
1101         break;
1102
1103         case FILE_EVENT_TYPE_DELETE:
1104         {
1105                 if (_pListView != null && _pListView->IsVisible())
1106                 {
1107                         _pListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
1108                 }
1109                 if (_pIconListView != null && _pIconListView->IsVisible())
1110                 {
1111                         if (_pThumbnailItemProvider != null)
1112                         {
1113                                 __counter = _pThumbnailItemProvider->GetPressedIndex();
1114                         }
1115                         _pIconListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
1116                 }
1117
1118         }
1119         break;
1120
1121         case FILE_EVENT_TYPE_DELETE_SELF:
1122         {
1123                 ShowHomeView();
1124         }
1125         break;
1126
1127         default:
1128         {
1129                 //Do Nothing.
1130         }
1131         break;
1132         }
1133
1134         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1135
1136         if (pNotiMgr != null)
1137         {
1138                 delete pNotiMgr;
1139                 pNotiMgr = null;
1140         }
1141         return;
1142
1143 CATCH:
1144         if (pNotiMgr != null)
1145         {
1146                 delete pNotiMgr;
1147                 pNotiMgr = null;
1148         }
1149         return;
1150 }
1151
1152 void
1153 SubFolderFileListForm::SetHeaderTitleText(Tizen::Base::String& filePath)
1154 {
1155         String token;
1156         String parentFileName;
1157         String delimiter(L"/");
1158         StringTokenizer tokenizer(filePath, delimiter);
1159
1160         AppResource* pAppResource = null;
1161
1162         pAppResource = UiApp::App::GetInstance()->GetAppResource();
1163
1164         if (filePath == BasePresentationModel::GetMediaPath())
1165         {
1166                 if (pAppResource != null)
1167                 {
1168                         pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
1169                 }
1170         }
1171         else if (filePath == BasePresentationModel::GetSdCardPath())
1172         {
1173                 if (pAppResource != null)
1174                 {
1175                         pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
1176                 }
1177         }
1178         else
1179         {
1180                 while (tokenizer.HasMoreTokens())
1181                 {
1182                         int tokenCount = tokenizer.GetTokenCount();
1183
1184                         if (tokenCount == 1)
1185                         {
1186                                 tokenizer.GetNextToken(parentFileName);
1187                         }
1188                         else
1189                         {
1190                                 tokenizer.GetNextToken(token);
1191                         }
1192                 }
1193         }
1194
1195         __pHeader = GetHeader();
1196         if (__pHeader != null)
1197         {
1198                 if (!parentFileName.IsEmpty())
1199                 {
1200                         __pHeader->SetTitleText(parentFileName);
1201                         __pHeader->Invalidate(true);
1202                 }
1203         }
1204 }
1205
1206 void
1207 SubFolderFileListForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
1208 {
1209         bool setMediaPath = false;
1210         MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
1211         String unmounted = sdCardStatusUnmounted;
1212         String removed = usbDeviceStatusRemoved;
1213         String currentPath;
1214
1215         SceneManager* pSceneManager = null;
1216
1217         if (state == unmounted || state == removed)
1218         {
1219                 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
1220                 if (state == unmounted)
1221                 {
1222                         if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
1223                         {
1224                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1225                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1226                                 setMediaPath = true;
1227                         }
1228                 }
1229
1230                 if (state == removed)
1231                 {
1232                         if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
1233                         {
1234                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1235                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1236                                 setMediaPath = true;
1237                         }
1238                 }
1239
1240                 if (setMediaPath)
1241                 {
1242                         pSceneManager = SceneManager::GetInstance();
1243                         if (pSceneManager != null)
1244                         {
1245                                 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
1246                         }
1247                 }
1248         }
1249 }
1250
1251 void
1252 SubFolderFileListForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1253 {
1254         ComponentType currentDeviceType;
1255         switch (deviceType)
1256         {
1257         case StorageCard:
1258         {
1259                 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1260         }
1261         break;
1262
1263         case UsbClient:
1264         {
1265                 currentDeviceType = COMPONENT_TYPE_USB;
1266         }
1267         break;
1268
1269         default:
1270         {
1271                 //Do Nothing.
1272         }
1273         break;
1274         }
1275         OnDeviceChange(currentDeviceType, state);
1276 }
1277
1278 void
1279 SubFolderFileListForm::OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId &currentSceneId)
1280 {
1281         AppLogDebug("Enter");
1282
1283         AppRegistry* pAppRegistry = null;
1284         String sortbyKeyName(L"SortBy");
1285         int sortStyle = SORT_BY_TYPE_DATE_RECENT;
1286         int fileCount = 0;
1287         int folderCount = 0;
1288
1289         SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1290         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1291
1292         _pLongPressGestureDetector->AddLongPressGestureEventListener(*this);
1293         if (_pIconListView != null)
1294         {
1295                 _pIconListView->AddGestureDetector(*_pLongPressGestureDetector);
1296         }
1297
1298         if (_pFileEventManager != null)
1299         {
1300                 delete _pFileEventManager;
1301                 _pFileEventManager = null;
1302
1303         }
1304         _pFileEventManager = new (std::nothrow)FileEventManager();
1305         _pFileEventManager->Construct(*this);
1306
1307         _pFileEventManager->AddPath(__currentDirectoryPath, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
1308
1309         _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(),folderCount, fileCount);
1310
1311         if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1312         {
1313                 if (_renameOrCreate == SELECT_RENAME)
1314                 {
1315                         pAppRegistry->Get(sortbyKeyName, sortStyle);
1316
1317                         if (sortStyle == SORT_BY_TYPE_NAME_ASCENDING || sortStyle == SORT_BY_TYPE_NAME_DESCENDING
1318                                         || sortStyle == SORT_BY_TYPE_DATE_OLDEST || sortStyle == SORT_BY_TYPE_DATE_RECENT)
1319                         {
1320                                 _pFolderEntryPM->SetFolderEntryPath(FolderNavigationPresentationModel::GetCurrentPath());
1321                                 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1322
1323                                 if (_pListView != null && _pListView->IsVisible())
1324                                 {
1325                                         _pListView->UpdateList();
1326                                         _pListView->ScrollToItem(0);
1327                                 }
1328                                 if (_pIconListView != null && _pIconListView->IsVisible())
1329                                 {
1330                                         _pIconListView->UpdateList();
1331                                         _pIconListView->ScrollToItem(0);
1332                                 }
1333                                 _pFolderEntryPM->InitThumbnailManager();
1334                         }
1335                         else
1336                         {
1337                                 if (_pListView != null && _pListView->IsVisible())
1338                                         _pListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1339                                 if (_pIconListView != null && _pIconListView->IsVisible())
1340                                         _pIconListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1341                         }
1342
1343                         SetFooterVisibility();
1344
1345                         return;
1346                 }
1347         }
1348
1349         if (CheckSearchHistory())
1350         {
1351                 __previousSceneName = previousSceneId;
1352         }
1353
1354         SwitchViewType();
1355
1356         SetFooterVisibility();
1357
1358         if (_pFilenames->GetCount() == 0)
1359         {
1360                 _bIsDirectoryEmpty = true;
1361         }
1362         else
1363         {
1364                 _bIsDirectoryEmpty = false;
1365         }
1366
1367         if (_pFolderEntryPM != null)
1368         {
1369                 _pFolderEntryPM->InitThumbnailManager();
1370         }
1371 }
1372
1373 void
1374 SubFolderFileListForm::OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId &currentSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId)
1375 {
1376         //Empty Implementation.
1377 }
1378
1379 void
1380 SubFolderFileListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1381 {
1382         AppLogDebug("ENTER");
1383         switch (orientationStatus)
1384         {
1385         case ORIENTATION_STATUS_LANDSCAPE:
1386         {
1387                 SceneManager* pSceneManager = null;
1388                 pSceneManager = SceneManager::GetInstance();
1389                 if (pSceneManager != null)
1390                 {
1391                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), null);
1392                 }
1393         }
1394         break;
1395         default:
1396         break;
1397         }
1398 }
1399
1400 void
1401 SubFolderFileListForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int      eventId)
1402 {
1403         AppLogDebug("TopMostFolderFileListForm::OnFileEventOccured:%S", path.GetPointer());
1404
1405         //Scan the directory
1406         //RequestId reqId;
1407         HashMap* pCacheList = null;
1408         DirectoryEntry* pCurrentEntry = null;
1409         bool cacheKeyStatus = false;
1410         String cachePath;
1411
1412         //result r = ContentManager::ScanDirectory(__currentDirectoryPath,true,null,reqId);
1413         //AppLogDebug("ContentManager::ScanDirectory:%s", GetErrorMessage(r));
1414
1415         if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1416         {
1417                 _bBackFromAppControl = true;
1418                 if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM))
1419                 {
1420                         AppLogDebug("Items to delete: %d", _indexTracker);
1421                         pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1422                         if (pCacheList != null)
1423                         {
1424                                 pCurrentEntry = static_cast<DirectoryEntry*>(_pFilenames->GetAt(_indexTracker));
1425
1426                                 if (pCurrentEntry != null)
1427                                 {
1428                                         cachePath = pCurrentEntry->GetFullFilePath();
1429                                 }
1430
1431                                 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1432
1433                                 if (cacheKeyStatus)
1434                                 {
1435                                         CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1436                                 }
1437                         }
1438                 }
1439                 if (_pFolderEntryPM!=null)
1440                 {
1441                          if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) )
1442                                  _pFilenames->RemoveAt(_indexTracker);
1443                          else
1444                                  _pFolderEntryPM->RefreshFolderEntries();
1445                 }
1446
1447                 if (_pListView != null && _pListView->IsVisible())
1448                 {
1449                         _pListView->UpdateList();
1450                 }
1451
1452                 if (_pIconListView != null && _pIconListView->IsVisible())
1453                 {
1454                         _pIconListView->UpdateList();
1455                 }
1456
1457                 if (_pFolderEntryPM!=null && ( (events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_MOVED_TO)))
1458                 {
1459                         _pFolderEntryPM->InitThumbnailManager();
1460                 }
1461         }
1462 }
1463
1464 void
1465 SubFolderFileListForm::OnContentScanCompleted (RequestId reqId, const Tizen::Base::String &scanPath, result r)
1466 {
1467         AppLogDebug("Enter");
1468         AppLogDebug("Exit");
1469 }
1470 void
1471 SubFolderFileListForm::OnAppControlCompleted(void)
1472 {
1473         SubBaseFolderEntryForm::OnAppControlCompleted();
1474 }