NABI_Se issues resolved
[apps/osp/MyFiles.git] / src / MfSubBaseFileManageForm.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: MfSubBaseFileManageForm.cpp
19  * @brief: This file contains the implementation of SubBaseFileManageForm class,
20  * and is responsible for creating the Edit View form.
21  * Operations like copy, move, delete can be performed in this form.
22  */
23
24 #include <FApp.h>
25
26 #include "MfDirectoryEntry.h"
27 #include "MfSubBaseFileManageForm.h"
28 #include "MfSceneRegister.h"
29 #include "MfTypes.h"
30
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Runtime;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Io;
37 using namespace Tizen::Locales;
38 using namespace Tizen::System;
39 using namespace Tizen::Ui;
40 using namespace Tizen::Ui::Animations;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43
44 FolderEntryPresentationModel* SubBaseFileManageForm::_pFolderEntryPM = null;
45
46 /*Constructor for the Edit Form.
47  * Variable are initialised to null or other default values
48  */
49 SubBaseFileManageForm::SubBaseFileManageForm(void)
50         : _pBaseItemProvider(null)
51         , _pCustomListViewForPopup(null)
52         , _pFileManager(null)
53         , _pMediaMetaData(null)
54         , _pThumbnailItemProvider(null)
55         , _pThumbnailManager(null)
56         , _pFilenames(null)
57         , _pStrItemSelectedCount(null)
58         , _isSelectAll(false)
59         , _pCancelDeletion(null)
60         , _pDeleteFile(null)
61         , _pFileProgressingCancelButton(null)
62         , _pShareContextMenu(null)
63         , _pMoreContextMenu(null)
64         , _pFooter(null)
65         , _pDelete(null)
66         , _pShare(null)
67         , _pEditIconListView(null)
68         , _pFileProgressingLabel(null)
69         , _pFileProgressingHeaderLabel(null)
70         , _pLabelNumberOfItems(null)
71         , _pEditListView(null)
72         , _pItemContext(null)
73         , _pDeleteConfirmationPopUp(null)
74         , _pFileProgressingPopup(null)
75         , _pAnimationProgress(null)
76     ,_pFileEventManager(null)
77 {
78         _fileCount = 0;
79         _fileProcessedCount = 0;
80         _folderCount = 0;
81         _renameItemIndex = 0;
82         _editOrShare = FILE_MANAGE_EDIT;
83
84 }
85
86 SubBaseFileManageForm::~SubBaseFileManageForm(void)
87 {
88         if (_pStrItemSelectedCount != null)
89         {
90                 delete _pStrItemSelectedCount;
91         }
92
93
94         if (_pFileManager != null)
95         {
96                 _pFileManager->ClearCheckedList();
97         }
98
99         if (_pMoreContextMenu != null)
100         {
101                 delete _pMoreContextMenu;
102         }
103
104         if (_pFileProgressingPopup != null)
105         {
106                 delete _pFileProgressingPopup;
107         }
108
109         if (_pDelete != null)
110         {
111                 delete _pDelete;
112         }
113
114         if (_pShare != null)
115         {
116                 delete _pShare;
117         }
118
119         if (_pDeleteConfirmationPopUp != null)
120         {
121                 delete _pDeleteConfirmationPopUp;
122         }
123
124         if (_pThumbnailItemProvider != null)
125         {
126                 delete _pThumbnailItemProvider;
127         }
128         if (_pShareContextMenu != null)
129         {
130                 delete _pShareContextMenu;
131         }
132         if (_pBaseItemProvider != null)
133         {
134                 delete _pBaseItemProvider;
135         }
136         if(_pFileEventManager != null)
137         {
138                 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
139                 delete _pFileEventManager;
140                 _pFileEventManager = null;
141         }
142         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
143 }
144
145 void
146 SubBaseFileManageForm::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
147 {
148         AppLogDebug("Entry");
149         int selectedItemsCount = 0;
150         int h_ListView = 0;
151         int itemCount = 0;
152         int fileCount = 0;
153         int folderCount = 0;
154         String btnMove;
155         String btnCopy;
156         DirectoryEntry* pCheckedEntry = null;
157         Bitmap* pBitmapCopyContextItem = null;
158         Bitmap* pBitmapMoveContextItem = null;
159
160         String selected;
161
162         AppResource* pAppResource = null;
163         pAppResource = UiApp::GetInstance()->GetAppResource();
164
165         if (pAppResource != null)
166         {
167                 pAppResource->GetString(L"IDS_MF_SK3_MOVE", btnMove);
168                 pAppResource->GetString(L"IDS_MF_SK3_COPY", btnCopy);
169                 pAppResource->GetString(L"IDS_COM_BODY_SELECTED", selected);
170                 pBitmapCopyContextItem = pAppResource->GetBitmapN(IDB_POPUP_COPY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
171                 pBitmapMoveContextItem = pAppResource->GetBitmapN(IDB_POPUP_MOVE_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
172         }
173
174         h_ListView = GetClientAreaBounds().height - H_CHECK_BUTTON - H_DISPLAY_PATH_LABEL;
175
176         Rectangle listViewBounds(X_DEFAULT, H_CHECK_BUTTON, GetClientAreaBounds().width, h_ListView);
177
178         switch (actionId)
179         {
180         case IDA_BTN_DELETE:
181         {
182                 CreateDeleteConfirmationPopUp();
183
184                 if (_pDeleteConfirmationPopUp != null)
185                 {
186                         _pDeleteConfirmationPopUp->SetShowState(true);
187                         _pDeleteConfirmationPopUp->Show();
188                 }
189         }
190         break;
191
192         case IDA_DELETE_FILE:
193         {
194                 if (_pDeleteConfirmationPopUp != null)
195                 {
196                         _pDeleteConfirmationPopUp->SetShowState(false);
197                 }
198
199                 if (_pDeleteConfirmationPopUp != null)
200                 {
201                         delete _pDeleteConfirmationPopUp;
202                         _pDeleteConfirmationPopUp = null;
203                 }
204
205                 if (_pFileManager != null && _pFileManager->IsCheckedListNull() == false)
206                 {
207                         if (_pFileManager->GetCheckedListCount() > 0)
208                         {
209                                 if (_pFileEventManager != null)
210                                 {
211                                         _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
212                                         delete _pFileEventManager;
213                                         _pFileEventManager = null;
214                                 }
215                                 AppLogDebug("remove path result %s",GetErrorMessage(GetLastResult()));
216                                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
217                                 ShowFileProgressingPopup();
218                                 DeleteFile();
219                                 SetFooterVisibility(ENABLE_FOOTER_ITEM);
220                         }
221                         else
222                         {
223                                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
224                         }
225                 }
226         }
227         break;
228
229         case IDA_CANCEL_DELETION:
230         {
231                 _isSelectAll = false;
232
233                 if (_pDeleteConfirmationPopUp != null)
234                 {
235                         _pDeleteConfirmationPopUp->SetShowState(false);
236                 }
237         }
238         break;
239
240         case IDA_BTN_ANIMATION_POPUP_CANCEL:
241         {
242                 HideFileProgressingPopup();
243
244                 _isSelectAll = false;
245
246                 if (_pFileManager != null)
247                         _pFileManager->ForceStopWorkerThread();
248
249                 if (_pEditListView != null && _pEditListView->IsVisible())
250                 {
251                         for (itemCount = 0;itemCount < _pEditListView->GetItemCount(); itemCount++)
252                         {
253                                 _pEditListView->SetItemChecked(itemCount,false);
254                         }
255                 }
256
257                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
258                 {
259                         if (_pThumbnailItemProvider != null)
260                         {
261                                 for (itemCount = 0; itemCount < _pThumbnailItemProvider->GetItemCount(); itemCount++)
262                                 {
263                                         _pEditIconListView->SetItemChecked(itemCount,false);
264
265                                 }
266                         }
267                 }
268         }
269         break;
270
271         case IDA_BTN_SHARE:
272         {
273                 CreateShareContextMenu();
274
275                 if (_pShareContextMenu != null)
276                 {
277                         _pShareContextMenu->SetShowState(true);
278                         _pShareContextMenu->Show();
279                 }
280         }
281         break;
282
283         case IDA_BTN_MOVE:
284         {
285                 if (_pFileManager != null && _pFileManager->IsCheckedListNull() == false)
286                 {
287                         if (_pFileManager->GetCheckedListCount() > 0)
288                         {
289                                 SetFooterVisibility(ENABLE_FOOTER_ITEM);
290                                 MoveFile();
291                         }
292                         else
293                         {
294                                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
295                         }
296                 }
297         }
298         break;
299
300         case IDA_BTN_COPY:
301         {
302                 if (_pFileManager != null && _pFileManager->IsCheckedListNull() == false)
303                 {
304                         if (_pFileManager->GetCheckedListCount() > 0)
305                         {
306                                 SetFooterVisibility(ENABLE_FOOTER_ITEM);
307                                 CopyFile();
308                         }
309                         else
310                         {
311                                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
312                         }
313                 }
314         }
315         break;
316
317         case IDA_BTN_MORE:
318         {
319                 _pMoreContextMenu->RemoveAllItems();
320                 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
321                 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
322                 _pMoreContextMenu->AddItem(btnMove, IDA_BTN_MOVE, *pBitmapMoveContextItem, null, null);
323                 _pMoreContextMenu->AddItem(btnCopy, IDA_BTN_COPY, *pBitmapCopyContextItem, null, null);
324                 _pMoreContextMenu->SetShowState(true);
325                 _pMoreContextMenu->Show();
326         }
327         break;
328
329         case IDA_BTN_CANCEL:
330         {
331                 SceneManager* pSceneManager = null;
332                 FolderNavigationPresentationModel::SetCurrentFilePath(_currentDirectoryPath);
333                 pSceneManager = SceneManager::GetInstance();
334
335                 if (pSceneManager != null)
336                 {
337                         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
338                 }
339         }
340         break;
341
342         case IDA_BTN_CHECKED:
343         {
344                 _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), folderCount, fileCount);
345
346                 if (_isSelectAll == false)
347                 {
348                         _isSelectAll = true;
349                         //Clear the existing entries of CheckedList
350                         if (_pFileManager != null)
351                         {
352                                 _pFileManager->ClearCheckedList();
353                         }
354                         //Add all entries to CheckedList!
355                         for (int itemcount = 0; itemcount < _pFilenames->GetCount(); itemcount++)
356                         {
357
358                                 if (_editOrShare == FILE_MANAGE_EDIT)
359                                 {
360                                         pCheckedEntry = static_cast< DirectoryEntry* >(_pFilenames->GetAt(itemcount));
361
362                                         if (_pFileManager != null /* && pCheckedEntry != null*/)
363                                         {
364                                                 _pFileManager->AddCheckedListEntry(itemcount, pCheckedEntry);
365                                         }
366                                         if (_pEditListView != null && _pEditListView->IsVisible())
367                                         {
368                                                 _pEditListView->SetItemChecked(itemcount, true);
369                                         }
370
371                                         if (_pEditIconListView != null && _pEditIconListView->IsVisible())
372                                         {
373                                                 _pEditIconListView->SetItemChecked(itemcount, true);
374                                         }
375                                 }
376                                 else
377                                 {
378                                         pCheckedEntry = static_cast< DirectoryEntry* >(_pFilenames->GetAt(itemcount));
379
380                                         if (!pCheckedEntry->IsDirectory())
381                                         {
382                                                 if (_pFileManager != null /* && pCheckedEntry != null*/)
383                                                 {
384                                                         _pFileManager->AddCheckedListEntry(itemcount, pCheckedEntry);
385                                                 }
386                                                 if (_pEditListView != null && _pEditListView->IsVisible())
387                                                 {
388                                                         _pEditListView->SetItemChecked(itemcount - folderCount, true);
389                                                 }
390
391                                                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
392                                                 {
393                                                         _pEditIconListView->SetItemChecked(itemcount - folderCount, true);
394                                                 }
395                                         }
396                                 }
397                                 AppLogDebug("Added to CheckedList! %ls", pCheckedEntry->GetFileName().GetPointer());
398                         }
399
400                         if (_pFileManager != null)
401                         {
402                                 selectedItemsCount = _pFileManager->GetCheckedListCount();
403                         }
404
405                         _pStrItemSelectedCount->Clear();
406                         _pStrItemSelectedCount->Append(selected);
407                         _pStrItemSelectedCount->Append(L"\x200E");
408                         _pStrItemSelectedCount->Append(L" (");
409                         _pStrItemSelectedCount->Append(selectedItemsCount);
410                         _pStrItemSelectedCount->Append(L")");
411                         _pStrItemSelectedCount->Append(L"\x200E");
412
413                         if (_pLabelNumberOfItems != null)
414                         {
415                                 _pLabelNumberOfItems->SetShowState(true);
416                                 _pLabelNumberOfItems->SetText(*_pStrItemSelectedCount);
417                                 _pLabelNumberOfItems->Invalidate(true);
418                         }
419
420                         if (selectedItemsCount > 0)
421                         {
422                                 SetFooterVisibility(ENABLE_FOOTER_ITEM);
423                         }
424                         else
425                         {
426                                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
427                         }
428                 }
429                 else
430                 {
431                         _isSelectAll = false;
432                         h_ListView = GetClientAreaBounds().height - H_CHECK_BUTTON;
433
434                         for (int itemcount = 0; itemcount < _pFilenames->GetCount(); itemcount++)
435                         {
436                                 if (_pEditListView != null && _pEditListView->IsVisible())
437                                 {
438                                         _pEditListView->SetItemChecked(itemcount, false);
439                                 }
440
441                                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
442                                 {
443                                         _pEditIconListView->SetItemChecked(itemcount, false);
444                                 }
445                         }
446
447                         if (_pFileManager != null)
448                         {
449                                 _pFileManager->ClearCheckedList();
450                         }
451
452                         if (_pLabelNumberOfItems != null)
453                         {
454                                 _pLabelNumberOfItems->SetShowState(false);
455                         }
456
457                         SetFooterVisibility(DISABLE_FOOTER_ITEM);
458                 }
459
460                 if (_pLabelNumberOfItems != null && _pLabelNumberOfItems->GetShowState() == true)
461                 {
462                         if (_pEditIconListView != null && _pEditIconListView->IsVisible())
463                         {
464                                 _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
465
466                                 _pEditIconListView->Invalidate(true);
467                         }
468
469                         if (_pEditListView != null && _pEditListView->IsVisible())
470                         {
471                                 _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
472
473                                 _pEditListView->Invalidate(true);
474                         }
475                 }
476                 else
477                 {
478                         if (_pEditIconListView != null && _pEditIconListView->IsVisible())
479                         {
480                                 _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
481
482                                 _pEditIconListView->Invalidate(true);
483                         }
484
485                         if (_pEditListView != null && _pEditListView->IsVisible())
486                         {
487                                 _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
488
489                                 _pEditListView->Invalidate(true);
490                         }
491                 }
492         }
493         break;
494
495         case IDA_BTN_SHARE_MESSAGE:
496         {
497                 ShareFile(SHARE_VIA_MESSAGE);
498         }
499         break;
500
501         case IDA_BTN_SHARE_EMAIL:
502         {
503                 ShareFile(SHARE_VIA_EMAIL);
504         }
505         break;
506
507         case IDA_BTN_SHARE_BLUETOOTH:
508         {
509 #if 0
510                 ShareFile(SHARE_VIA_BLUETOOTH);
511 #endif
512         }
513         break;
514
515         case IDA_BTN_SHARE_WIFI_DIRECT:
516         {
517 #if 0
518                 ShareFile(SHARE_VIA_WIFIDIRECT);
519 #endif
520         }
521         break;
522
523         default:
524         {
525                 //Do Nothing.
526         }
527         break;
528         }
529
530         if (pBitmapCopyContextItem != null)
531         {
532                 delete pBitmapCopyContextItem;
533                 pBitmapCopyContextItem = null;
534         }
535         if (pBitmapMoveContextItem != null)
536         {
537                 delete pBitmapMoveContextItem;
538                 pBitmapMoveContextItem = null;
539         }
540
541         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
542 }
543
544 void
545 SubBaseFileManageForm::SubBaseOnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
546 {
547         AppLogDebug("Entry");
548
549         int selectedItemsCount = 0;
550         int fileCount = 0;
551         int folderCount = 0;
552         int itemIndex = INVALID_LIST_INDEX;
553
554
555         _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), folderCount, fileCount);
556
557         DirectoryEntry* pCheckedEntry = null;
558         String selected;
559
560         AppResource* pAppResource = null;
561         pAppResource = UiApp::GetInstance()->GetAppResource();
562         if (pAppResource != null)
563         {
564                 pAppResource->GetString(L"IDS_COM_BODY_SELECTED", selected);
565         }
566
567         if (_editOrShare == FILE_MANAGE_SHARE)
568         {
569                 itemIndex = folderCount + index;
570         }
571         else
572         {
573                 itemIndex = index;
574         }
575
576         _renameItemIndex = index;
577
578         if (elementId == CONTENT_LIST_ITEM_TYPE_RENAME || elementId == DETAILED_LIST_ELEMENTS_RENAME)
579         {
580                 if (listView.IsItemChecked(index) == false)
581                 {
582                         listView.SetItemChecked(index, true);
583                 }
584                 else
585                 {
586                         listView.SetItemChecked(index, false);
587                 }
588                 if (_pFileEventManager != null)
589                 {
590                         _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
591                         delete _pFileEventManager;
592                         _pFileEventManager = null;
593                 }
594                 LoadRenameForm(index);
595
596                 return;
597         }
598         else
599         {
600                 _renameItemIndex = INVALID_LIST_INDEX;
601         }
602
603         pCheckedEntry = static_cast< DirectoryEntry* >(_pFilenames->GetAt(itemIndex));
604         TryCatch(pCheckedEntry != null,, "Failed to retieve Directory Entry from ArrayList");
605
606
607         if (_pLabelNumberOfItems != null)
608         {
609                 _pLabelNumberOfItems->SetShowState(true);
610         }
611
612         if (listView.IsItemChecked(index) == false)
613         {
614                 _isSelectAll = false;
615
616                 if (_pFileManager != null)
617                         _pFileManager->RemoveCheckedListEntry(itemIndex);
618         }
619         else
620         {
621                 if (_editOrShare == FILE_MANAGE_SHARE)
622                 {
623                         if (! pCheckedEntry->IsDirectory())
624                         {
625                                 if (pCheckedEntry != null && _pFileManager != null)
626                                 {
627                                         _pFileManager->AddCheckedListEntry(itemIndex, pCheckedEntry);
628                                 }
629                         }
630                 }
631                 else
632                 {
633                         if (pCheckedEntry != null && _pFileManager != null)
634                         {
635                                 _pFileManager->AddCheckedListEntry(itemIndex, pCheckedEntry);
636                         }
637                 }
638         }
639
640         selectedItemsCount = 0;
641
642         if(_pFileManager != null)
643         {
644                 selectedItemsCount = _pFileManager->GetCheckedListCount();
645         }
646
647         if (selectedItemsCount == 0)
648         {
649                 _isSelectAll = false;
650
651                 if (_pLabelNumberOfItems != null)
652                 {
653                         _pLabelNumberOfItems->SetShowState(false);
654                 }
655                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
656         }
657         else
658         {
659                 if (_editOrShare == FILE_MANAGE_EDIT)
660                 {
661                         if (selectedItemsCount == _pFilenames->GetCount())
662                         {
663                                 _isSelectAll = true;
664                         }
665                 }
666                 else
667                 {
668                         if (selectedItemsCount == fileCount)
669                         {
670                                 _isSelectAll = true;
671                         }
672                 }
673                 //Selected Item Count Not Equal to Zero, Display the Label.
674                 if (_pLabelNumberOfItems != null)
675                 {
676                         _pLabelNumberOfItems->SetShowState(true);
677                         _pStrItemSelectedCount->Clear();
678                         _pStrItemSelectedCount->Append(selected);
679                         _pStrItemSelectedCount->Append(L"\x200E");
680                         _pStrItemSelectedCount->Append(L" (");
681                         _pStrItemSelectedCount->Append(selectedItemsCount);
682                         _pStrItemSelectedCount->Append(L")");
683                         _pStrItemSelectedCount->Append(L"\x200E");
684
685                         _pLabelNumberOfItems->SetText(*_pStrItemSelectedCount);
686
687                         _pLabelNumberOfItems->Invalidate(true);
688                 }
689
690                 SetFooterVisibility(ENABLE_FOOTER_ITEM);
691         }
692         if (_pLabelNumberOfItems != null && _pLabelNumberOfItems->GetShowState() == true)
693         {
694                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
695                 {
696                         _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
697
698                         _pEditIconListView->Invalidate(true);
699                 }
700
701                 if (_pEditListView != null && _pEditListView->IsVisible())
702                 {
703                         _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
704
705                         _pEditListView->Invalidate(true);
706                 }
707         }
708         else
709         {
710                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
711                 {
712                         _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
713
714                         _pEditIconListView->Invalidate(true);
715                 }
716
717                 if (_pEditListView != null && _pEditListView->IsVisible())
718                 {
719                         _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
720
721                         _pEditListView->Invalidate(true);
722                 }
723         }
724
725         if (_pFileManager != null && _pFileManager->IsCheckedListNull() == false)
726         {
727                 if (_pFileManager->GetCheckedListCount() > 0)
728                 {
729                         SetFooterVisibility(ENABLE_FOOTER_ITEM);
730                 }
731                 else
732                 {
733                         SetFooterVisibility(DISABLE_FOOTER_ITEM);
734                 }
735         }
736
737         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
738         return;
739
740         CATCH:
741         return;
742 }
743
744
745 void
746 SubBaseFileManageForm::SubBaseOnThumbnailReceived(ThumbRequest* pThumbReq)
747 {
748         result res = E_SUCCESS;
749         AppLogDebug("Enter");
750
751         if (_pFolderEntryPM)
752         {
753                 if (pThumbReq != null)
754                 {
755                         if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
756                         {
757                                 if (pThumbReq->pBitmap != null)
758                                 {
759                                         AppLogDebug("This Bitmap is not requested from same form");
760                                         delete pThumbReq->pBitmap;
761                                 }
762                                 return;
763                         }
764                 }
765                 if (pThumbReq)
766                 {
767                         if (pThumbReq->iRquestId < _pFilenames->GetCount())
768                         {
769                                 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
770                                 if (_pEditListView && _pEditListView->IsVisible())
771                                 {
772                                         res = _pEditListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
773                                 }
774                                 else if (_pEditIconListView && _pEditIconListView->IsVisible())
775                                 {
776                                         res = _pEditIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
777                                 }
778                         }
779                 }
780                 else
781                 {
782                         _pFolderEntryPM->OnThumbnailResponseFailed();
783                 }
784         }
785         AppLogDebug("Exit %s", GetErrorMessage(res));
786         return;
787 }
788
789 void
790 SubBaseFileManageForm::CreateFooterControls(void)
791 {
792         AppLogDebug("Entry");
793         String btnDelete;
794         String btnShare;
795         String btnCancel;
796         Bitmap* pBitmap = null;
797         Bitmap* pBitmapDisabled = null;
798         Bitmap* pBitmapPress = null;
799         AppResource* pAppResource = null;
800
801         pAppResource = Application::GetInstance()->GetAppResource();
802         if (pAppResource != null)
803         {
804                 pAppResource->GetString(L"IDS_COM_BUTTON_SHARE", btnShare);
805                 pAppResource->GetString(L"IDS_COM_POP_CANCEL", btnCancel);
806                 pAppResource->GetString(L"IDS_MF_SK3_DELETE", btnDelete);
807                 pBitmap = pAppResource->GetBitmapN(IDB_MORE, BITMAP_PIXEL_FORMAT_ARGB8888);
808                 pBitmapDisabled = pAppResource->GetBitmapN(IDB_MORE_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888);
809                 pBitmapPress = pAppResource->GetBitmapN(IDB_MORE_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
810
811         }
812         _pButtonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_BTN_MORE);
813
814         _pDelete = new (std::nothrow) FooterItem();
815         _pDelete->Construct(IDA_BTN_DELETE);
816         _pDelete->SetText(btnDelete);
817
818         _pShare = new (std::nothrow) FooterItem();
819         _pShare->Construct(IDA_BTN_SHARE);
820         _pShare->SetText(btnShare);
821
822         TryCatch(pBitmap != null, , "MfMyFilesApp::Bitmap pBitmap null");
823         TryCatch(pBitmapDisabled != null, , "MfMyFilesApp::Bitmap pBitmapDisabled null");
824         TryCatch(pBitmapPress != null, , "MfMyFilesApp::Bitmap pBitmapPress null");
825
826         pBitmap->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
827         _pButtonItemMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap);
828
829         pBitmapDisabled->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
830         _pButtonItemMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapDisabled);
831
832         pBitmapPress->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
833         _pButtonItemMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapPress);
834
835
836         _pFooter = GetFooter();
837         if (_pFooter != null)
838         {
839                 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
840
841                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
842
843                 //Set am ActionEventListener to the Footer
844                 _pFooter->AddActionEventListener(*this);
845         }
846
847         ToggleFooter();
848
849         return;
850 CATCH:
851
852         if (pBitmap != null)
853         {
854                 delete pBitmap;
855         }
856         if (pBitmapDisabled != null)
857         {
858                 delete pBitmapDisabled;
859         }
860         return;
861 }
862
863 void
864 SubBaseFileManageForm::RemoveFooter(void)
865 {
866         _pFooter = GetFooter();
867         if (_pFooter != null)
868         {
869                 _pFooter->RemoveAllItems();
870                 _pFooter->RemoveAllButtons();
871         }
872 }
873
874 void
875 SubBaseFileManageForm::DeleteFile(void)
876 {
877         //_pFolderEntryPM->SetFileEventListener(null);
878         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
879         if (_pFileManager != null)
880                 _pFileManager->DeleteFolderEntries();
881
882 }
883
884 void
885 SubBaseFileManageForm::CopyFile(void)
886 {
887         AppLogDebug("Entry");
888         Integer* pSourceForm = null;
889         SceneManager* pSceneManager = SceneManager::GetInstance();
890         ArrayList* pArgs = null;
891
892         pArgs = new (std::nothrow) ArrayList();
893         TryCatch(pArgs != null, , "pArgs is null.");
894         pSourceForm = new (std::nothrow) Integer(SELECT_COPY_BUTTON);
895
896         //_pFolderEntryPM->SetFileEventListener(null);
897
898         pArgs->Construct();
899
900         pArgs->Add(pSourceForm);
901
902         TryCatch(pSceneManager != null, , "SceneManager is null.");
903
904         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_COPY_MOVE_FORM),pArgs);
905         return;
906 CATCH:
907
908         if (pSourceForm != null)
909         {
910                 delete pSourceForm;
911                 pSourceForm = null;
912         }
913
914         if (pArgs != null)
915         {
916                 delete pArgs;
917                 pArgs = null;
918         }
919 }
920
921 void
922 SubBaseFileManageForm::MoveFile(void)
923 {
924         AppLogDebug("Entry");
925         Integer* pSourceForm;
926
927         ArrayList* pArgs = null;
928         SceneManager* pSceneManager = null;
929
930         pSceneManager = SceneManager::GetInstance();
931
932         pSourceForm = new (std::nothrow) Integer(SELECT_MOVE_BUTTON);
933
934         pArgs = new (std::nothrow) ArrayList();
935         TryCatch(pArgs != null, , "pArgs is null.");
936         //_pFolderEntryPM->SetFileEventListener(null);
937
938         pArgs->Construct();
939         pArgs->Add(pSourceForm);
940
941         TryCatch(pSceneManager != null, , "SceneManager is null.");
942
943         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_COPY_MOVE_FORM),pArgs);
944         //_pCheckedList = null;
945         return;
946
947 CATCH:
948         if (pSourceForm != null)
949         {
950                 delete pSourceForm;
951                 pSourceForm = null;
952         }
953
954         if (pArgs != null)
955         {
956                 delete pArgs;
957                 pArgs = null;
958         }
959
960         return;
961 }
962
963 void
964 SubBaseFileManageForm::ShareFile(ShareVia shareType)
965 {
966         AppLogDebug("Entry");
967         DirectoryEntry* ptempDirEntry = null;
968         IMapEnumerator* pMapEnum = null;
969         AppControl* pAc = null;
970         const String* pAttachKey = null;
971         const String* pUriType = null;
972         //const HashMap* pResultHash = null;
973         result r = E_SUCCESS;
974
975         HashMap dataList;
976         ArrayList* filePathList = null;
977         MessageBox messageBox;
978         int modalResult = 0;
979
980         dataList.Construct();
981         pAttachKey = new (std::nothrow) const String(L"http://tizen.org/appcontrol/data/path");
982
983         switch (shareType)
984         {
985         case SHARE_VIA_EMAIL:
986         {
987                 pAc = AppManager::FindAppControlN(L"tizen.email", "http://tizen.org/appcontrol/operation/compose");
988         }
989         break;
990
991         case SHARE_VIA_MESSAGE:
992         {
993                 pUriType = new (std::nothrow) const String(L"mmsto");
994                 pAc = AppManager::FindAppControlN(L"tizen.messages", "http://tizen.org/appcontrol/operation/compose");
995         }
996         break;
997
998         default:
999         {
1000                 //Do Nothing
1001         }
1002         break;
1003         }
1004         //pResultHash = FolderEntryEditorPresentationModel::GetInstance()->GetCheckedList();
1005
1006         if (_pFileManager != null && _pFileManager->IsCheckedListNull() == false)
1007         {
1008                 pMapEnum = _pFileManager->GetCheckedList()->GetMapEnumeratorN();
1009                 if (pMapEnum != null)
1010                 {
1011                         if (filePathList == null)
1012                         {
1013                                 filePathList = new (std::nothrow) ArrayList();
1014                         }
1015                         while (pMapEnum->MoveNext() == E_SUCCESS)
1016                         {
1017                                 ptempDirEntry = static_cast< DirectoryEntry* >(pMapEnum->GetValue());
1018
1019                                 if (ptempDirEntry != null)
1020                                 {
1021                                         filePathList->Add(new (std::nothrow) String (ptempDirEntry->GetFullFilePath()));
1022                                 }
1023                         }
1024                 }
1025         }
1026
1027         dataList.Add(*pAttachKey,*filePathList);
1028         if (shareType == SHARE_VIA_MESSAGE)
1029         {
1030                 dataList.Add(new (std::nothrow) String (L"http://tizen.org/appcontrol/data/message/type"),new (std::nothrow) String (L"mms"));
1031         }
1032
1033         if (pAc != null)
1034         {
1035                 AppLogDebug("filePathList count is %d",filePathList->GetCount());
1036
1037                 if (shareType == SHARE_VIA_EMAIL)
1038                 {
1039                         r = pAc->Start(null, null, &dataList, null);
1040                 }
1041                 else if (shareType == SHARE_VIA_MESSAGE)
1042                 {
1043                         r = pAc->Start(pUriType, null, &dataList, null);
1044                 }
1045
1046                 //Before going to Message/Email appcontrol, remove FIleEventListener
1047                 //to avoid any file modification event
1048                 if ( r == E_SUCCESS)
1049                 {
1050                         if(_pFileEventManager != null)
1051                         {
1052                                 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1053                                 delete _pFileEventManager;
1054                                 _pFileEventManager = null;
1055                         }
1056                 }
1057
1058                 if (r == E_MAX_EXCEEDED)
1059                 {
1060                         messageBox.Construct(L"", L"Email Size Exceeded", MSGBOX_STYLE_OK);
1061                         messageBox.ShowAndWait(modalResult);
1062                 }
1063                 delete pAc;
1064         }
1065
1066         if (dataList.GetCount() > 0)
1067         {
1068                 if (filePathList != null)
1069                 {
1070                         filePathList->RemoveAll(true);
1071                 }
1072                 dataList.RemoveAll(true);
1073         }
1074         if (pUriType != null)
1075         {
1076                 delete pUriType;
1077         }
1078 }
1079
1080 void
1081 SubBaseFileManageForm::CreateLabelControl(void)
1082 {
1083         Color backgroundColor(68, 68, 68);
1084
1085         _pLabelNumberOfItems = new (std::nothrow) Label();
1086         if (_pLabelNumberOfItems != null)
1087         {
1088                 _pLabelNumberOfItems->Construct(Rectangle(X_DEFAULT, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL), *_pStrItemSelectedCount);
1089                 _pLabelNumberOfItems->SetBackgroundColor(backgroundColor);
1090                 _pLabelNumberOfItems->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1091                 _pLabelNumberOfItems->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1092                 _pLabelNumberOfItems->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1093                 _pLabelNumberOfItems->SetTextConfig(ID_FONT_SIZE_32, LABEL_TEXT_STYLE_BOLD);
1094                 _pLabelNumberOfItems->SetName(L"IDC_LABEL_COUNT");
1095
1096                 _pLabelNumberOfItems->SetShowState(false);
1097
1098                 AddControl(*_pLabelNumberOfItems);
1099         }
1100         return;
1101 }
1102
1103 void
1104 SubBaseFileManageForm::SetFooterVisibility(int mode)
1105 {
1106         AppLogDebug("ENTRY mode = %d",mode);
1107
1108         _pFooter = GetFooter();
1109
1110         if (mode == DISABLE_FOOTER_ITEM)
1111         {
1112                 _pFooter->SetItemEnabled(0, false);
1113                 _pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1114         }
1115         else
1116         {
1117                 _pFooter->SetItemEnabled(0, true);
1118                 _pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1119         }
1120         _pFooter->Invalidate(true);
1121 }
1122
1123 void
1124 SubBaseFileManageForm::SubBaseOnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status)
1125 {
1126         AppLogDebug("Entry");
1127         int itemIndex = INVALID_LIST_INDEX;
1128         int selectedItemsCount = 0;
1129         //int shareEnableFlag = 1;
1130
1131         int dirCount = 0;
1132         int fileCount = 0;
1133
1134         result r = E_SUCCESS;
1135         DirectoryEntry* pCheckedEntry = null;
1136         Integer indexToCheck(itemIndex);
1137         String selected;
1138
1139         AppResource* pAppResource = null;
1140         pAppResource = UiApp::GetInstance()->GetAppResource();
1141         if (pAppResource != null)
1142         {
1143                 pAppResource->GetString(L"IDS_COM_BODY_SELECTED", selected);
1144         }
1145
1146         _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), dirCount, fileCount);
1147
1148         if (_editOrShare == FILE_MANAGE_SHARE)
1149         {
1150                 itemIndex = dirCount + index;
1151         }
1152         else
1153         {
1154                 itemIndex = index;
1155         }
1156
1157         pCheckedEntry = static_cast< DirectoryEntry* >(_pFilenames->GetAt(itemIndex));
1158         TryCatch(pCheckedEntry != null, , "Failed to retrieve the directory entry for this index.");
1159
1160
1161
1162         //Set ShowState of the Label Displaying Selected Count as true
1163         if (_pLabelNumberOfItems != null)
1164         {
1165                 _pLabelNumberOfItems->SetShowState(true);
1166         }
1167
1168         //Check the item @ index if it is false.
1169         if (iconListView.IsItemChecked(index) == false)
1170         {
1171                 _isSelectAll = false;
1172
1173                 if (_pFileManager != null)
1174                         _pFileManager->RemoveCheckedListEntry(itemIndex);
1175         }
1176         else
1177         {
1178                 if (_editOrShare == FILE_MANAGE_SHARE)
1179                 {
1180                         if (!pCheckedEntry->IsDirectory())
1181                         {
1182                                 if (pCheckedEntry != null && _pFileManager != null)
1183                                 {
1184                                         _pFileManager->AddCheckedListEntry(itemIndex, pCheckedEntry);
1185                                 }
1186                         }
1187                 }
1188                 else
1189                 {
1190                         if (pCheckedEntry != null && _pFileManager != null)
1191                         {
1192                                 _pFileManager->AddCheckedListEntry(itemIndex, pCheckedEntry);
1193                         }
1194                 }
1195         }
1196
1197         if (_pFileManager != null)
1198         {
1199                 selectedItemsCount = _pFileManager->GetCheckedListCount();
1200         }
1201
1202         if (selectedItemsCount == 0)
1203         {
1204                 //If each item is unselected, set the showstate of the label to false.
1205                 if (_pFileManager != null)
1206                         _pFileManager->ClearCheckedList();
1207
1208                 if (_pLabelNumberOfItems != null)
1209                 {
1210                         _pLabelNumberOfItems->SetShowState(false);
1211                 }
1212
1213                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
1214
1215         }
1216         else
1217         {
1218                 //Else at least one item is selected and show the number of items selected on the label.
1219                 if (_pLabelNumberOfItems != null)
1220                 {
1221                         _pLabelNumberOfItems->SetShowState(true);
1222
1223                         _pStrItemSelectedCount->Clear();
1224                         _pStrItemSelectedCount->Append(selected);
1225                         _pStrItemSelectedCount->Append(L"\x200E");
1226                         _pStrItemSelectedCount->Append(L" (");
1227                         _pStrItemSelectedCount->Append(selectedItemsCount);
1228                         _pStrItemSelectedCount->Append(L")");
1229                         _pStrItemSelectedCount->Append(L"\x200E");
1230
1231                         AppLogDebug("Text on Label = %ls", _pStrItemSelectedCount->GetPointer());
1232
1233                         _pLabelNumberOfItems->SetText(*_pStrItemSelectedCount);
1234                         _pLabelNumberOfItems->Invalidate(true);
1235                 }
1236
1237                 SetFooterVisibility(ENABLE_FOOTER_ITEM);
1238         }
1239
1240         AppLogDebug("Exit %s", GetErrorMessage(r));
1241         return;
1242
1243 CATCH:
1244         return;
1245
1246 }
1247
1248
1249 void
1250 SubBaseFileManageForm::ShowFileProgressingPopup(void)
1251 {
1252         CreateFileProgressingPopup();
1253
1254         if (_pFileProgressingPopup != null)
1255         {
1256                 _pFileProgressingPopup->SetShowState(true);
1257                 _pFileProgressingPopup->Show();
1258         }
1259 }
1260
1261 void
1262 SubBaseFileManageForm::HideFileProgressingPopup(void)
1263 {
1264         if (_pFileProgressingPopup != null && _pFileProgressingPopup->IsVisible())
1265         {
1266                 _pFileProgressingPopup->SetShowState(false);
1267                 //_pFileProgressingPopup->Invalidate(true);
1268
1269                 //_pFileProgressingPopup->RemoveAllControls();
1270                 delete _pFileProgressingPopup;
1271                 _pFileProgressingPopup = null;
1272         }
1273 }
1274
1275 result
1276 SubBaseFileManageForm::CreateFileProgressingPopup(void)
1277 {
1278         result r = E_SUCCESS;
1279         //String popUpTitle;
1280         String deleting;
1281         String fileProgress;
1282
1283         AppResource* pAppResource = null;
1284
1285         if (_pFileProgressingPopup != null)
1286         {
1287                 //_pFileProgressingPopup->RemoveAllControls();
1288                 delete _pFileProgressingPopup;
1289                 _pFileProgressingPopup = null;
1290         }
1291
1292         pAppResource = UiApp::GetInstance()->GetAppResource();
1293
1294         if (pAppResource != null)
1295         {
1296                 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
1297         }
1298         _pFileProgressingPopup = new (std::nothrow) Popup();
1299         TryCatch(_pFileProgressingPopup != null, , "Failed to Allocate Memory to _pAnimationPopUp");
1300
1301         _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1302
1303         _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1304         if (_pFileProgressingCancelButton != null)
1305         {
1306                 _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1307                 _pFileProgressingCancelButton->AddActionEventListener(*this);
1308                 _pFileProgressingCancelButton->SetShowState(true);
1309         }
1310         _pAnimationProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1311         if (_pAnimationProgress != null)
1312         {
1313                 _pAnimationProgress->SetName(L"AnimationProgress");
1314                 _pAnimationProgress->SetValue(0);
1315         }
1316
1317         _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1318         if (_pFileProgressingHeaderLabel != null)
1319         {
1320                 _pFileProgressingHeaderLabel->SetText(deleting);
1321                 _pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
1322                 _pFileProgressingHeaderLabel->SetShowState(true);
1323         }
1324         _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1325         if (_pFileProgressingLabel != null)
1326         {
1327                 _pFileProgressingLabel->SetName(L"FileCountLabel");
1328                 _pFileProgressingLabel->SetText(L"");
1329                 _pFileProgressingLabel->SetShowState(false);
1330         }
1331
1332         return r;
1333
1334 CATCH:
1335         if (_pFileProgressingPopup != null)
1336         {
1337                 delete _pFileProgressingPopup;
1338                 _pFileProgressingPopup = null;
1339         }
1340         return r;
1341 }
1342 void
1343 SubBaseFileManageForm::SubBaseOnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1344 {
1345         AppLogDebug("Entry");
1346
1347         result r = E_SUCCESS;
1348         Integer* pCurrentStatus = null;
1349         Integer* pTotalCount = null;
1350         String fileProcessCountText;
1351         Integer* pFileProcessingResult = null;
1352         Integer* pFolderEntryDeleteIndex = null;
1353
1354         Rectangle listViewBounds(X_DEFAULT, H_CHECK_BUTTON, GetClientAreaBounds().width, GetClientAreaBounds().height - H_CHECK_BUTTON);
1355
1356         int badgeNumber = 0;
1357
1358         Header* pHeader = null;
1359         pHeader = GetHeader();
1360         NotificationManager* pNotiManager = null;
1361         TryCatch(pArgs != null, , "Argument Lis Received is Invalid!");
1362
1363         pFileProcessingResult = (Integer*) pArgs->GetAt(0);
1364         TryCatch(pFileProcessingResult != null, , "File Processing Result is Invalid!");
1365
1366         pNotiManager = new (std::nothrow) NotificationManager();
1367         TryCatch(pNotiManager != null, , "Failed to fetch AppNotificationManager");
1368
1369         pNotiManager->Construct();
1370         badgeNumber = pNotiManager->GetBadgeNumber();
1371         badgeNumber++;
1372
1373         switch (pFileProcessingResult->ToInt())
1374         {
1375         case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1376         {
1377                 HideFileProgressingPopup();
1378                 if(_pFileEventManager == null)
1379                 {
1380                         _pFileEventManager = new (std::nothrow)FileEventManager();
1381                         _pFileEventManager->Construct(*this);
1382
1383                         _pFileEventManager->AddPath(FolderNavigationPresentationModel::GetCurrentPath(),FILE_EVENT_TYPE_DELETE);
1384
1385                 }
1386
1387                 if (_pFileManager != null)
1388                         _pFileManager->ClearCheckedList();
1389
1390                 if (_pLabelNumberOfItems != null)
1391                         _pLabelNumberOfItems->SetShowState(false);
1392
1393                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
1394
1395                 if (_pFilenames->GetCount() == 0)
1396                 {
1397
1398                         if (pHeader != null)
1399                         {
1400                                 pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, false);
1401                                 //pHeader->SetItemEnabled(0, false);
1402                                 pHeader->Invalidate(true);
1403                         }
1404                         SetFooterVisibility(DISABLE_FOOTER_ITEM);
1405                 }
1406         }
1407         break;
1408
1409         case FILE_MANAGING_RESULT_DELETING_FAILED:
1410         {
1411                 HideFileProgressingPopup();
1412                 if(_pFileEventManager == null)
1413                 {
1414                         _pFileEventManager = new (std::nothrow)FileEventManager();
1415                         _pFileEventManager->Construct(*this);
1416
1417                         _pFileEventManager->AddPath(FolderNavigationPresentationModel::GetCurrentPath(),FILE_EVENT_TYPE_DELETE);
1418
1419                 }
1420                 String deleteFailed;
1421                 AppResource* pAppResource = null;
1422                 pAppResource = Application::GetInstance()->GetAppResource();
1423                 pAppResource->GetString("IDS_MF_POP_DELETE_FAILED", deleteFailed);
1424
1425                 MessageBox messageBox;
1426                 messageBox.Construct(L"", deleteFailed, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1427                 int modalResult = 0;
1428                 messageBox.ShowAndWait(modalResult);
1429         }
1430         break;
1431
1432         case FILE_MANAGING_RESULT_CURRENT_STATUS:
1433         {
1434                 int value = 0;
1435                 if (pArgs->GetCount() > 1)
1436                 {
1437                         pCurrentStatus = (Integer*) pArgs->GetAt(1);
1438                         pTotalCount = (Integer*) pArgs->GetAt(2);
1439                         if (pCurrentStatus != null)
1440                         {
1441                                 _fileProcessedCount = pCurrentStatus->ToInt();
1442
1443                                 fileProcessCountText.Append(_fileProcessedCount);
1444                                 fileProcessCountText.Append(L"/");
1445                                 if (pTotalCount != null)
1446                                 {
1447                                         fileProcessCountText.Append(pTotalCount->ToInt());
1448                                         value = (_fileProcessedCount * 100) / pTotalCount->ToInt();
1449                                 }
1450                         }
1451                 }
1452
1453                 if (_pFileProgressingPopup != null)
1454                 {
1455                         if(_pAnimationProgress != null)
1456                         {
1457                                 _pAnimationProgress->SetValue(value);
1458                                 _pAnimationProgress->SetShowState(true);
1459                                 _pAnimationProgress->Invalidate(true);
1460                         }
1461                         if (_pFileProgressingLabel != null)
1462                         {
1463                                 _pFileProgressingLabel->SetText(fileProcessCountText);
1464                                 _pFileProgressingLabel->SetShowState(true);
1465                                 _pFileProgressingLabel->Invalidate(true);
1466                         }
1467                 }
1468         }
1469         break;
1470         case FILE_MANAGING_REFRESH_LIST:
1471         {
1472                 HashMap* pCacheList = null;
1473                 DirectoryEntry* pCurrentEntry = null;
1474                 bool cacheKeyStatus = false;
1475                 String cachePath;
1476
1477                 if (pArgs->GetCount() > 1)
1478                 {
1479                         pFolderEntryDeleteIndex = (Integer*) pArgs->GetAt(1);
1480
1481                         pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1482
1483                         if (pCacheList != null)
1484                         {
1485                                 pCurrentEntry = static_cast<DirectoryEntry*>(_pFilenames->GetAt(pFolderEntryDeleteIndex->ToInt()));
1486
1487                                 if (pCurrentEntry != null)
1488                                 {
1489                                         cachePath = pCurrentEntry->GetFullFilePath();
1490                                 }
1491
1492                                 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1493
1494                                 if (cacheKeyStatus)
1495                                 {
1496                                         CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1497                                 }
1498                         }
1499
1500                         if (pFolderEntryDeleteIndex != null)
1501                         {
1502                                 r = _pFilenames->RemoveAt(pFolderEntryDeleteIndex->ToInt());
1503                                 TryCatch(r == E_SUCCESS, , "Remove from array list failed");
1504                         }
1505
1506                         if (_pEditListView != null && _pEditListView->IsVisible())
1507                         {
1508                                 _pEditListView->RefreshList(pFolderEntryDeleteIndex->ToInt(), LIST_REFRESH_TYPE_ITEM_REMOVE);
1509                         }
1510
1511                         if (_pEditIconListView != null && _pEditIconListView->IsVisible())
1512                         {
1513                                 _pEditIconListView->RefreshList(pFolderEntryDeleteIndex->ToInt(), LIST_REFRESH_TYPE_ITEM_REMOVE);
1514                         }
1515                 }
1516         }
1517         break;
1518
1519         default:
1520         {
1521                 //Do Nothing.
1522         }
1523         break;
1524         }
1525
1526         if (_pLabelNumberOfItems != null && _pLabelNumberOfItems->GetShowState() == true)
1527         {
1528                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
1529                 {
1530                         _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
1531
1532                         _pEditIconListView->Invalidate(true);
1533                 }
1534
1535                 if (_pEditListView != null && _pEditListView->IsVisible())
1536                 {
1537                         _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
1538
1539                         _pEditListView->Invalidate(true);
1540                 }
1541         }
1542         else
1543         {
1544                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
1545                 {
1546                         _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
1547
1548                         _pEditIconListView->Invalidate(true);
1549                 }
1550
1551                 if (_pEditListView != null && _pEditListView->IsVisible())
1552                 {
1553                         _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
1554
1555                         _pEditListView->Invalidate(true);
1556                 }
1557         }
1558
1559         if (pNotiManager != null)
1560         {
1561                 delete pNotiManager;
1562                 pNotiManager = null;
1563         }
1564
1565         if (pArgs != null)
1566         {
1567                 pArgs->RemoveAll(true);
1568                 delete pArgs;
1569                 pArgs = null;
1570         }
1571
1572         return;
1573 CATCH:
1574
1575         if (pArgs != null)
1576         {
1577                 pArgs->RemoveAll(true);
1578                 delete pArgs;
1579                 pArgs = null;
1580         }
1581         if (pNotiManager != null)
1582         {
1583                 delete pNotiManager;
1584                 pNotiManager = null;
1585         }
1586         return;
1587 }
1588
1589 void
1590 SubBaseFileManageForm::LoadRenameForm(int index)
1591 {
1592         result r = E_SUCCESS;
1593         ArrayList* pArg = null;
1594         Integer* pSourceSelected = null;
1595         SceneManager* pSceneManager = null;
1596         DirectoryEntry* pDirectory = null;
1597
1598         if (_pFilenames != null)
1599         {
1600                 pDirectory = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
1601         }
1602
1603         pSceneManager = SceneManager::GetInstance();
1604         TryCatch(pSceneManager != null, , "Failed to Get SceneManager Instance");
1605
1606         pArg = new (std::nothrow) ArrayList();
1607         pArg->Construct();
1608
1609         pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
1610
1611         r = pArg->Add(pSourceSelected);
1612         TryCatch(r == E_SUCCESS, , "Failed to Add Entry to ArrayList");
1613         if (pDirectory != null)
1614         {
1615                 r = pArg->Add(pDirectory);
1616                 TryCatch(r == E_SUCCESS, , "Failed to Add Entry to ArrayList");
1617         }
1618         AppLogDebug("SubBaseFileManageForm: pArgs Count is %d", pArg->GetCount());
1619
1620         if (pSceneManager != null)
1621         {
1622                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
1623         }
1624         AppLogDebug("Exit %s", GetErrorMessage(r));
1625         return;
1626
1627 CATCH:
1628
1629         if (pSourceSelected != null)
1630         {
1631                 delete pSourceSelected;
1632                 pSourceSelected = null;
1633         }
1634         if (pArg != null)
1635         {
1636                 delete pArg;
1637                 pArg = null;
1638         }
1639         AppLogDebug("Exit %s", GetErrorMessage(r));
1640         return;
1641
1642 }
1643
1644 result
1645 SubBaseFileManageForm::CreateDeleteConfirmationPopUp(void)
1646 {
1647
1648         result r = E_SUCCESS;
1649         Rectangle popupBounds;
1650
1651         //Create a new popup control
1652         _pDeleteConfirmationPopUp = new (std::nothrow) Popup();
1653         _pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
1654
1655         _pDeleteFile = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
1656         TryCatch(_pDeleteFile != null, , "MfMyFilesApp::Button For Popup not created!");
1657
1658         _pDeleteFile->SetActionId(IDA_DELETE_FILE);
1659         _pDeleteFile->AddActionEventListener(*this);
1660         _pDeleteFile->SetShowState(true);
1661
1662         _pCancelDeletion = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
1663         TryCatch(_pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
1664
1665         _pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
1666         _pCancelDeletion->AddActionEventListener(*this);
1667         _pCancelDeletion->SetShowState(true);
1668         return r;
1669
1670 CATCH:
1671
1672         delete _pDeleteConfirmationPopUp;
1673         _pDeleteConfirmationPopUp = null;
1674
1675         return r;
1676 }
1677
1678 result
1679 SubBaseFileManageForm::CreateShareContextMenu(void)
1680 {
1681         AppLogDebug("Enter");
1682         result r = E_SUCCESS;
1683
1684         if (_pShareContextMenu != null)
1685         {
1686                 return E_SUCCESS;
1687         }
1688
1689         int x_Footer = 0;
1690         int y_Footer = 0;
1691
1692         String message;
1693         String eMail;
1694         String bluetooth;
1695         String wifiDirect;
1696
1697         AppResource* pAppResource = null;
1698         Bitmap* pBitmapEmailContextItem = null;
1699         Bitmap* pBitmapMessageContextItem = null;
1700 //      Bitmap* pBitmapBluetoothContextItem = null;
1701 //      Bitmap* pBitmapWiFiDirectContextItem = null;
1702
1703         _pFooter = GetFooter();
1704         if (_pFooter != null)
1705         {
1706                 _pFooter->GetPosition(x_Footer, y_Footer);
1707         }
1708
1709         Point startPosition(GetClientAreaBounds().width / 2, y_Footer - H_DISPLAY_PATH_LABEL);
1710
1711         pAppResource = Application::GetInstance()->GetAppResource();
1712         if (pAppResource != null)
1713         {
1714                 pAppResource->GetString(L"IDS_COM_BODY_MESSAGE", message);
1715                 pAppResource->GetString(L"IDS_COM_BODY_EMAIL", eMail);
1716                 pAppResource->GetString(L"IDS_COM_BODY_BLUETOOTH", bluetooth);
1717                 pAppResource->GetString(L"IDS_COM_OPT1_WI_FI_DIRECT", wifiDirect);
1718                 pBitmapEmailContextItem = pAppResource->GetBitmapN(IDB_POPUP_EMAIL_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1719                 pBitmapMessageContextItem = pAppResource->GetBitmapN(IDB_POPUP_MESSAGE_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1720
1721                 //pBitmapBluetoothContextItem = pAppResource->GetBitmapN(IDB_POPUP_BLUETOOTH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1722                 //pBitmapWiFiDirectContextItem = pAppResource->GetBitmapN(IDB_POPUP_WIFIDIRECT_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1723         }
1724         AppLogDebug("enter1");
1725         _pShareContextMenu = new (std::nothrow) ContextMenu();
1726         _pShareContextMenu->Construct(startPosition, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
1727         _pShareContextMenu->AddItem(message, IDA_BTN_SHARE_MESSAGE, *pBitmapMessageContextItem, null, null);
1728         _pShareContextMenu->AddItem(eMail, IDA_BTN_SHARE_EMAIL, *pBitmapEmailContextItem, null, null);
1729 #if 0
1730         _pShareContextMenu->AddItem(bluetooth, IDA_BTN_SHARE_BLUETOOTH, *pBitmapBluetoothContextItem, null, null);
1731         _pShareContextMenu->AddItem(wifiDirect, IDA_BTN_SHARE_WIFI_DIRECT, *pBitmapWiFiDirectContextItem, null, null);
1732 #endif
1733
1734         _pShareContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_BLACK));
1735         _pShareContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
1736
1737         _pShareContextMenu->SetShowState(false);
1738
1739         _pShareContextMenu->AddActionEventListener(*this);
1740
1741         AppLogDebug("EXIT");
1742         return r;
1743 }
1744
1745 void
1746 SubBaseFileManageForm::SortArrayList(Tizen::Base::Collection::ArrayList* pArrList)
1747 {
1748         for (int i = 0; i < pArrList->GetCount(); i++)
1749         {
1750                 Integer* PValue1 = (Integer*) pArrList->GetAt(i);
1751                 for (int j = i + 1; j < pArrList->GetCount(); j++)
1752                 {
1753                         Integer* PValue2 = (Integer*) pArrList->GetAt(j);
1754                         if (PValue1->ToInt() > PValue2->ToInt())
1755                         {
1756                                 int temp;
1757                                 temp = PValue1->ToInt();
1758                                 *PValue1 = *PValue2;
1759                                 *PValue2 = temp;
1760                         }
1761                 }
1762         }
1763         for (int i = 0; i < pArrList->GetCount(); i++)
1764         {
1765                 Integer* PValue1 = (Integer*) pArrList->GetAt(i);
1766                 AppLogDebug("%d", PValue1->ToInt());
1767         }
1768 }
1769
1770 void
1771 SubBaseFileManageForm::ToggleFooter(void)
1772 {
1773         int xPos = 0, yPos = 0;
1774
1775         _pFooter = GetFooter();
1776         TryReturn(_pFooter != null, , "Footer is Null");
1777         _pFooter->RemoveAllItems();
1778         _pFooter->RemoveAllButtons();
1779         _pFooter->SetBackButton();
1780         _pFooter->SetBackButtonEnabled(true);
1781
1782         switch (_editOrShare)
1783         {
1784         case FILE_MANAGE_EDIT:
1785         {
1786                 _pFooter->AddItem(*_pDelete);
1787                 _pFooter->SetButton(BUTTON_POSITION_LEFT, _pButtonItemMore);
1788                 _pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1789
1790                 _pMoreContextMenu = new (std::nothrow) ContextMenu();
1791                 _pFooter->GetPosition(xPos, yPos);
1792                 _pMoreContextMenu->Construct(Point(0 , yPos), CONTEXT_MENU_STYLE_LIST);
1793                 _pMoreContextMenu->AddActionEventListener(*this);
1794                 _pMoreContextMenu->SetShowState(false);
1795         }
1796         break;
1797         case FILE_MANAGE_SHARE:
1798         {
1799                 _pFooter->AddItem(*_pShare);
1800         }
1801         break;
1802
1803         default:
1804         break;
1805         }
1806         _pFooter->Invalidate(true);
1807 }
1808
1809 void
1810 SubBaseFileManageForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int      eventId)
1811 {
1812         AppLogDebug("SubBaseFileManageForm::OnFileEventOccured");
1813   SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1814 }
1815
1816 void
1817 SubBaseFileManageForm::OnAppControlCompleted(void)
1818 {
1819         AppLogDebug("SubBaseFileManageForm::OnAppControlCompleted");
1820         //On coming back from Email/Message appcontrol, register the FileEvent Listener back
1821         if(_pFileEventManager == null)
1822         {
1823                 _pFileEventManager = new (std::nothrow)FileEventManager();
1824                 _pFileEventManager->Construct(*this);
1825         }
1826         _pFileEventManager->AddPath(FolderNavigationPresentationModel::GetCurrentPath(),FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_MOVED_FROM);
1827 }