57df0d8fe0d6eafb57aaadf43dad46d30db23e98
[apps/osp/MyFiles.git] / src / MfSubFolderMoveCopy.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: MfSubFolderMoveCopy.cpp
19  * @brief: This file contains the implementation SubFolderMoveCopy class, which loads the form which implements the Copy
20  * and Move Functionalities on the SubDirectoryForm.
21  */
22
23 #include "MfSubFolderMoveCopy.h"
24 #include "MfTypes.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::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::Locales;
33 using namespace Tizen::Media;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39
40 SubFolderMoveCopy::SubFolderMoveCopy(void)
41 : _pBaseItemProvider(null)
42 , _pFolderEntryPM(null)
43 , _pFileManager(null)
44 , _pThumbnailItemProvider(null)
45 , _pThumbnailManager(null)
46 , _pFileNames(null)
47 , _pFileProgressingCancelButton(null)
48 , __pHomeButton(null)
49 , __pUpButton(null)
50 , _pMoreContextMenu(null)
51 , _pFooter(null)
52 , _pCopy(null)
53 , _pCreateFolder(null)
54 , _pMove(null)
55 , _pPaste(null)
56 , __pHeader(null)
57 , _pIconListView(null)
58 , _pDisplayPathLabel(null)
59 , _pFileProgressingHeaderLabel(null)
60 , _pFileProgressingLabel(null)
61 , _pListView(null)
62 , _pFileProgressingPopup(null)
63 , _pFileProgressingProgress(null)
64 {
65         __updateFooterCheck = false;
66         __fileManagedCount = 0;
67         __storageType = MEMORY_TYPE_NONE;
68         __viewType = 0;
69         setMediaPath = false;
70 }
71
72 SubFolderMoveCopy::~SubFolderMoveCopy(void)
73 {
74         if (__pHomeButton != null)
75         {
76                 delete __pHomeButton;
77         }
78
79         if (__pUpButton != null)
80         {
81                 delete __pUpButton;
82         }
83 }
84
85 bool
86 SubFolderMoveCopy::Initialize(void)
87 {
88         Form::Construct(L"IDL_SUB_FOLDER_MOVE_COPY");
89         return true;
90 }
91
92 result
93 SubFolderMoveCopy::OnInitializing(void)
94 {
95         AppLogDebug("ENTER");
96         result r = E_SUCCESS;
97         String btnHome;
98         String btnUp;
99         Color formBgColor = GetBackgroundColor();
100
101         AppResource* pAppResource = null;
102         Bitmap* pBitmapHomeButton = null;
103         Bitmap* pBitmapUpButton = null;
104         Bitmap* pBitmapHomeButtonPress = null;
105         Bitmap* pBitmapUpButtonPress = null;
106
107         __fileManagedCount = 0;
108         __updateFooterCheck = false;
109
110         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
111
112         int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_MOVE_COPY_FORM;
113         CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_BASE_MOVE_COPY;
114
115         pAppResource = UiApp::GetInstance()->GetAppResource();
116         TryCatch(pAppResource != null, , "Resource manager not found!");
117
118         pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
119         pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
120         pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
121         pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
122
123         pAppResource->GetString(L"IDS_MF_BUTTON_HOME", btnHome);
124         pAppResource->GetString(L"IDS_MF_TAB_UP", btnUp);
125         __pHeader = GetHeader();
126         if (__pHeader != null)
127         {
128                 __pHomeButton = new (std::nothrow) ButtonItem();
129                 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
130                 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
131                 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
132
133                 __pUpButton = new (std::nothrow) ButtonItem();
134                 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
135                 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
136                 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
137
138                 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
139                 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
140                 __pHeader->AddActionEventListener(*this);
141         }
142
143         _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
144         TryCatch(_pFolderEntryPM != null, , "__pContentManager not found!");
145         _pFolderEntryPM->Construct();
146         _pFolderEntryPM->SetSourceForm(createitemsource);
147
148         _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
149         TryCatch(_pFileManager != null, , "File Manager not found!");
150
151         if (_pThumbnailItemProvider == null)
152         {
153                 _pThumbnailItemProvider = new (std::nothrow) ThumbnailItemProviderAndListener(_rootPath, sourceForm);
154                 TryCatch(_pThumbnailItemProvider != null, , "Failed to allocate memory to thumbnail provider");
155                 _pThumbnailItemProvider->SetFolderEntryProvider(this);
156                 _pThumbnailItemProvider->SetFooterItemStateChangeListener(this);
157
158         }
159
160         _pDisplayPathLabel = static_cast< Label* >(GetControl("IDC_LABEL_DISPLAY_PATH"));
161         TryCatch(_pDisplayPathLabel != null, , "__pDisplayPathLabel is null");
162
163         _pBaseItemProvider = new (std::nothrow) BaseItemProvider();
164         TryCatch(_pBaseItemProvider != null, , "Failed to allocate base itemprovider");
165         _pBaseItemProvider->Construct();
166         _pBaseItemProvider->SetSourceForm(createitemsource);
167         _pBaseItemProvider->SetFolderEntryProvider(this);
168
169         _pListView = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
170         TryCatch(_pListView != null, , "list view is null");
171         _pListView->AddListViewItemEventListener(*this);
172         _pListView->SetItemProvider(*_pBaseItemProvider);
173
174         _pIconListView = static_cast< IconListView* >(GetControl(L"IDC_ICONLISTVIEW_SUB_THUMBNAILS"));
175         if (_pIconListView != null)
176         {
177                 _pIconListView->SetShowState(false);
178                 r = _pIconListView->SetItemProvider(*_pThumbnailItemProvider);
179                 _pIconListView->AddIconListViewItemEventListener(*_pThumbnailItemProvider);
180         }
181
182 #if 0
183         DataBindingContext* pContext = null;
184
185         pContext = GetDataBindingContextN();
186         pContext->Bind(L"ID_DISPLAY_PATH", L"IDC_LABEL_DISPLAY_PATH", L"text", __displayPath, DATA_BINDING_DATA_TYPE_STRING, DATA_BINDING_FLOW_ONE_WAY, DATA_BINDING_TRIGGER_EXPLICIT, this, null, null);
187         delete pContext;
188
189 #endif
190
191         delete pBitmapHomeButton;
192         delete pBitmapUpButton;
193         delete pBitmapHomeButtonPress;
194         delete pBitmapUpButtonPress;
195         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
196
197         return r;
198 CATCH:
199
200         if (__pHomeButton != null)
201         {
202                 delete __pHomeButton;
203                 __pHomeButton = null;
204         }
205
206         if (__pUpButton != null)
207         {
208                 delete __pUpButton;
209                 __pUpButton = null;
210         }
211
212         if (_pDisplayPathLabel != null)
213         {
214                 delete _pDisplayPathLabel;
215                 _pDisplayPathLabel = null;
216         }
217
218         if (_pListView != null)
219         {
220                 delete _pListView;
221                 _pListView = null;
222         }
223
224         if (pBitmapHomeButton != null)
225         {
226                 delete pBitmapHomeButton;
227                 pBitmapHomeButton = null;
228         }
229
230         if (pBitmapUpButton != null)
231         {
232                 delete pBitmapUpButton;
233                 pBitmapUpButton = null;
234         }
235         if (pBitmapHomeButtonPress != null)
236         {
237                 delete pBitmapHomeButtonPress;
238                 pBitmapHomeButtonPress = null;
239         }
240         if (pBitmapUpButtonPress != null)
241         {
242                 delete pBitmapUpButtonPress;
243                 pBitmapUpButtonPress = null;
244         }
245         return r;
246 }
247
248 void
249 SubFolderMoveCopy::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
250 {
251         AppLogDebug("ENTER");
252         Bitmap* pBitmapCreateFolderContextItem = null;
253         String btnCreateFoler;
254         AppResource* pAppResource = null;
255         pAppResource = UiApp::GetInstance()->GetAppResource();
256
257         if (pAppResource != null)
258         {
259                 pAppResource->GetString(L"IDS_COM_BODY_CREATE_FOLDER", btnCreateFoler);
260                 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
261         }
262
263         switch (actionId)
264         {
265         case IDA_BTN_HOME:
266         {
267                 ShowHomeView();
268         }
269         break;
270
271         case IDA_BTN_UP:
272         {
273                 LoadParentForm();
274         }
275         break;
276         case IDA_BTN_PASTE:
277         {
278                 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
279                 _rootPath = FolderNavigationPresentationModel::GetCurrentPath();
280                 _pFileManager->CopyFolderEntries(FILE_EXISTING_OPERATIONID_NONE);
281         }
282         break;
283
284         case IDA_BTN_MOVE:
285         {
286                 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
287                 _rootPath = FolderNavigationPresentationModel::GetCurrentPath();
288                 _pFileManager->MoveFolderEntries(FILE_EXISTING_OPERATIONID_NONE);
289         }
290         break;
291         case IDA_BTN_CREATE_FOLDER:
292         {
293                 LoadCreateFolderForm();
294         }
295         break;
296         case IDA_BTN_MORE:
297         {
298                 _pMoreContextMenu->RemoveAllItems();
299                 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
300                 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
301                 _pMoreContextMenu->AddItem(btnCreateFoler, IDA_BTN_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
302                 _pMoreContextMenu->SetShowState(true);
303                 _pMoreContextMenu->Show();
304         }
305         break;
306         case IDA_BTN_ANIMATION_POPUP_CANCEL:
307         {
308                 //HideFileProgressingPopup();
309                 _pFileManager->ForceStopWorkerThread();
310         }
311         break;
312         default:
313         {
314                 //SubBaseOnActionPerformed(source, actionId);
315         }
316         break;
317         }
318         AppLogDebug("EXIT");
319 }
320
321 void
322 SubFolderMoveCopy::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
323 {
324         AppLogDebug("ENTER");
325         DirectoryEntry* pDirStr = null;
326         String fileName;
327         SceneManager* pSceneManager = SceneManager::GetInstance();
328         result r = E_SUCCESS;
329         String backupRootPath = FolderNavigationPresentationModel::GetCurrentPath();
330         if (_pFileNames != null)
331         {
332                 pDirStr = static_cast< DirectoryEntry* >(_pFileNames->GetAt(index));
333                 TryCatch(pDirStr != null, , " Failed to retrieve pDirStr");
334
335                 _rootPath.Clear();
336                 _rootPath.Append(pDirStr->GetFullFilePath());
337                 if (pDirStr->IsDirectory())
338                 {
339                         FolderNavigationPresentationModel::SetCurrentFilePath(_rootPath);
340
341                         String oldLabelText = _pDisplayPathLabel->GetText();
342
343                         String newLabelText;
344                         newLabelText.Append(oldLabelText);
345                         newLabelText.Append(pDirStr->GetFileName());
346                         newLabelText.Append(L"/");
347
348                         __displayPath = newLabelText;
349
350                         //Get the header and set the title to the current Directory Name.
351                         __pHeader = GetHeader();
352                         if (__pHeader != null)
353                         {
354                                 if (!fileName.IsEmpty())
355                                 {
356                                         __pHeader->SetTitleText(fileName);
357                                         __pHeader->Invalidate(true);
358                                 }
359                         }
360
361                         ArrayList* pArg = null;
362                         pArg = new (std::nothrow) ArrayList();
363                         pArg->Construct();
364                         pArg->Add(new (std::nothrow) Integer(sourceFormOption));
365                         pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
366                         TryCatch(r == E_SUCCESS, , "scene transition failed");
367                 }
368         }
369
370         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
371         return;
372
373 CATCH:
374         FolderNavigationPresentationModel::SetCurrentFilePath(backupRootPath);
375         if (_pFolderEntryPM != null)
376         {
377                 delete _pFolderEntryPM;
378         }
379
380         return;
381 }
382
383 void
384 SubFolderMoveCopy::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
385                                                                          const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
386 {
387         AppLogDebug("ENTER");
388         result r = E_SUCCESS;
389
390         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
391
392         AppResource* pAppResource = null;
393         AppRegistry* pAppRegistry = null;
394         String viewStyleKeyName(L"ListDisplayType");
395         String phone;
396         String sdCard;
397         String externalStorage;
398         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
399         int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
400         int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_MOVE_COPY_FORM;
401
402         r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
403         AppLogDebug("AppRegistry Get Result: %s", GetErrorMessage(r));
404
405         __viewType = listViewDisplayType;
406
407         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
408         DeviceManager::GetState(DEVICE_TYPE_STORAGE_CARD,deviceState);
409 #if 0
410         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
411 #endif
412
413         pAppResource = UiApp::GetInstance()->GetAppResource();
414         TryCatch(pAppResource != null, , "Failed to fetch AppResource");
415         pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
416         pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
417         pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage);
418         phone.Append(L"/");
419         sdCard.Append(L"/");
420         externalStorage.Append(L"/");
421
422         SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
423
424         if (_pThumbnailItemProvider != null)
425         {
426                 _pThumbnailItemProvider->SetCreateItemSource(sourceForm);
427         }
428
429         if (pArgs != null)
430         {
431                 sourceFormOption = *(static_cast< Integer* >(pArgs->GetAt(0)));
432
433                 pArgs->RemoveAll(true);
434                 delete pArgs;
435                 pArgs = null;
436
437                 _rootPath.Clear();
438                 _rootPath = FolderNavigationPresentationModel::GetCurrentPath();
439                 __receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
440
441                 SetHeaderTitleText(_rootPath);
442
443                 switch (__receivedStorageType.ToInt())
444                 {
445                 case MEMORY_TYPE_PHONE:
446                 {
447                         __storageType = MEMORY_TYPE_PHONE;
448                         __displayPath = phone;
449                 }
450                 break;
451
452                 case MEMORY_TYPE_SD_CARD:
453                 {
454                         __storageType = MEMORY_TYPE_SD_CARD;
455
456                         __displayPath = sdCard;
457                 }
458                 break;
459
460                 case MEMORY_TYPE_EXTERNAL:
461                 {
462                         __storageType = MEMORY_TYPE_EXTERNAL;
463                         __displayPath = externalStorage;
464                 }
465                 break;
466
467                 default:
468                 {
469                         //Do Nothing.
470                 }
471                 break;
472                 }
473
474         }
475         //Call SetNextDisplayPath to Append the right path to the label.
476         SetNextDisplayPath();
477
478         _pFileManager->SetFileManagingListener(this);
479
480         if (_pFolderEntryPM != null)
481         {
482                 _pFolderEntryPM->SetFolderEntryPath(_rootPath);
483                 //__pFileListPM->SetFileEventListener(this);
484                 _pFileNames = _pFolderEntryPM->GetFolderEntryList();
485                 TryCatch(_pFileNames != null, , "Failed to allocate Memory to Filenames ArrayList");
486         }
487
488
489         AppLogDebug("Filenames Count %d", _pFileNames->GetCount());
490
491         _pThumbnailItemProvider->SetSourceFromOption(sourceFormOption.ToInt());
492
493         _pFooter = GetFooter();
494         if (_pFooter != null)
495         {
496                 _pFooter->RemoveAllButtons();
497                 _pFooter->RemoveAllItems();
498         }
499         CreateFooterItems();
500
501         _pFolderEntryPM->InitThumbnailManager();
502         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
503         return;
504 CATCH:
505         return;
506 }
507
508 void
509 SubFolderMoveCopy::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
510                                                                           const Tizen::Ui::Scenes::SceneId& nextSceneId)
511 {
512         ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
513         DeviceManager::RemoveAllDeviceEventListeners();
514         _pFolderEntryPM->StopThumbnailManager(true);
515 }
516
517 result
518 SubFolderMoveCopy::LoadParentForm(void)
519 {
520         AppLogDebug("ENTER");
521         SceneManager* pSceneManager = SceneManager::GetInstance();
522         result r = E_SUCCESS;
523         _rootPath = FolderNavigationPresentationModel::GetCurrentPath();
524         String previousParentPath = GetParentDirectoryName();
525
526         //FolderNavigationPresentationModel::SetCurrentFilePath(previousParentPath);
527
528         if (_rootPath == BasePresentationModel::GetMediaPath() || _rootPath == BasePresentationModel::GetSdCardPath() || _rootPath == BasePresentationModel::GetUsbPath())
529         {
530                 String __rootPath;
531                 __rootPath.Append(previousParentPath);
532                 ArrayList* pArgs = new (std::nothrow) ArrayList();
533                 r = pArgs->Construct();
534                 Integer* pSourceFromOption = new (std::nothrow) Integer(sourceFormOption);
535                 pArgs->Add(pSourceFromOption);
536                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_COPY_MOVE_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pArgs);
537         }
538         else
539         {
540                 FolderNavigationPresentationModel::SetCurrentFilePath(previousParentPath);
541                 _rootPath.Clear();
542                 _rootPath.Append(previousParentPath);
543
544                 SetParentDisplayPath();
545                 SetHeaderTitleText(_rootPath);
546
547                 if (_pFolderEntryPM != null)
548                 {
549                         //__pContentManager->ClearList();
550                         _pFolderEntryPM->SetFolderEntryPath(_rootPath);
551                         _pFileNames = _pFolderEntryPM->GetFolderEntryList();
552
553                         _pFolderEntryPM->InitThumbnailManager();
554                         TryCatch(_pFileNames != null, , "Failed to allocate Memory to __pFilenames");
555                 }
556
557
558
559                 if (_pListView != null && _pListView->IsVisible())
560                 {
561                         //Call UpdateList on __pListView
562                         r = _pListView->UpdateList();
563                 }
564
565                 if (_pIconListView != null && _pIconListView->IsVisible())
566                 {
567                         _pIconListView->UpdateList();
568                 }
569
570                 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
571         }
572         return r;
573 CATCH:
574         return r;
575 }
576
577 String
578 SubFolderMoveCopy::GetParentDirectoryName(void)
579 {
580         String pPreviousParentPath;
581         pPreviousParentPath = FolderNavigationPresentationModel::GetParentPath();
582         return pPreviousParentPath;
583 }
584
585 void
586 SubFolderMoveCopy::SetNextDisplayPath(void)
587 {
588         AppLogDebug("ENTER");
589         String dislayPath;
590         String delim(L"/");
591         String token;
592         String newDisplayPath;
593         String testPath;
594
595         String phone;
596         String sdCard;
597         String externalStorage;
598         AppResource* pAppResource = null;
599         pAppResource = UiApp::GetInstance()->GetAppResource();
600         if (pAppResource != null)
601         {
602                 pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
603                 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
604                 pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage);
605                 phone.Append(L"/");
606                 sdCard.Append(L"/");
607                 externalStorage.Append(L"/");
608         }
609         _rootPath = FolderNavigationPresentationModel::GetCurrentPath();
610         StringTokenizer StrTok(_rootPath, delim);
611         int tokenCount = 0;
612
613         switch (__storageType)
614         {
615         case MEMORY_TYPE_PHONE:
616         {
617                 tokenCount = 3;
618                 __displayPath = phone;
619         }
620         break;
621
622         case MEMORY_TYPE_SD_CARD:
623         {
624                 tokenCount = 3;
625                 __displayPath = sdCard;
626         }
627         break;
628
629         case MEMORY_TYPE_EXTERNAL:
630         {
631                 tokenCount = 3;
632                 __displayPath = externalStorage;
633         }
634         break;
635
636         default:
637                 //Do Nothing.
638                 break;
639         }
640
641         //Use a string tokenizer to get the filepath until it's the last token, break the loop when
642         //it is the last token
643         while (StrTok.HasMoreTokens())
644         {
645                 if (tokenCount > 0)
646                 {
647                         tokenCount--;
648                         StrTok.GetNextToken(token);
649                 }
650                 else
651                 {
652                         StrTok.GetNextToken(token);
653                         dislayPath.Append(token);
654                         dislayPath.Append(L"/");
655                 }
656         }
657
658         newDisplayPath = __displayPath;
659         newDisplayPath.Append(dislayPath);
660         __displayPath = newDisplayPath;
661
662 #if 0
663         DataBindingContext* pContext = GetDataBindingContextN();
664         if (pContext != null)
665         {
666                 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
667                 delete pContext;
668                 pContext = null;
669         }
670 #endif
671
672         if (_pDisplayPathLabel != null)
673         {
674                 _pDisplayPathLabel->SetText(__displayPath);
675                 _pDisplayPathLabel->Invalidate(true);
676         }
677         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
678 }
679
680 void
681 SubFolderMoveCopy::SetParentDisplayPath(void)
682 {
683         AppLogDebug("ENTER");
684         String dislayPath;
685         String delim(L"/");
686         String parentDisplayPath;
687         String token;
688
689         if (_pDisplayPathLabel != null)
690         {
691                 dislayPath = _pDisplayPathLabel->GetText();
692         }
693
694         StringTokenizer StrTok(dislayPath, delim);
695
696         //Use a string tokenizer to get the filepath until it's the last token, break the loop when
697         //it is the last token
698         while (StrTok.HasMoreTokens())
699         {
700                 int tokenCount = StrTok.GetTokenCount();
701
702                 if (tokenCount != 1)
703                 {
704                         StrTok.GetNextToken(token);
705                         parentDisplayPath.Append(token);
706                         parentDisplayPath.Append(L"/");
707                 }
708                 else
709                 {
710                         break;
711                 }
712         }
713
714         __displayPath = parentDisplayPath;
715
716 #if 0
717         DataBindingContext* pContext = GetDataBindingContextN();
718         pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
719         delete pContext;
720         pContext = null;
721 #endif
722         if (_pDisplayPathLabel != null)
723         {
724                 _pDisplayPathLabel->SetText(__displayPath);
725                 _pDisplayPathLabel->Invalidate(true);
726         }
727
728         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
729 }
730
731 void
732 SubFolderMoveCopy::OnDataBindingSourceUpdated(const String& bindingId, const String& controlName, const Tizen::Base::String& propertyName)
733 {
734         //Empty Implementation.
735 }
736
737 void
738 SubFolderMoveCopy::OnDataBindingTargetUpdated(const String& bindingId, const String& controlName, const Tizen::Base::String& propertyName)
739 {
740         //Empty Implementation.
741 }
742 void
743 SubFolderMoveCopy::OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Ui::DataBindingDestinationType destType)
744 {
745         //Empty Implementation.
746 }
747
748 void
749 SubFolderMoveCopy::ShowHomeView(void)
750 {
751         
752         AppLogDebug("Entry");
753         Integer* pSourceForm = null;
754         SceneManager* pSceneManager = SceneManager::GetInstance();
755         ArrayList* pArgs = null;
756
757         pArgs = new (std::nothrow) ArrayList();
758         //TryCatch(pArgs != null, , "pArgs is null.");
759         pSourceForm = new (std::nothrow) Integer(sourceFormOption);
760
761         //__pFolderEntryPM->SetFileEventListener(null);
762
763         pArgs->Construct();
764
765         pArgs->Add(pSourceForm);
766
767         //TryCatch(pSceneManager != null, , "SceneManager is null.");
768
769         /*if (__rootPath == BasePresentationModel::GetMediaPath() || __rootPath == BasePresentationModel::GetSdCardPath())
770                 {
771                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_MOVE_COPY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pArgs);
772                 }
773                 else
774                 {
775                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_MOVE_COPY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pArgs);
776                 }
777          */
778         //pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_MOVE_COPY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pArgs);
779         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_COPY_MOVE_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY),pArgs);
780         return;
781 }
782
783 void
784 SubFolderMoveCopy::SetHeaderTitleText(Tizen::Base::String& filePath)
785 {
786         String token;
787         String parentFileName;
788         String delimiter(L"/");
789         StringTokenizer tokenizer(filePath, delimiter);
790         AppResource* pAppResource = null;
791
792         pAppResource = UiApp::App::GetInstance()->GetAppResource();
793
794         if (filePath == BasePresentationModel::GetMediaPath())
795         {
796                 if (pAppResource != null)
797                 {
798                         pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
799                 }
800         }
801         else if (filePath == BasePresentationModel::GetSdCardPath())
802         {
803                 if (pAppResource != null)
804                 {
805                         pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
806                 }
807         }
808         else
809         {
810                 while (tokenizer.HasMoreTokens())
811                 {
812                         int tokenCount = tokenizer.GetTokenCount();
813
814                         if (tokenCount == 1)
815                         {
816                                 tokenizer.GetNextToken(parentFileName);
817                         }
818                         else
819                         {
820                                 tokenizer.GetNextToken(token);
821                         }
822                 }
823         }
824         __pHeader = GetHeader();
825
826         if (__pHeader != null)
827         {
828                 if (!parentFileName.IsEmpty())
829                 {
830                         __pHeader->SetTitleText(parentFileName);
831                         __pHeader->Invalidate(true);
832                         __pHeader->Invalidate(true);
833                 }
834         }
835 }
836
837 void
838 SubFolderMoveCopy::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
839 {
840         bool setMediaPath = false;
841         MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
842         String unmounted = sdCardStatusUnmounted;
843         String removed = usbDeviceStatusRemoved;
844         String currentPath;
845
846         if (state == unmounted || state == removed)
847         {
848                 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
849                 if (state == unmounted)
850                 {
851                         if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
852                         {
853                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
854                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
855                                 setMediaPath = true;
856                         }
857                 }
858
859                 if (state == removed)
860                 {
861                         if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
862                         {
863                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
864                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
865                                 setMediaPath = true;
866                         }
867                 }
868
869                 if (setMediaPath)
870                 {
871                         SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_COPY_MOVE_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
872                 }
873         }
874 }
875 void
876 SubFolderMoveCopy::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
877 {
878
879         ComponentType currentDeviceType;
880         switch (deviceType)
881         {
882         case StorageCard:
883         {
884                 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
885         }
886         break;
887
888         case UsbClient:
889         {
890                 currentDeviceType = COMPONENT_TYPE_USB;
891         }
892         break;
893
894         default:
895         {
896                 //Do Nothing.
897         }
898         break;
899         }
900         OnDeviceChange(currentDeviceType, state);
901 }
902
903 void
904 SubFolderMoveCopy::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
905                 const Tizen::Ui::Scenes::SceneId &currentSceneId)
906 {
907         AppLogDebug("Enter");
908
909         result r = E_SUCCESS;
910
911         int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
912         String viewStyleKeyName(L"ListDisplayType");
913
914         AppRegistry* pAppRegistry = null;
915         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
916
917         r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
918         AppLogDebug("AppRegistry Get Result: %s", GetErrorMessage(r));
919
920         SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
921
922         switch (listViewDisplayType)
923         {
924         case VIEW_TYPE_AS_DETAILED_LIST:
925         {
926                 if (_pIconListView != null && _pIconListView->IsVisible())
927                 {
928                         _pIconListView->SetShowState(false);
929                 }
930
931                 if (_pListView != null)
932                 {
933                         _pListView->ScrollToItem(0);
934                         _pListView->UpdateList();
935                         _pListView->SetShowState(true);
936                 }
937
938         }
939         break;
940
941         case VIEW_TYPE_AS_NORMAL_LIST:
942         {
943                 if (_pIconListView != null && _pIconListView->IsVisible())
944                 {
945                         _pIconListView->SetShowState(false);
946                 }
947
948                 if (_pListView != null)
949                 {
950                         _pListView->ScrollToItem(0);
951                         _pListView->UpdateList();
952                         _pListView->SetShowState(true);
953                 }
954
955         }
956         break;
957
958         case VIEW_TYPE_AS_THUMBNAILS:
959         {
960                 if (_pListView != null && _pListView->IsVisible())
961                 {
962                         _pListView->SetShowState(false);
963                 }
964
965                 if (_pIconListView != null)
966                 {
967                         _pIconListView->ScrollToItem(0);
968                         _pIconListView->UpdateList();
969                         _pIconListView->SetShowState(true);
970                 }
971
972         }
973         break;
974
975         default:
976         {
977                 __viewType = VIEW_TYPE_AS_NORMAL_LIST;
978                 if (_pListView != null)
979                 {
980                         _pListView->ScrollToItem(0);
981                         _pListView->UpdateList();
982                 }
983         }
984         break;
985         }
986
987 }
988
989 void
990 SubFolderMoveCopy::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId &currentSceneId,
991                 const Tizen::Ui::Scenes::SceneId &nextSceneId)
992 {
993         //Empty Implementation.
994 }
995
996 void
997 SubFolderMoveCopy::CreateFooterItems(void)
998 {
999         AppLogDebug("ENTER");
1000         result r = E_SUCCESS;
1001         _pFooter = GetFooter();
1002         int xPos = 0, yPos = 0;
1003
1004         String btnMove;
1005         String btnMoveHere;
1006         String btnPaste;
1007         String btnPasteHere;
1008         //String btnCreateFolder;
1009
1010         ButtonItem footerItemMenu;
1011
1012         Bitmap* pBitmap = null;
1013         Bitmap* pBitmapPress = null;
1014         Bitmap* pBitmapDisabled = null;
1015
1016         AppResource* pAppResource = null;
1017         pAppResource = Application::GetInstance()->GetAppResource();
1018         TryCatch(pAppResource != null, , "Resource manager not found!");
1019
1020         pAppResource->GetString(L"IDS_MF_SK3_MOVE_HERE", btnMoveHere);
1021         pAppResource->GetString(L"IDS_MF_SK3_PASTE_HERE", btnPasteHere);
1022         //pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", btnCreateFolder);
1023
1024         footerItemMenu.Construct(BUTTON_ITEM_STYLE_ICON, IDA_BTN_MORE);
1025         _pFooter = GetFooter();
1026
1027         pBitmap = pAppResource->GetBitmapN(IDB_MORE, BITMAP_PIXEL_FORMAT_ARGB8888);
1028         pBitmapDisabled = pAppResource->GetBitmapN(IDB_MORE_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888);
1029         pBitmapPress = pAppResource->GetBitmapN(IDB_MORE_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
1030
1031         if (pBitmap != null)
1032         {
1033                 pBitmap->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
1034                 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap);
1035         }
1036         if (pBitmapPress != null)
1037         {
1038                 pBitmapPress->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
1039                 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapPress);
1040         }
1041         if (pBitmapDisabled != null)
1042         {
1043                 pBitmapDisabled->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
1044                 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapDisabled);
1045         }
1046         if (_pFooter != null)
1047         {
1048                 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
1049         }
1050
1051         if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
1052         {
1053                 if (_pMove == null)
1054                 {
1055                         _pMove = new (std::nothrow) FooterItem();
1056                         r = _pMove->Construct(IDA_BTN_MOVE);
1057                         _pMove->SetText(btnMoveHere);
1058                 }
1059                 if (_pFooter != null)
1060                 {
1061                         r = _pFooter->AddItem(*_pMove);
1062                 }
1063         }
1064         else
1065         {
1066                 if (_pPaste == null)
1067                 {
1068                         _pPaste = new (std::nothrow) FooterItem();
1069                         r = _pPaste->Construct(IDA_BTN_PASTE);
1070                         _pPaste->SetText(btnPasteHere);
1071                 }
1072                 if (_pFooter != null)
1073                 {
1074                         r = _pFooter->AddItem(*_pPaste);
1075                 }
1076         }
1077
1078 /*      if (_pCreateFolder == null)
1079         {
1080                 _pCreateFolder = new (std::nothrow) FooterItem();
1081                 r = _pCreateFolder->Construct(IDA_BTN_CREATE_FOLDER);
1082                 _pCreateFolder->SetText(btnCreateFolder);
1083         }*/
1084 /*      if (_pFooter != null)
1085         {
1086                 r = _pFooter->AddItem(*_pCreateFolder);
1087         }*/
1088
1089         if (_pFooter != null)
1090         {
1091                 _pFooter->AddActionEventListener(*this);
1092                 _pFooter->SetBackButton();
1093                 _pFooter->SetBackButtonEnabled(true);
1094                 _pFooter->SetShowState(true);
1095                 _pFooter->Invalidate(true);
1096                 SetFormBackEventListener(this);
1097                 _pFooter->SetButton(BUTTON_POSITION_LEFT, footerItemMenu);
1098                 _pFooter->GetPosition(xPos, yPos);
1099         }
1100         _pMoreContextMenu = new (std::nothrow) ContextMenu();
1101         _pMoreContextMenu->Construct(Point(0, yPos), CONTEXT_MENU_STYLE_LIST);
1102         _pMoreContextMenu->AddActionEventListener(*this);
1103
1104         delete pBitmap;
1105         delete pBitmapPress;
1106         delete pBitmapDisabled;
1107         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1108         return;
1109 CATCH:
1110         if (_pFooter != null)
1111         {
1112                 _pFooter->RemoveAllItems();
1113         }
1114
1115         AppLogDebug("CreateFooterCustomControls--");
1116 }
1117
1118 FolderEntryPresentationModel*
1119 SubFolderMoveCopy::GetFolderEntryPresentationModel(void)
1120 {
1121         return _pFolderEntryPM;
1122 }
1123
1124 void
1125 SubFolderMoveCopy::OnNotificationReceived(ArrayList* pArgs)
1126 {
1127         AppLogDebug("ENTER");
1128
1129         int fileProcessingResult = 0;
1130         Integer* pfileProcessingResult = null;
1131
1132         TryCatch(pArgs != null, , "Argument list received is invalid");
1133
1134         pfileProcessingResult = (Integer*) pArgs->GetAt(0);
1135         if (pfileProcessingResult != null)
1136         {
1137                 //TryCatch(pArgs!=null ,,"Argument list received is invalid");
1138                 fileProcessingResult = pfileProcessingResult->ToInt();
1139
1140                 delete pfileProcessingResult;
1141         }
1142         switch (fileProcessingResult)
1143         {
1144         case FILE_MANAGING_RESULT_COPYING_SUCCESS:
1145         {
1146                 HideFileProgressingPopup();
1147                 LoadDirectoryForm();
1148         }
1149         break;
1150
1151         case FILE_MANAGING_RESULT_MOVING_SUCCESS:
1152         {
1153                 HideFileProgressingPopup();
1154                 LoadDirectoryForm();
1155         }
1156         break;
1157
1158         case FILE_MANAGING_RESULT_DUPLICITY:
1159         {
1160                 HideFileProgressingPopup();
1161                 //ShowFileExistingPopup();
1162         }
1163         break;
1164
1165         case FILE_MANAGING_RESULT_SOURCE_SAME_AS_DESTINATION:
1166         {
1167                 HideFileProgressingPopup();
1168                 MessageBox messageBox;
1169                 String moveFailedErrorMessage;
1170                 AppResource::GetInstance()->GetString(L"IDS_MF_POP_UNABLE_TO_MOVE_DESTINATION_FOLDER_SAME_AS_SOURCE_FOLDER", moveFailedErrorMessage);
1171
1172                 if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
1173                 {
1174                         messageBox.Construct(L"", moveFailedErrorMessage, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1175                 }
1176                 else
1177                 {
1178                         messageBox.Construct(L"", L"Cannot Copy: The Destination and the source are the same", MSGBOX_STYLE_NONE, 1000);
1179                 }
1180
1181                 // Call ShowAndWait - draw, show itself and process events
1182                 int modalResult = 0;
1183                 messageBox.ShowAndWait(modalResult);
1184         }
1185         break;
1186
1187         case FILE_MANAGING_RESULT_CURRENT_STATUS:
1188         {
1189                 String movingLabelText;
1190                 String copyingLabelText;
1191                 Integer* percentage = null;
1192
1193                 AppResource* pAppResource = null;
1194                 pAppResource = Application::GetInstance()->GetAppResource();
1195
1196                 pAppResource->GetString("IDS_COM_POP_MOVING", movingLabelText);
1197                 pAppResource->GetString("IDS_MF_POP_COPYING", copyingLabelText);
1198                 int value = 0;
1199                 String strFileProcessCount(L"");
1200                 if (pArgs->GetCount() > 1)
1201                 {
1202                         Integer* pCurrentStatus = (Integer*) pArgs->GetAt(1);
1203                         Integer* pTotalFileCount = (Integer*) pArgs->GetAt(2);
1204                         HashMap* pCacheList = null;
1205                         const HashMap* pSelectedItemsList = null;
1206                         int deleteItemcount = 0;
1207                         int filesCount = 0;
1208                         DirectoryEntry* pCurrentEntry = null;
1209                         bool cacheKeyStatus = false;
1210                         String cachePath;
1211
1212                         AppLogDebug("items deleted %d",pCurrentStatus->ToInt());
1213                         deleteItemcount = pCurrentStatus->ToInt();
1214                         pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1215                         pSelectedItemsList = FolderEntryEditorPresentationModel::GetInstance()->GetCheckedList();
1216
1217                         if (pCacheList != null && pSelectedItemsList != null)
1218                         {
1219                                 for (filesCount=0;filesCount<deleteItemcount;filesCount++)
1220                                 {
1221                                         Integer currentKeyIndex = filesCount;
1222                                         pCurrentEntry = const_cast< DirectoryEntry* >(static_cast< const DirectoryEntry* >(pSelectedItemsList->GetValue(currentKeyIndex)));
1223
1224                                         if (pCurrentEntry != null)
1225                                         {
1226                                                 cachePath = pCurrentEntry->GetFullFilePath();
1227                                         }
1228
1229                                         cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1230
1231                                         if (cacheKeyStatus)
1232                                         {
1233                                                 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1234                                         }
1235                                 }
1236                         }
1237
1238                         percentage = (Integer *)pArgs->GetAt(3);
1239                         value = percentage->ToInt();
1240                         AppLogDebug("precentage vlaue is %d",value);
1241                         if (pTotalFileCount != null)
1242                         {
1243                                 //value = (__fileManagedCount * 100) / (pTotalFileCount->ToInt());
1244
1245                                 __fileManagedCount = pCurrentStatus->ToInt();
1246                                 strFileProcessCount.Append(__fileManagedCount);
1247                                 strFileProcessCount.Append(L"/");
1248                                 strFileProcessCount.Append(pTotalFileCount->ToInt());
1249                                 delete pCurrentStatus;
1250                                 delete pTotalFileCount;
1251                         }
1252                 }
1253                 if (_pFileProgressingPopup != null)
1254                 {
1255                         if (_pFileProgressingHeaderLabel != null)
1256                         {
1257                                 if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
1258                                 {
1259                                         _pFileProgressingHeaderLabel->SetText(movingLabelText);
1260                                         _pFileProgressingHeaderLabel->Invalidate(true);
1261                                 }
1262
1263                                 if (sourceFormOption.ToInt() == SELECT_COPY_BUTTON)
1264                                 {
1265                                         _pFileProgressingHeaderLabel->SetText(copyingLabelText);
1266                                         _pFileProgressingHeaderLabel->Invalidate(true);
1267                                 }
1268                         }
1269                         if (_pFileProgressingProgress != null)
1270                         {
1271                                 _pFileProgressingProgress->SetValue(value);
1272                                 _pFileProgressingProgress->Invalidate(true);
1273                         }
1274
1275                         if (_pFileProgressingLabel != null)
1276                         {
1277                                 _pFileProgressingLabel->SetText(strFileProcessCount);
1278                                 _pFileProgressingLabel->Invalidate(true);
1279                         }
1280
1281                 }
1282
1283         }
1284         break;
1285
1286         case FILE_MANAGING_RESULT_COPYING_FAILED:
1287         {
1288                 String copyingFailed;
1289                 AppResource* pAppResource = null;
1290                 pAppResource = Application::GetInstance()->GetAppResource();
1291                 pAppResource->GetString("IDS_COPY_FAILED_MESSAGE", copyingFailed);
1292
1293                 HideFileProgressingPopup();
1294
1295                 MessageBox messageBox;
1296                 //messageBox.Construct(L"", L"Not enough memory.\n Delete some items and try again", MSGBOX_STYLE_NONE, 1000);
1297                 messageBox.Construct(L"", copyingFailed, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1298                 // Call ShowAndWait - draw, show itself and process events
1299                 int modalResult = 0;
1300                 messageBox.ShowAndWait(modalResult);
1301
1302                 String tempDeviceState;
1303
1304                 DeviceManager::GetState(DEVICE_TYPE_STORAGE_CARD,tempDeviceState);
1305                 if(tempDeviceState == sdCardStatusUnmounted && deviceState == sdCardStatusMounted)
1306                 {
1307                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
1308                 }
1309                 else
1310                 {
1311                         LoadDirectoryForm();
1312                 }
1313
1314         }
1315         break;
1316
1317         case FILE_MANAGING_RESULT_MOVING_FAILED:
1318         {
1319                 String movingFailed;
1320                 AppResource* pAppResource = null;
1321                 pAppResource = Application::GetInstance()->GetAppResource();
1322                 pAppResource->GetString("IDS_COM_POP_MOVING_FAILED", movingFailed);
1323
1324                 HideFileProgressingPopup();
1325
1326                 MessageBox messageBox;
1327                 //messageBox.Construct(L"", L"Not enough memory.\n Delete some items and try again", MSGBOX_STYLE_NONE, 1000);
1328                 messageBox.Construct(L"", movingFailed, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1329                 // Call ShowAndWait - draw, show itself and process events
1330                 int modalResult = 0;
1331                 messageBox.ShowAndWait(modalResult);
1332
1333                 String tempDeviceState;
1334                 DeviceManager::GetState(DEVICE_TYPE_STORAGE_CARD,tempDeviceState);
1335                 AppLogDebug("cureent %ls",tempDeviceState.GetPointer());
1336                 AppLogDebug("old device %ls",deviceState.GetPointer());
1337                 if(tempDeviceState == sdCardStatusUnmounted && deviceState == sdCardStatusMounted)
1338                 {
1339                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
1340                 }
1341                 else
1342                 {
1343                         LoadDirectoryForm();
1344                 }
1345         }
1346         break;
1347
1348         case FILE_MANAGING_RESULT_STORAGE_FULL:
1349         {
1350                 String storageFull;
1351                 AppResource* pAppResource = null;
1352                 pAppResource = Application::GetInstance()->GetAppResource();
1353                 pAppResource->GetString("IDS_STORAGE_FULL", storageFull);
1354
1355                 HideFileProgressingPopup();
1356                 MessageBox messageBox;
1357                 //messageBox.Construct(L"", L"Not enough memory.\n Delete some items and try again", MSGBOX_STYLE_NONE, 1000);
1358                 messageBox.Construct(L"", storageFull, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1359                 // Call ShowAndWait - draw, show itself and process events
1360                 int modalResult = 0;
1361                 messageBox.ShowAndWait(modalResult);
1362
1363                 LoadDirectoryForm();
1364         }
1365         break;
1366
1367         default:
1368                 break;
1369         }
1370
1371 CATCH:
1372         if (pArgs != null)
1373         {
1374                 pArgs->RemoveAll(false);
1375                 delete pArgs;
1376                 pArgs = null;
1377         }
1378
1379         AppLogDebug("EXIT");
1380 }
1381
1382 result
1383 SubFolderMoveCopy::CreateFileProgressingPopup(void)
1384 {
1385         AppLogDebug("Entry");
1386         result r = E_SUCCESS;
1387         _pFileProgressingPopup = new (std::nothrow) Popup();
1388         _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1389         if (_pFileProgressingPopup != null)
1390         {
1391                 //_pFileProgressingPopup->SetTitleText(L"FileProcessing");
1392
1393                 _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1394                 if (_pFileProgressingCancelButton != null)
1395                 {
1396                         _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1397                         _pFileProgressingCancelButton->AddActionEventListener(*this);
1398                         _pFileProgressingCancelButton->SetShowState(true);
1399                 }
1400
1401                 _pFileProgressingProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1402                 if (_pFileProgressingProgress != null)
1403                 {
1404                         _pFileProgressingProgress->SetValue(0);
1405                 }
1406
1407                 _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1408                 if (_pFileProgressingHeaderLabel != null)
1409                 {
1410                         _pFileProgressingHeaderLabel->SetShowState(true);
1411                 }
1412
1413                 _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1414                 if (_pFileProgressingLabel != null)
1415                 {
1416                         _pFileProgressingLabel->SetShowState(true);
1417                 }
1418         }
1419         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1420         return r;
1421 }
1422
1423 void
1424 SubFolderMoveCopy::ShowFileProgressingPopup(void)
1425 {
1426         String movingLabelText;
1427         String copyingLabelText;
1428         AppResource* pAppResource = null;
1429         pAppResource = Application::GetInstance()->GetAppResource();
1430
1431         pAppResource->GetString("IDS_COM_POP_MOVING", movingLabelText);
1432         pAppResource->GetString("IDS_MF_POP_COPYING", copyingLabelText);
1433
1434         CreateFileProgressingPopup();
1435
1436         if (_pFileProgressingPopup != null)
1437         {
1438
1439                 if (_pFileProgressingHeaderLabel != null)
1440                 {
1441                         if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
1442                         {
1443                                 _pFileProgressingHeaderLabel->SetText(movingLabelText);
1444                                 _pFileProgressingHeaderLabel->Invalidate(true);
1445                         }
1446
1447                         if (sourceFormOption.ToInt() == SELECT_COPY_BUTTON)
1448                         {
1449                                 _pFileProgressingHeaderLabel->SetText(copyingLabelText);
1450                                 _pFileProgressingHeaderLabel->Invalidate(true);
1451                         }
1452                 }
1453
1454                 _pFileProgressingPopup->SetShowState(true);
1455                 _pFileProgressingPopup->Show();
1456         }
1457 }
1458
1459 void
1460 SubFolderMoveCopy::HideFileProgressingPopup(void)
1461 {
1462         if (_pFileProgressingPopup != null && _pFileProgressingPopup->IsVisible())
1463         {
1464                 _pFileProgressingPopup->SetShowState(false);
1465
1466                 delete _pFileProgressingPopup;
1467                 _pFileProgressingPopup = null;
1468         }
1469 }
1470
1471 result
1472 SubFolderMoveCopy::LoadDirectoryForm(void)
1473 {
1474         AppLogDebug("ENTER");
1475         result r = E_SUCCESS;
1476         ArrayList* pArg = null;
1477         String fileName;
1478         SceneManager* pSceneManager = null;
1479         pSceneManager = SceneManager::GetInstance();
1480
1481         FolderNavigationPresentationModel::SetCurrentFilePath(_rootPath);
1482         //if (_moveCopySource == MOVE_COPY_SOURCE_SUB_FOLDER)
1483         //{
1484                 String delim(L"/");
1485                 String token;
1486                 StringTokenizer strTok(_rootPath, delim);
1487                 while (strTok.HasMoreTokens())
1488                 {
1489                         strTok.GetNextToken(token);
1490                 }
1491                 fileName.Append(token);
1492                 pArg = new (std::nothrow) ArrayList();
1493                 r = pArg->Construct();
1494                 pArg->Add(&fileName);
1495         //}
1496
1497         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pArg);
1498         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1499         return r;
1500 }
1501
1502 void
1503 SubFolderMoveCopy::OnFileManagingStart(void)
1504 {
1505         ShowFileProgressingPopup();
1506 }
1507
1508 void
1509 SubFolderMoveCopy::OnFileManagingStop(FileManagingResult fileProcessingResult)
1510 {
1511
1512 }
1513
1514 void
1515 SubFolderMoveCopy::OnFormBackRequested(Form& source)
1516 {
1517         SceneManager* pSceneManager = SceneManager::GetInstance();
1518         ArrayList* pArgs = null;
1519
1520         pArgs = new (std::nothrow) ArrayList();
1521         pArgs->Construct();
1522
1523         pArgs->Add(* new (std::nothrow) Integer(FILE_MANAGE_EDIT));
1524
1525         if (pSceneManager != null)
1526         {
1527                 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_DESTROY_OPTION_DESTROY), pArgs);
1528         }
1529         return;
1530 }
1531
1532 void
1533 SubFolderMoveCopy::LoadCreateFolderForm(void)
1534 {
1535         //Load the CreateFolder view in the current directory.
1536         AppLogDebug("ENTER");
1537         result r = E_SUCCESS;
1538         ArrayList* pArg = null;
1539         Integer* pSourceSelected = null;
1540         SceneManager* pSceneManager = null;
1541
1542         pSceneManager = SceneManager::GetInstance();
1543         //TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
1544
1545         pArg = new (std::nothrow) ArrayList();
1546         r = pArg->Construct();
1547
1548         pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER);
1549         pArg->Add(pSourceSelected);
1550
1551         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
1552         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1553
1554         return;
1555 }
1556
1557 void
1558 SubFolderMoveCopy::OnThumbnailReceived(ThumbRequest* pThumbReq)
1559 {
1560         result res = E_SUCCESS;
1561         ArrayList*              pFileList  = null;
1562         AppLogDebug("Enter");
1563
1564
1565
1566
1567         if (_pFolderEntryPM)
1568         {
1569                 pFileList = _pFolderEntryPM->GetFolderEntryList();
1570                 if (pThumbReq != null)
1571                 {
1572                         if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
1573                         {
1574                                 if (pThumbReq->pBitmap != null)
1575                                 {
1576                                         AppLogDebug("This Bitmap is not requested from same form");
1577                                         delete pThumbReq->pBitmap;
1578                                 }
1579                                 return;
1580                         }
1581                 }
1582
1583                 if (pThumbReq)
1584                 {
1585                         if (pThumbReq->iRquestId < pFileList->GetCount())
1586                         {
1587
1588                                 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
1589
1590                                 if (_pListView && _pListView->IsVisible())
1591                                 {
1592                                         res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1593                                 }
1594                                 else if (_pIconListView && _pIconListView->IsVisible())
1595                                 {
1596                                         res = _pIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1597                                 }
1598                         }
1599                 }
1600                 else
1601                 {
1602                         _pFolderEntryPM->OnThumbnailResponseFailed();
1603                 }
1604         }
1605         AppLogDebug("Exit %s", GetErrorMessage(res));
1606         return;
1607 }
1608