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