NABI_SE issues resolved
[apps/osp/MyFiles.git] / src / MfSubBaseMoveCopy.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: MfSubBaseMoveCopy.cpp
19  * @brief: This file contains the implementation of SubBaseMoveCopy class, which acts as a base view for TopMostMoveCopy
20  * and SubMoveCopy forms.
21  */
22
23 #include "MfSubBaseMoveCopy.h"
24
25 using namespace Tizen::App;
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Base::Utility;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Io;
31 using namespace Tizen::Media;
32 using namespace Tizen::Locales;
33 using namespace Tizen::System;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37
38 Integer SubBaseMoveCopy::sourceFormOption;
39
40 SubBaseMoveCopy::SubBaseMoveCopy(void)
41         : _pFileNames(null)
42         , _pCopyCancelButton(null)
43         , _pCopyRenameButton(null)
44         , _pCopyReplaceButton(null)
45         , _pFileProgressingCancelButton(null)
46         , _pMoreContextMenu(null)
47         , _pFooter(null)
48         , _pCopy(null)
49         , _pMove(null)
50         , _pPaste(null)
51         , _pIconListView(null)
52         , _pDisplayPathLabel(null)
53         , _pFileProgressingHeaderLabel(null)
54         , _pFileProgressingLabel(null)
55         , _pListView(null)
56         , _pFileExistingPopup(null)
57         , _pFileProgressingPopup(null)
58         , _pFileProgressingProgress(null)
59         , _pBaseItemProvider(null)
60         , _pFileManager(null)
61         , _pFolderEntryPM(null)
62         , _pMediaMetaData(null)
63         , _pThumbnailItemProvider(null)
64         , _pThumbnailManager(null)
65 {
66         _fileManagedCount = 0;
67         _moveCopySource = MOVE_COPY_SOURCE_NONE;
68         setMediaPath = false;
69 }
70
71 SubBaseMoveCopy::~SubBaseMoveCopy(void)
72 {
73         if (_pFileExistingPopup != null)
74         {
75                 delete _pFileExistingPopup;
76         }
77
78         if (_pFileProgressingPopup != null)
79         {
80                 delete _pFileProgressingPopup;
81         }
82
83         if (_pMove != null)
84         {
85                 delete _pMove;
86         }
87
88         if (_pCopy != null)
89         {
90                 delete _pCopy;
91         }
92
93         if (_pMoreContextMenu != null)
94         {
95                 delete _pMoreContextMenu;
96         }
97
98         if (_pPaste != null)
99         {
100                 delete _pPaste;
101         }
102
103 /*      if (_pCreateFolder != null)
104         {
105                 delete _pCreateFolder;
106         }*/
107
108         if (_pFolderEntryPM != null)
109         {
110                 delete _pFolderEntryPM;
111         }
112
113         if (_pBaseItemProvider != null)
114         {
115                 delete _pBaseItemProvider;
116         }
117
118         if (_pThumbnailItemProvider != null)
119         {
120                 delete _pThumbnailItemProvider;
121         }
122 }
123
124 SubBaseMoveCopy&
125 SubBaseMoveCopy::operator =(const SubBaseMoveCopy& pSubBaseMoveCopy)
126 {
127         return *this;
128 }
129
130 SubBaseMoveCopy::SubBaseMoveCopy(const SubBaseMoveCopy& pSubBaseMoveCopy)
131 {
132         //Do Nothing
133 }
134
135 result
136 SubBaseMoveCopy::CreateFileExistingPopup(void)
137 {
138         AppLogDebug("ENTER");
139         result r = E_SUCCESS;
140 //      Label* pPopupLabel = null;
141 //      Label* pBottomPanelLabel = null;
142 //      Label* pLabelTitleText = null;
143 //
144 //      Bitmap* pPopUpBackground = null;
145 //      Bitmap* pBottomPanelBackground = null;
146
147 //      pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
148 //      pBottomPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
149
150         _pFileExistingPopup = new (std::nothrow) Popup;
151         r = _pFileExistingPopup->Construct(L"IDL_FILE_EXISTING_POPUP");
152
153 //      pPopupLabel = static_cast< Label* >(_pFileExistingPopup->GetControl(L"IDC_LABEL_POPUP_CENTER_BACKGROUND", true));
154 //      TryCatch(pPopupLabel != null, , "__pCopyRenameButton Popup Could Not be Created!");
155 //
156 //      pBottomPanelLabel = static_cast< Label* >(_pFileExistingPopup->GetControl(L"IDC_LABEL_POPUP_BOTTOM_BACKGROUND", true));
157 //      TryCatch(pBottomPanelLabel != null, , "__pCopyRenameButton Popup Could Not be Created!");
158 //
159 //      pLabelTitleText = static_cast< Label* >(_pFileExistingPopup->GetControl(L"IDC_LABEL_TITLE_TEXT", true));
160 //      TryCatch(pLabelTitleText != null, , "__pCopyRenameButton Popup Could Not be Created!");
161 //
162 //      pBottomPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, pBottomPanelLabel->GetWidth(), pBottomPanelLabel->GetHeight());;
163 //      pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, pPopupLabel->GetWidth(), pPopupLabel->GetHeight());
164 //
165 //      if (pPopUpBackground != null)
166 //      {
167 //              pPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
168 //      }
169 //      if (pBottomPanelBackground != null)
170 //      {
171 //              pBottomPanelLabel->SetBackgroundBitmap(*pBottomPanelBackground);
172 //      }
173 //
174         _pCopyRenameButton = static_cast< Button* >(_pFileExistingPopup->GetControl(L"IDC_FILE_EXISTING_RENAME", true));
175         TryCatch(_pCopyRenameButton != null, , "::__pCopyRenameButton Popup Could Not be Created!");
176
177         _pCopyRenameButton->SetActionId(IDA_BTN_POPUP_COPY_RENAME);
178         _pCopyRenameButton->AddActionEventListener(*this);
179         _pCopyRenameButton->SetShowState(true);
180
181         _pCopyReplaceButton = static_cast< Button* >(_pFileExistingPopup->GetControl(L"IDC_FILE_EXISTING_REPLACE", true));
182         TryCatch(_pCopyReplaceButton != null, , "::__pCopyReplaceButton Could Not be Created!");
183
184         _pCopyReplaceButton->SetActionId(IDA_BTN_POPUP_COPY_REPLACE);
185         _pCopyReplaceButton->AddActionEventListener(*this);
186         _pCopyReplaceButton->SetShowState(true);
187
188
189         _pCopyCancelButton = static_cast< Button* >(_pFileExistingPopup->GetControl(L"IDC_FILE_EXISTING_CANCEL", true));
190         TryCatch(_pCopyCancelButton != null, , " __pCopyCancelButton Could Not be Created!");
191
192         _pCopyCancelButton->SetActionId(IDA_BTN_POPUP_COPY_CANCEL);
193         _pCopyCancelButton->AddActionEventListener(*this);
194         _pCopyCancelButton->SetShowState(true);
195
196         _pFileExistingPopup->SetControlAlwaysOnTop(*_pCopyRenameButton, true);
197         _pFileExistingPopup->SetControlAlwaysOnTop(*_pCopyReplaceButton, true);
198         _pFileExistingPopup->SetControlAlwaysOnTop(*_pCopyCancelButton, true);
199 //      _pFileExistingPopup->SetControlAlwaysOnTop(*pLabelTitleText, true);
200 //      _pFileExistingPopup->SetControlAlwaysAtBottom(*pPopupLabel, true);
201 //      _pFileExistingPopup->SetControlAlwaysAtBottom(*pBottomPanelLabel, true);
202
203 //      if (pPopUpBackground != null)
204 //      {
205 //              delete pPopUpBackground;
206 //              pPopUpBackground = null;
207 //      }
208 //
209 //      if (pBottomPanelBackground != null)
210 //      {
211 //              delete pBottomPanelBackground;
212 //              pBottomPanelBackground = null;
213 //      }
214         AppLogDebug(":: CreateFileExistingPopup--");
215         return r;
216
217 CATCH:
218 //      if (pPopUpBackground != null)
219 //      {
220 //              delete pPopUpBackground;
221 //              pPopUpBackground = null;
222 //      }
223 //      if (pBottomPanelBackground != null)
224 //      {
225 //              delete pBottomPanelBackground;
226 //              pBottomPanelBackground = null;
227 //      }
228         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
229         return r;
230 }
231
232 result
233 SubBaseMoveCopy::CreateFileProgressingPopup(void)
234 {
235         AppLogDebug("Entry");
236         result r = E_SUCCESS;
237         _pFileProgressingPopup = new (std::nothrow) Popup();
238         _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
239         if (_pFileProgressingPopup != null)
240         {
241                 _pFileProgressingPopup->SetTitleText(L"FileProcessing");
242
243                 _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
244                 if (_pFileProgressingCancelButton != null)
245                 {
246                         _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
247                         _pFileProgressingCancelButton->AddActionEventListener(*this);
248                         _pFileProgressingCancelButton->SetShowState(true);
249                 }
250
251                 _pFileProgressingProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
252                 if (_pFileProgressingProgress != null)
253                 {
254                         _pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
255                         _pFileProgressingProgress->SetValue(0);
256                 }
257
258                 _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
259                 if (_pFileProgressingHeaderLabel != null)
260                 {
261                         _pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
262                         _pFileProgressingHeaderLabel->SetShowState(true);
263                 }
264
265                 _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
266                 if (_pFileProgressingLabel != null)
267                 {
268                         _pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
269                         _pFileProgressingLabel->SetShowState(true);
270                 }
271         }
272         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
273         return r;
274 }
275
276 void
277 SubBaseMoveCopy::CreateFooterItems(void)
278 {
279         AppLogDebug("ENTER");
280         result r = E_SUCCESS;
281         _pFooter = GetFooter();
282         int xPos = 0, yPos = 0;
283
284         String btnMove;
285         String btnMoveHere;
286         String btnPaste;
287         String btnPasteHere;
288         //String btnCreateFolder;
289
290         ButtonItem footerItemMenu;
291
292         Bitmap* pBitmap = null;
293         Bitmap* pBitmapPress = null;
294         AppResource* pAppResource = null;
295         pAppResource = UiApp::GetInstance()->GetAppResource();
296         TryCatch(pAppResource != null, , "Resource manager not found!");
297
298         pAppResource->GetString(L"IDS_MF_SK3_MOVE_HERE", btnMoveHere);
299         pAppResource->GetString(L"IDS_MF_SK3_PASTE_HERE", btnPasteHere);
300         //pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", btnCreateFolder);
301
302         footerItemMenu.Construct(BUTTON_ITEM_STYLE_ICON, IDA_BTN_MORE);
303         _pFooter = GetFooter();
304
305         pBitmap = pAppResource->GetBitmapN(IDB_MORE, BITMAP_PIXEL_FORMAT_ARGB8888);
306         pBitmapPress = pAppResource->GetBitmapN(IDB_MORE_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
307         if (pBitmap != null)
308         {
309                 pBitmap->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
310                 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap);
311         }
312         if (pBitmapPress != null)
313         {
314                 pBitmapPress->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
315                 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapPress);
316         }
317
318         if (_pFooter != null)
319         {
320                 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
321         }
322
323         if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
324         {
325                 if (_pMove == null)
326                 {
327                         _pMove = new (std::nothrow) FooterItem();
328                         r = _pMove->Construct(IDA_BTN_MOVE);
329                         _pMove->SetText(btnMoveHere);
330                 }
331                 if (_pFooter != null)
332                 {
333                         r = _pFooter->AddItem(*_pMove);
334                 }
335         }
336         else
337         {
338                 if (_pPaste == null)
339                 {
340                         _pPaste = new (std::nothrow) FooterItem();
341                         r = _pPaste->Construct(IDA_BTN_PASTE);
342                         _pPaste->SetText(btnPasteHere);
343                 }
344                 if (_pFooter != null)
345                 {
346                         r = _pFooter->AddItem(*_pPaste);
347                 }
348         }
349
350 /*      if (_pCreateFolder == null)
351         {
352                 _pCreateFolder = new (std::nothrow) FooterItem();
353                 r = _pCreateFolder->Construct(IDA_BTN_CREATE_FOLDER);
354                 _pCreateFolder->SetText(btnCreateFolder);
355         }*/
356 /*      if (_pFooter != null)
357         {
358                 r = _pFooter->AddItem(*_pCreateFolder);
359         }*/
360
361         if (_pFooter != null)
362         {
363                 _pFooter->AddActionEventListener(*this);
364                 _pFooter->SetBackButton();
365                 _pFooter->SetBackButtonEnabled(true);
366                 _pFooter->SetShowState(true);
367                 _pFooter->Invalidate(true);
368                 SetFormBackEventListener(this);
369                 _pFooter->SetButton(BUTTON_POSITION_LEFT, footerItemMenu);
370                 _pFooter->GetPosition(xPos, yPos);
371         }
372         _pMoreContextMenu = new (std::nothrow) ContextMenu();
373         _pMoreContextMenu->Construct(Point(0, yPos), CONTEXT_MENU_STYLE_LIST);
374         _pMoreContextMenu->AddActionEventListener(*this);
375
376         delete pBitmap;
377         delete pBitmapPress;
378         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
379         return;
380 CATCH:
381         if (_pFooter != null)
382         {
383                 _pFooter->RemoveAllItems();
384         }
385
386         AppLogDebug("CreateFooterCustomControls--");
387 }
388
389 FolderEntryPresentationModel*
390 SubBaseMoveCopy::GetFolderEntryPresentationModel(void)
391 {
392         return _pFolderEntryPM;
393 }
394
395 void
396 SubBaseMoveCopy::HideFileExistingPopup(void)
397 {
398         if (_pFileExistingPopup != null && _pFileExistingPopup->IsVisible())
399         {
400                 _pFileExistingPopup->SetShowState(false);
401
402                 delete _pFileExistingPopup;
403                 _pFileExistingPopup = null;
404         }
405 }
406
407 void
408 SubBaseMoveCopy::HideFileProgressingPopup(void)
409 {
410         if (_pFileProgressingPopup != null && _pFileProgressingPopup->IsVisible())
411         {
412                 _pFileProgressingPopup->SetShowState(false);
413
414                 delete _pFileProgressingPopup;
415                 _pFileProgressingPopup = null;
416         }
417 }
418
419 void
420 SubBaseMoveCopy::LoadCreateFolderForm(void)
421 {
422         //Load the CreateFolder view in the current directory.
423         AppLogDebug("ENTER");
424         result r = E_SUCCESS;
425         ArrayList* pArg = null;
426         Integer* pSourceSelected = null;
427         SceneManager* pSceneManager = null;
428
429         pSceneManager = SceneManager::GetInstance();
430         //TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
431
432         pArg = new (std::nothrow) ArrayList();
433         r = pArg->Construct();
434
435         pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER);
436         pArg->Add(pSourceSelected);
437
438         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
439         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
440
441         return;
442 }
443
444 void
445 SubBaseMoveCopy::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
446 {
447         AppLogDebug("ENTER");
448
449         String __mediaPath;
450         String __StoragePath;
451         String createFolder;
452         Bitmap* pBitmapCreateFolderContextItem = null;
453
454         AppResource* pAppResource = null;
455         pAppResource = UiApp::GetInstance()->GetAppResource();
456
457         if (pAppResource != null)
458         {
459                 pAppResource->GetString(L"IDS_COM_BODY_CREATE_FOLDER", createFolder);
460                 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
461         }
462
463         switch (actionId)
464         {
465         case IDA_BTN_MOVE:
466         {
467                 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
468                 _rootPath = FolderNavigationPresentationModel::GetCurrentPath();
469                 _pFileManager->MoveFolderEntries(FILE_EXISTING_OPERATIONID_NONE);
470         }
471         break;
472
473         case IDA_BTN_PASTE:
474         {
475                 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
476                 _rootPath = FolderNavigationPresentationModel::GetCurrentPath();
477                 _pFileManager->CopyFolderEntries(FILE_EXISTING_OPERATIONID_NONE);
478         }
479         break;
480
481         case IDA_BTN_CREATE_FOLDER:
482         {
483                 LoadCreateFolderForm();
484         }
485         break;
486
487         case IDA_BTN_CANCEL:
488         {
489                 SceneManager* pSceneManager = SceneManager::GetInstance();
490                 if (pSceneManager != null)
491                 {
492                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_DESTROY_OPTION_DESTROY), null);
493                 }
494         }
495         break;
496
497         case IDA_BTN_MORE:
498         {
499                 _pMoreContextMenu->RemoveAllItems();
500                 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
501                 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
502                 _pMoreContextMenu->AddItem(createFolder, IDA_BTN_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
503                 _pMoreContextMenu->SetShowState(true);
504                 _pMoreContextMenu->Show();
505         }
506         break;
507
508         case IDA_BTN_ANIMATION_POPUP_CANCEL:
509         {
510                 //HideFileProgressingPopup();
511                 _pFileManager->ForceStopWorkerThread();
512         }
513         break;
514
515         case IDA_BTN_POPUP_COPY_RENAME:
516         {
517                 HideFileExistingPopup();
518                 if (sourceFormOption.ToInt() == SELECT_COPY_BUTTON)
519                 {
520                         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
521                         _pFileManager->CopyFolderEntries(FILE_EXISTING_OPERATIONID_RENAME);
522
523                 }
524
525                 if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
526                 {
527                         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
528                         _pFileManager->MoveFolderEntries(FILE_EXISTING_OPERATIONID_RENAME);
529
530                 }
531         }
532         break;
533
534         case IDA_BTN_POPUP_COPY_REPLACE:
535         {
536                 HideFileExistingPopup();
537                 if (sourceFormOption.ToInt() == SELECT_COPY_BUTTON)
538                 {
539                         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
540                         _pFileManager->CopyFolderEntries(FILE_EXISTING_OPERATIONID_REPLACE);
541
542                 }
543
544                 if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
545                 {
546                         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
547                         _pFileManager->MoveFolderEntries(FILE_EXISTING_OPERATIONID_REPLACE);
548
549                 }
550         }
551         break;
552
553         case IDA_BTN_POPUP_COPY_CANCEL:
554         {
555                 //HideFileProgressingPopup();
556                 HideFileExistingPopup();
557                 LoadDirectoryForm();
558         }
559         break;
560
561         default:
562         {
563                 // In Default
564         }
565         break;
566         }
567
568         if (pBitmapCreateFolderContextItem != null)
569         {
570                 delete pBitmapCreateFolderContextItem;
571                 pBitmapCreateFolderContextItem = null;
572         }
573         Invalidate(true);
574         AppLogDebug("EXIT");
575 }
576
577
578 void
579 SubBaseMoveCopy::OnFileManagingStart(void)
580 {
581         ShowFileProgressingPopup();
582 }
583
584 void
585 SubBaseMoveCopy::ShowFileProgressingPopup(void)
586 {
587         String movingLabelText;
588         String copyingLabelText;
589         AppResource* pAppResource = null;
590         pAppResource = Application::GetInstance()->GetAppResource();
591
592         pAppResource->GetString("IDS_COM_POP_MOVING", movingLabelText);
593         pAppResource->GetString("IDS_MF_POP_COPYING", copyingLabelText);
594
595         CreateFileProgressingPopup();
596
597         if (_pFileProgressingPopup != null)
598         {
599
600                 if (_pFileProgressingHeaderLabel != null)
601                 {
602                         if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
603                         {
604                                 _pFileProgressingHeaderLabel->SetText(movingLabelText);
605                                 _pFileProgressingHeaderLabel->Invalidate(true);
606                         }
607
608                         if (sourceFormOption.ToInt() == SELECT_COPY_BUTTON)
609                         {
610                                 _pFileProgressingHeaderLabel->SetText(copyingLabelText);
611                                 _pFileProgressingHeaderLabel->Invalidate(true);
612                         }
613                 }
614
615                 _pFileProgressingPopup->SetShowState(true);
616                 _pFileProgressingPopup->Show();
617         }
618 }
619
620 void
621 SubBaseMoveCopy::OnFileManagingStop(FileManagingResult fileProcessingResult)
622 {
623         //Empty Implementation.
624 }
625
626 void
627 SubBaseMoveCopy::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
628 {
629         //Empty Implementation.
630 }
631
632 void
633 SubBaseMoveCopy::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
634 {
635         //Empty Implementation.
636 }
637
638 void
639 SubBaseMoveCopy::OnListViewItemStateChangedNotify(ViewType viewType)
640 {
641         //Empty Implementation.
642 }
643
644 void
645 SubBaseMoveCopy::OnThumbnailReceived(ThumbRequest* pThumbReq)
646 {
647         result res = E_SUCCESS;
648         ArrayList*              pFileList  = null;
649         AppLogDebug("Enter");
650
651
652
653
654         if (_pFolderEntryPM)
655         {
656                 pFileList = _pFolderEntryPM->GetFolderEntryList();
657                 if (pThumbReq != null)
658                 {
659                         if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
660                         {
661                                 if (pThumbReq->pBitmap != null)
662                                 {
663                                         AppLogDebug("This Bitmap is not requested from same form");
664                                         delete pThumbReq->pBitmap;
665                                 }
666                                 return;
667                         }
668                 }
669
670                 if (pThumbReq)
671                 {
672                         if (pThumbReq->iRquestId < pFileList->GetCount())
673                         {
674
675                                 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
676
677                                 if (_pListView && _pListView->IsVisible())
678                                 {
679                                         res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
680                                 }
681                                 else if (_pIconListView && _pIconListView->IsVisible())
682                                 {
683                                         res = _pIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
684                                 }
685                         }
686                 }
687                 else
688                 {
689                         _pFolderEntryPM->OnThumbnailResponseFailed();
690                 }
691         }
692         AppLogDebug("Exit %s", GetErrorMessage(res));
693         return;
694 }
695
696 result
697 SubBaseMoveCopy::OnTerminating(void)
698 {
699         result r = E_SUCCESS;
700
701         _pFooter = GetFooter();
702         if (_pFooter != null)
703         {
704                 _pFooter->RemoveAllButtons();
705                 _pFooter->RemoveAllItems();
706         }
707         return r;
708 }
709
710 void
711 SubBaseMoveCopy::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
712                                                                         const Tizen::Ui::Scenes::SceneId& nextSceneId)
713 {
714         //Empty Implementation.
715         ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
716         if (_pFolderEntryPM != null)
717         {
718                 _pFolderEntryPM->StopThumbnailManager(true);
719         }
720 }
721
722 void
723 SubBaseMoveCopy::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
724 {
725         //empty Implementation
726 }
727
728 void
729 SubBaseMoveCopy::ShowFileExistingPopup(void)
730 {
731         CreateFileExistingPopup();
732
733         if (_pFileExistingPopup != null)
734         {
735                 _pFileExistingPopup->SetShowState(true);
736                 _pFileExistingPopup->Show();
737         }
738 }
739
740 void
741 SubBaseMoveCopy::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
742 {
743
744         AppLogDebug("ENTER");
745         Rectangle listViewBounds;
746         Rectangle labelBounds;
747
748
749         if (_moveCopySource == MOVE_COPY_SOURCE_SUB_FOLDER)
750         {
751                 listViewBounds.SetBounds(GetClientAreaBounds().x, H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, GetClientAreaBounds().height);
752                 labelBounds.SetBounds(GetClientAreaBounds().x, 0, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL);
753         }
754         else
755         {
756                 listViewBounds.SetBounds(GetClientAreaBounds().x, 0, GetClientAreaBounds().width, GetClientAreaBounds().height);
757         }
758
759         switch (orientationStatus)
760         {
761         case ORIENTATION_STATUS_PORTRAIT:
762         {
763                 if (_pListView != null)
764                 {
765                         _pListView->SetBounds(listViewBounds);
766                 }
767
768                 if (_pIconListView != null)
769                 {
770                         _pIconListView->SetBounds(listViewBounds);
771                 }
772
773                 if (_moveCopySource == MOVE_COPY_SOURCE_SUB_FOLDER)
774                 {
775                         if (_pDisplayPathLabel != null)
776                         {
777                                 _pDisplayPathLabel->SetBounds(labelBounds);
778                         }
779                 }
780
781         }
782         break;
783
784         case ORIENTATION_STATUS_LANDSCAPE:
785         {
786                 if (_pListView != null)
787                 {
788                         _pListView->SetBounds(listViewBounds);
789                 }
790
791                 if (_pIconListView != null)
792                 {
793                         _pIconListView->SetBounds(listViewBounds);
794                 }
795
796                 if (_moveCopySource == MOVE_COPY_SOURCE_SUB_FOLDER)
797                 {
798                         if (_pDisplayPathLabel != null)
799                         {
800                                 _pDisplayPathLabel->SetBounds(labelBounds);
801                         }
802                 }
803         }
804         break;
805
806         default:
807         {
808                 //Do Nothing
809         }
810         break;
811         }
812
813         Invalidate(true);
814         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
815 }
816
817 void
818 SubBaseMoveCopy::OnFormBackRequested(Form& source)
819 {
820
821         SceneManager* pSceneManager = SceneManager::GetInstance();
822         if (pSceneManager != null)
823         {
824                 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_DESTROY_OPTION_DESTROY), null);
825         }
826         return;
827 }
828
829 void
830 SubBaseMoveCopy::OnNotificationReceived(ArrayList* pArgs)
831 {
832         AppLogDebug("ENTER");
833
834         int fileProcessingResult = 0;
835         Integer* pfileProcessingResult = null;
836
837         TryCatch(pArgs != null, , "Argument list received is invalid");
838
839         pfileProcessingResult = (Integer*) pArgs->GetAt(0);
840         if (pfileProcessingResult != null)
841         {
842                 //TryCatch(pArgs!=null ,,"Argument list received is invalid");
843                 fileProcessingResult = pfileProcessingResult->ToInt();
844
845                 delete pfileProcessingResult;
846         }
847         switch (fileProcessingResult)
848         {
849         case FILE_MANAGING_RESULT_COPYING_SUCCESS:
850         {
851                 HideFileProgressingPopup();
852                 LoadDirectoryForm();
853         }
854         break;
855
856         case FILE_MANAGING_RESULT_MOVING_SUCCESS:
857         {
858                 HideFileProgressingPopup();
859                 LoadDirectoryForm();
860         }
861         break;
862
863         case FILE_MANAGING_RESULT_DUPLICITY:
864         {
865                 HideFileProgressingPopup();
866                 ShowFileExistingPopup();
867         }
868         break;
869
870         case FILE_MANAGING_RESULT_SOURCE_SAME_AS_DESTINATION:
871         {
872                 HideFileProgressingPopup();
873                 MessageBox messageBox;
874                 String moveFailedErrorMessage;
875                 String copyFailedErrorMessage;
876
877                 AppResource::GetInstance()->GetString(L"IDS_MF_POP_UNABLE_TO_MOVE_DESTINATION_FOLDER_SAME_AS_SOURCE_FOLDER", moveFailedErrorMessage);
878                 AppResource::GetInstance()->GetString(L"IDS_MF_POP_UNABLE_TO_COPY_DESTINATION_FOLDER_SAME_AS_SOURCE_FOLDER", copyFailedErrorMessage);
879
880                 if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
881                 {
882                         messageBox.Construct(L"", moveFailedErrorMessage, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
883                 }
884                 else
885                 {
886                         messageBox.Construct(L"", copyFailedErrorMessage, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
887                 }
888
889                 // Call ShowAndWait - draw, show itself and process events
890                 int modalResult = 0;
891                 messageBox.ShowAndWait(modalResult);
892         }
893         break;
894
895         case FILE_MANAGING_RESULT_CURRENT_STATUS:
896         {
897                 String movingLabelText;
898                 String copyingLabelText;
899                 AppResource* pAppResource = null;
900                 pAppResource = Application::GetInstance()->GetAppResource();
901
902                 pAppResource->GetString("IDS_COM_POP_MOVING", movingLabelText);
903                 pAppResource->GetString("IDS_MF_POP_COPYING", copyingLabelText);
904                 int value = 0;
905                 String strFileProcessCount(L"");
906                 if (pArgs->GetCount() > 1)
907                 {
908                         Integer* pCurrentStatus = (Integer*) pArgs->GetAt(1);
909                         Integer* pTotalFileCount = (Integer*) pArgs->GetAt(2);
910                         if (pCurrentStatus != null && pTotalFileCount != null)
911                         {
912                                 value = (_fileManagedCount * 100) / (pTotalFileCount->ToInt());
913
914                                 _fileManagedCount = pCurrentStatus->ToInt();
915                                 strFileProcessCount.Append(_fileManagedCount);
916                                 strFileProcessCount.Append(L"/");
917                                 strFileProcessCount.Append(pTotalFileCount->ToInt());
918                                 delete pCurrentStatus;
919                                 delete pTotalFileCount;
920                         }
921                 }
922                 if (_pFileProgressingPopup != null)
923                 {
924                         Progress* pProgrssAnimation = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_PROGRESS", true));
925                         if (_pFileProgressingHeaderLabel != null)
926                         {
927                                 if (sourceFormOption.ToInt() == SELECT_MOVE_BUTTON)
928                                 {
929                                         _pFileProgressingHeaderLabel->SetText(movingLabelText);
930                                         _pFileProgressingHeaderLabel->Invalidate(true);
931                                 }
932
933                                 if (sourceFormOption.ToInt() == SELECT_COPY_BUTTON)
934                                 {
935                                         _pFileProgressingHeaderLabel->SetText(copyingLabelText);
936                                         _pFileProgressingHeaderLabel->Invalidate(true);
937                                 }
938                         }
939                         if (pProgrssAnimation != null)
940                         {
941                                 pProgrssAnimation->SetValue(value);
942                                 pProgrssAnimation->Invalidate(true);
943                         }
944
945                         Label* pLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_FILE_COUNT_LABEL", true));
946                         if (pLabel != null)
947                         {
948                                 pLabel->SetText(strFileProcessCount);
949                                 pLabel->Invalidate(true);
950                         }
951
952                 }
953
954         }
955         break;
956
957         case FILE_MANAGING_RESULT_COPYING_FAILED:
958         {
959                 String copyingFailed;
960                 AppResource* pAppResource = null;
961                 pAppResource = Application::GetInstance()->GetAppResource();
962                 pAppResource->GetString("IDS_COPY_FAILED_MESSAGE", copyingFailed);
963
964                 HideFileProgressingPopup();
965
966                 MessageBox messageBox;
967                 //messageBox.Construct(L"", L"Not enough memory.\n Delete some items and try again", MSGBOX_STYLE_NONE, 1000);
968                 messageBox.Construct(L"", copyingFailed, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
969                 // Call ShowAndWait - draw, show itself and process events
970                 int modalResult = 0;
971                 messageBox.ShowAndWait(modalResult);
972
973                 String tempDeviceState;
974
975                 DeviceManager::GetState(DEVICE_TYPE_STORAGE_CARD,tempDeviceState);
976                 if(tempDeviceState == sdCardStatusUnmounted && deviceState == sdCardStatusMounted)
977                 {
978                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
979                 }
980                 else
981                 {
982                         LoadDirectoryForm();
983                 }
984                 
985         }
986         break;
987
988         case FILE_MANAGING_RESULT_MOVING_FAILED:
989         {
990                 String movingFailed;
991                 AppResource* pAppResource = null;
992                 pAppResource = Application::GetInstance()->GetAppResource();
993                 pAppResource->GetString("IDS_COM_POP_MOVING_FAILED", movingFailed);
994
995                 HideFileProgressingPopup();
996
997                 MessageBox messageBox;
998                 //messageBox.Construct(L"", L"Not enough memory.\n Delete some items and try again", MSGBOX_STYLE_NONE, 1000);
999                 messageBox.Construct(L"", movingFailed, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1000                 // Call ShowAndWait - draw, show itself and process events
1001                 int modalResult = 0;
1002                 messageBox.ShowAndWait(modalResult);
1003
1004                 String tempDeviceState;
1005                 DeviceManager::GetState(DEVICE_TYPE_STORAGE_CARD,tempDeviceState);
1006                 AppLogDebug("cureent %ls",tempDeviceState.GetPointer());
1007                 AppLogDebug("old device %ls",deviceState.GetPointer());
1008                 if(tempDeviceState == sdCardStatusUnmounted && deviceState == sdCardStatusMounted)
1009                 {
1010                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
1011                 }
1012                 else
1013                 {
1014                         LoadDirectoryForm();
1015                 }
1016         }
1017         break;
1018
1019         case FILE_MANAGING_RESULT_STORAGE_FULL:
1020         {
1021                 String storageFull;
1022                 AppResource* pAppResource = null;
1023                 pAppResource = Application::GetInstance()->GetAppResource();
1024                 pAppResource->GetString("IIDS_STORAGE_FULL", storageFull);
1025
1026                 HideFileProgressingPopup();
1027                 MessageBox messageBox;
1028                 //messageBox.Construct(L"", L"Not enough memory.\n Delete some items and try again", MSGBOX_STYLE_NONE, 1000);
1029                 messageBox.Construct(L"", storageFull, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1030                 // Call ShowAndWait - draw, show itself and process events
1031                 int modalResult = 0;
1032                 messageBox.ShowAndWait(modalResult);
1033
1034                 LoadDirectoryForm();
1035         }
1036         break;
1037
1038         default:
1039                 break;
1040         }
1041
1042 CATCH:
1043         if (pArgs != null)
1044         {
1045                 pArgs->RemoveAll(false);
1046                 delete pArgs;
1047                 pArgs = null;
1048         }
1049
1050         AppLogDebug("EXIT");
1051 }
1052
1053 result
1054 SubBaseMoveCopy::LoadDirectoryForm(void)
1055 {
1056         AppLogDebug("ENTER");
1057         result r = E_SUCCESS;
1058         ArrayList* pArg = null;
1059         String fileName;
1060         SceneManager* pSceneManager = null;
1061         pSceneManager = SceneManager::GetInstance();
1062
1063         FolderNavigationPresentationModel::SetCurrentFilePath(_rootPath);
1064         if (_moveCopySource == MOVE_COPY_SOURCE_SUB_FOLDER)
1065         {
1066                 String delim(L"/");
1067                 String token;
1068                 StringTokenizer strTok(_rootPath, delim);
1069                 while (strTok.HasMoreTokens())
1070                 {
1071                         strTok.GetNextToken(token);
1072                 }
1073                 fileName.Append(token);
1074                 pArg = new (std::nothrow) ArrayList();
1075                 r = pArg->Construct();
1076                 pArg->Add(&fileName);
1077         }
1078
1079         if (_moveCopySource == MOVE_COPY_SOURCE_TOP_MOST)
1080         {
1081                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
1082         }
1083         else
1084         {
1085                 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pArg);
1086         }
1087         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1088         return r;
1089 }