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         result r = E_SUCCESS;
973
974         HashMap dataList;
975         ArrayList* filePathList = null;
976         MessageBox messageBox;
977         int modalResult = 0;
978
979         //Disable the form to avoid any more clicks, if the share button is already clicked
980         SetEnabled(false);
981
982         dataList.Construct();
983         pAttachKey = new (std::nothrow) const String(L"http://tizen.org/appcontrol/data/path");
984
985         switch (shareType)
986         {
987         case SHARE_VIA_EMAIL:
988         {
989                 pAc = AppManager::FindAppControlN(L"tizen.email", "http://tizen.org/appcontrol/operation/compose");
990         }
991         break;
992
993         case SHARE_VIA_MESSAGE:
994         {
995                 pUriType = new (std::nothrow) const String(L"mmsto");
996                 pAc = AppManager::FindAppControlN(L"tizen.messages", "http://tizen.org/appcontrol/operation/compose");
997         }
998         break;
999
1000         default:
1001         {
1002                 //Do Nothing
1003         }
1004         break;
1005         }
1006
1007         if (_pFileManager != null && _pFileManager->IsCheckedListNull() == false)
1008         {
1009                 pMapEnum = _pFileManager->GetCheckedList()->GetMapEnumeratorN();
1010                 if (pMapEnum != null)
1011                 {
1012                         if (filePathList == null)
1013                         {
1014                                 filePathList = new (std::nothrow) ArrayList();
1015                         }
1016                         while (pMapEnum->MoveNext() == E_SUCCESS)
1017                         {
1018                                 ptempDirEntry = static_cast< DirectoryEntry* >(pMapEnum->GetValue());
1019
1020                                 if (ptempDirEntry != null)
1021                                 {
1022                                         filePathList->Add(new (std::nothrow) String (ptempDirEntry->GetFullFilePath()));
1023                                 }
1024                         }
1025                 }
1026         }
1027
1028         dataList.Add(*pAttachKey,*filePathList);
1029         if (shareType == SHARE_VIA_MESSAGE)
1030         {
1031                 dataList.Add(new (std::nothrow) String (L"http://tizen.org/appcontrol/data/message/type"),new (std::nothrow) String (L"mms"));
1032         }
1033
1034         if (pAc != null)
1035         {
1036                 AppLogDebug("filePathList count is %d",filePathList->GetCount());
1037
1038                 if (shareType == SHARE_VIA_EMAIL)
1039                 {
1040                         r = pAc->Start(null, null, &dataList, null);
1041                 }
1042                 else if (shareType == SHARE_VIA_MESSAGE)
1043                 {
1044                         r = pAc->Start(pUriType, null, &dataList, null);
1045                 }
1046
1047                 //Before going to Message/Email appcontrol, remove FIleEventListener
1048                 //to avoid any file modification event
1049                 if ( r == E_SUCCESS)
1050                 {
1051                         ((MyFilesApp*) Application::GetInstance())->SetAppControlLaunched(true);
1052                         if(_pFileEventManager != null)
1053                         {
1054                                 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1055                                 delete _pFileEventManager;
1056                                 _pFileEventManager = null;
1057                         }
1058                 }
1059
1060                 if (r == E_MAX_EXCEEDED)
1061                 {
1062                         messageBox.Construct(L"", L"Email Size Exceeded", MSGBOX_STYLE_OK);
1063                         messageBox.ShowAndWait(modalResult);
1064                 }
1065                 delete pAc;
1066         }
1067
1068         if (dataList.GetCount() > 0)
1069         {
1070                 if (filePathList != null)
1071                 {
1072                         filePathList->RemoveAll(true);
1073                 }
1074                 dataList.RemoveAll(true);
1075         }
1076         if (pUriType != null)
1077         {
1078                 delete pUriType;
1079         }
1080 }
1081
1082 void
1083 SubBaseFileManageForm::CreateLabelControl(void)
1084 {
1085         Color backgroundColor(68, 68, 68);
1086
1087         _pLabelNumberOfItems = new (std::nothrow) Label();
1088         if (_pLabelNumberOfItems != null)
1089         {
1090                 _pLabelNumberOfItems->Construct(Rectangle(X_DEFAULT, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL), *_pStrItemSelectedCount);
1091                 _pLabelNumberOfItems->SetBackgroundColor(backgroundColor);
1092                 _pLabelNumberOfItems->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1093                 _pLabelNumberOfItems->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1094                 _pLabelNumberOfItems->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1095                 _pLabelNumberOfItems->SetTextConfig(ID_FONT_SIZE_32, LABEL_TEXT_STYLE_BOLD);
1096                 _pLabelNumberOfItems->SetName(L"IDC_LABEL_COUNT");
1097
1098                 _pLabelNumberOfItems->SetShowState(false);
1099
1100                 AddControl(*_pLabelNumberOfItems);
1101         }
1102         return;
1103 }
1104
1105 void
1106 SubBaseFileManageForm::SetFooterVisibility(int mode)
1107 {
1108         AppLogDebug("ENTRY mode = %d",mode);
1109
1110         _pFooter = GetFooter();
1111
1112         if (mode == DISABLE_FOOTER_ITEM)
1113         {
1114                 _pFooter->SetItemEnabled(0, false);
1115                 _pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1116         }
1117         else
1118         {
1119                 _pFooter->SetItemEnabled(0, true);
1120                 _pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1121         }
1122         _pFooter->Invalidate(true);
1123 }
1124
1125 void
1126 SubBaseFileManageForm::SubBaseOnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status)
1127 {
1128         AppLogDebug("Entry");
1129         int itemIndex = INVALID_LIST_INDEX;
1130         int selectedItemsCount = 0;
1131         //int shareEnableFlag = 1;
1132
1133         int dirCount = 0;
1134         int fileCount = 0;
1135
1136         result r = E_SUCCESS;
1137         DirectoryEntry* pCheckedEntry = null;
1138         Integer indexToCheck(itemIndex);
1139         String selected;
1140
1141         AppResource* pAppResource = null;
1142         pAppResource = UiApp::GetInstance()->GetAppResource();
1143         if (pAppResource != null)
1144         {
1145                 pAppResource->GetString(L"IDS_COM_BODY_SELECTED", selected);
1146         }
1147
1148         _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), dirCount, fileCount);
1149
1150         if (_editOrShare == FILE_MANAGE_SHARE)
1151         {
1152                 itemIndex = dirCount + index;
1153         }
1154         else
1155         {
1156                 itemIndex = index;
1157         }
1158
1159         pCheckedEntry = static_cast< DirectoryEntry* >(_pFilenames->GetAt(itemIndex));
1160         TryCatch(pCheckedEntry != null, , "Failed to retrieve the directory entry for this index.");
1161
1162
1163
1164         //Set ShowState of the Label Displaying Selected Count as true
1165         if (_pLabelNumberOfItems != null)
1166         {
1167                 _pLabelNumberOfItems->SetShowState(true);
1168         }
1169
1170         //Check the item @ index if it is false.
1171         if (iconListView.IsItemChecked(index) == false)
1172         {
1173                 _isSelectAll = false;
1174
1175                 if (_pFileManager != null)
1176                         _pFileManager->RemoveCheckedListEntry(itemIndex);
1177         }
1178         else
1179         {
1180                 if (_editOrShare == FILE_MANAGE_SHARE)
1181                 {
1182                         if (!pCheckedEntry->IsDirectory())
1183                         {
1184                                 if (pCheckedEntry != null && _pFileManager != null)
1185                                 {
1186                                         _pFileManager->AddCheckedListEntry(itemIndex, pCheckedEntry);
1187                                 }
1188                         }
1189                 }
1190                 else
1191                 {
1192                         if (pCheckedEntry != null && _pFileManager != null)
1193                         {
1194                                 _pFileManager->AddCheckedListEntry(itemIndex, pCheckedEntry);
1195                         }
1196                 }
1197         }
1198
1199         if (_pFileManager != null)
1200         {
1201                 selectedItemsCount = _pFileManager->GetCheckedListCount();
1202         }
1203
1204         if (selectedItemsCount == 0)
1205         {
1206                 //If each item is unselected, set the showstate of the label to false.
1207                 if (_pFileManager != null)
1208                         _pFileManager->ClearCheckedList();
1209
1210                 if (_pLabelNumberOfItems != null)
1211                 {
1212                         _pLabelNumberOfItems->SetShowState(false);
1213                 }
1214
1215                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
1216
1217         }
1218         else
1219         {
1220                 //Else at least one item is selected and show the number of items selected on the label.
1221                 if (_pLabelNumberOfItems != null)
1222                 {
1223                         _pLabelNumberOfItems->SetShowState(true);
1224
1225                         _pStrItemSelectedCount->Clear();
1226                         _pStrItemSelectedCount->Append(selected);
1227                         _pStrItemSelectedCount->Append(L"\x200E");
1228                         _pStrItemSelectedCount->Append(L" (");
1229                         _pStrItemSelectedCount->Append(selectedItemsCount);
1230                         _pStrItemSelectedCount->Append(L")");
1231                         _pStrItemSelectedCount->Append(L"\x200E");
1232
1233                         AppLogDebug("Text on Label = %ls", _pStrItemSelectedCount->GetPointer());
1234
1235                         _pLabelNumberOfItems->SetText(*_pStrItemSelectedCount);
1236                         _pLabelNumberOfItems->Invalidate(true);
1237                 }
1238
1239                 SetFooterVisibility(ENABLE_FOOTER_ITEM);
1240         }
1241
1242         AppLogDebug("Exit %s", GetErrorMessage(r));
1243         return;
1244
1245 CATCH:
1246         return;
1247
1248 }
1249
1250
1251 void
1252 SubBaseFileManageForm::ShowFileProgressingPopup(void)
1253 {
1254         CreateFileProgressingPopup();
1255
1256         if (_pFileProgressingPopup != null)
1257         {
1258                 _pFileProgressingPopup->SetShowState(true);
1259                 _pFileProgressingPopup->Show();
1260         }
1261 }
1262
1263 void
1264 SubBaseFileManageForm::HideFileProgressingPopup(void)
1265 {
1266         if (_pFileProgressingPopup != null && _pFileProgressingPopup->IsVisible())
1267         {
1268                 _pFileProgressingPopup->SetShowState(false);
1269                 //_pFileProgressingPopup->Invalidate(true);
1270
1271                 //_pFileProgressingPopup->RemoveAllControls();
1272                 delete _pFileProgressingPopup;
1273                 _pFileProgressingPopup = null;
1274         }
1275 }
1276
1277 result
1278 SubBaseFileManageForm::CreateFileProgressingPopup(void)
1279 {
1280         result r = E_SUCCESS;
1281         //String popUpTitle;
1282         String deleting;
1283         String fileProgress;
1284
1285         AppResource* pAppResource = null;
1286
1287         if (_pFileProgressingPopup != null)
1288         {
1289                 //_pFileProgressingPopup->RemoveAllControls();
1290                 delete _pFileProgressingPopup;
1291                 _pFileProgressingPopup = null;
1292         }
1293
1294         pAppResource = UiApp::GetInstance()->GetAppResource();
1295
1296         if (pAppResource != null)
1297         {
1298                 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
1299         }
1300         _pFileProgressingPopup = new (std::nothrow) Popup();
1301         TryCatch(_pFileProgressingPopup != null, , "Failed to Allocate Memory to _pAnimationPopUp");
1302
1303         _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1304
1305         _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1306         if (_pFileProgressingCancelButton != null)
1307         {
1308                 _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1309                 _pFileProgressingCancelButton->AddActionEventListener(*this);
1310                 _pFileProgressingCancelButton->SetShowState(true);
1311         }
1312         _pAnimationProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1313         if (_pAnimationProgress != null)
1314         {
1315                 _pAnimationProgress->SetName(L"AnimationProgress");
1316                 _pAnimationProgress->SetValue(0);
1317         }
1318
1319         _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1320         if (_pFileProgressingHeaderLabel != null)
1321         {
1322                 _pFileProgressingHeaderLabel->SetText(deleting);
1323                 _pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
1324                 _pFileProgressingHeaderLabel->SetShowState(true);
1325         }
1326         _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1327         if (_pFileProgressingLabel != null)
1328         {
1329                 _pFileProgressingLabel->SetName(L"FileCountLabel");
1330                 _pFileProgressingLabel->SetText(L"");
1331                 _pFileProgressingLabel->SetShowState(false);
1332         }
1333
1334         return r;
1335
1336 CATCH:
1337         if (_pFileProgressingPopup != null)
1338         {
1339                 delete _pFileProgressingPopup;
1340                 _pFileProgressingPopup = null;
1341         }
1342         return r;
1343 }
1344 void
1345 SubBaseFileManageForm::SubBaseOnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1346 {
1347         AppLogDebug("Entry");
1348
1349         result r = E_SUCCESS;
1350         Integer* pCurrentStatus = null;
1351         Integer* pTotalCount = null;
1352         String fileProcessCountText;
1353         Integer* pFileProcessingResult = null;
1354         Integer* pFolderEntryDeleteIndex = null;
1355
1356         Rectangle listViewBounds(X_DEFAULT, H_CHECK_BUTTON, GetClientAreaBounds().width, GetClientAreaBounds().height - H_CHECK_BUTTON);
1357
1358         int badgeNumber = 0;
1359
1360         Header* pHeader = null;
1361         pHeader = GetHeader();
1362         NotificationManager* pNotiManager = null;
1363         TryCatch(pArgs != null, , "Argument Lis Received is Invalid!");
1364
1365         pFileProcessingResult = (Integer*) pArgs->GetAt(0);
1366         TryCatch(pFileProcessingResult != null, , "File Processing Result is Invalid!");
1367
1368         pNotiManager = new (std::nothrow) NotificationManager();
1369         TryCatch(pNotiManager != null, , "Failed to fetch AppNotificationManager");
1370
1371         pNotiManager->Construct();
1372         badgeNumber = pNotiManager->GetBadgeNumber();
1373         badgeNumber++;
1374
1375         switch (pFileProcessingResult->ToInt())
1376         {
1377         case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1378         {
1379                 HideFileProgressingPopup();
1380                 if(_pFileEventManager == null)
1381                 {
1382                         _pFileEventManager = new (std::nothrow)FileEventManager();
1383                         _pFileEventManager->Construct(*this);
1384
1385                         _pFileEventManager->AddPath(FolderNavigationPresentationModel::GetCurrentPath(), FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_MOVE_SELF);
1386
1387                 }
1388
1389                 if (_pFileManager != null)
1390                         _pFileManager->ClearCheckedList();
1391
1392                 if (_pLabelNumberOfItems != null)
1393                         _pLabelNumberOfItems->SetShowState(false);
1394
1395                 SetFooterVisibility(DISABLE_FOOTER_ITEM);
1396
1397                 if (_pFilenames->GetCount() == 0)
1398                 {
1399
1400                         if (pHeader != null)
1401                         {
1402                                 pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, false);
1403                                 //pHeader->SetItemEnabled(0, false);
1404                                 pHeader->Invalidate(true);
1405                         }
1406                         SetFooterVisibility(DISABLE_FOOTER_ITEM);
1407                 }
1408         }
1409         break;
1410
1411         case FILE_MANAGING_RESULT_DELETING_FAILED:
1412         {
1413                 HideFileProgressingPopup();
1414                 if(_pFileEventManager == null)
1415                 {
1416                         _pFileEventManager = new (std::nothrow)FileEventManager();
1417                         _pFileEventManager->Construct(*this);
1418
1419                         _pFileEventManager->AddPath(FolderNavigationPresentationModel::GetCurrentPath(), FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_MOVE_SELF);
1420
1421                 }
1422                 String deleteFailed;
1423                 AppResource* pAppResource = null;
1424                 pAppResource = Application::GetInstance()->GetAppResource();
1425                 pAppResource->GetString("IDS_MF_POP_DELETE_FAILED", deleteFailed);
1426
1427                 MessageBox messageBox;
1428                 messageBox.Construct(L"", deleteFailed, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
1429                 int modalResult = 0;
1430                 messageBox.ShowAndWait(modalResult);
1431         }
1432         break;
1433
1434         case FILE_MANAGING_RESULT_CURRENT_STATUS:
1435         {
1436                 int value = 0;
1437                 if (pArgs->GetCount() > 1)
1438                 {
1439                         pCurrentStatus = (Integer*) pArgs->GetAt(1);
1440                         pTotalCount = (Integer*) pArgs->GetAt(2);
1441                         if (pCurrentStatus != null)
1442                         {
1443                                 _fileProcessedCount = pCurrentStatus->ToInt();
1444
1445                                 fileProcessCountText.Append(_fileProcessedCount);
1446                                 fileProcessCountText.Append(L"/");
1447                                 if (pTotalCount != null)
1448                                 {
1449                                         fileProcessCountText.Append(pTotalCount->ToInt());
1450                                         value = (_fileProcessedCount * 100) / pTotalCount->ToInt();
1451                                 }
1452                         }
1453                 }
1454
1455                 if (_pFileProgressingPopup != null)
1456                 {
1457                         if(_pAnimationProgress != null)
1458                         {
1459                                 _pAnimationProgress->SetValue(value);
1460                                 _pAnimationProgress->SetShowState(true);
1461                                 _pAnimationProgress->Invalidate(true);
1462                         }
1463                         if (_pFileProgressingLabel != null)
1464                         {
1465                                 _pFileProgressingLabel->SetText(fileProcessCountText);
1466                                 _pFileProgressingLabel->SetShowState(true);
1467                                 _pFileProgressingLabel->Invalidate(true);
1468                         }
1469                 }
1470         }
1471         break;
1472         case FILE_MANAGING_REFRESH_LIST:
1473         {
1474                 HashMap* pCacheList = null;
1475                 DirectoryEntry* pCurrentEntry = null;
1476                 bool cacheKeyStatus = false;
1477                 String cachePath;
1478
1479                 if (pArgs->GetCount() > 1)
1480                 {
1481                         pFolderEntryDeleteIndex = (Integer*) pArgs->GetAt(1);
1482
1483                         pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1484
1485                         if (pCacheList != null)
1486                         {
1487                                 pCurrentEntry = static_cast<DirectoryEntry*>(_pFilenames->GetAt(pFolderEntryDeleteIndex->ToInt()));
1488
1489                                 if (pCurrentEntry != null)
1490                                 {
1491                                         cachePath = pCurrentEntry->GetFullFilePath();
1492                                 }
1493
1494                                 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1495
1496                                 if (cacheKeyStatus)
1497                                 {
1498                                         CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1499                                 }
1500                         }
1501
1502                         if (pFolderEntryDeleteIndex != null)
1503                         {
1504                                 r = _pFilenames->RemoveAt(pFolderEntryDeleteIndex->ToInt());
1505                                 TryCatch(r == E_SUCCESS, , "Remove from array list failed");
1506                         }
1507
1508                         if (_pEditListView != null && _pEditListView->IsVisible())
1509                         {
1510                                 _pEditListView->RefreshList(pFolderEntryDeleteIndex->ToInt(), LIST_REFRESH_TYPE_ITEM_REMOVE);
1511                         }
1512
1513                         if (_pEditIconListView != null && _pEditIconListView->IsVisible())
1514                         {
1515                                 _pEditIconListView->RefreshList(pFolderEntryDeleteIndex->ToInt(), LIST_REFRESH_TYPE_ITEM_REMOVE);
1516                         }
1517                 }
1518         }
1519         break;
1520
1521         default:
1522         {
1523                 //Do Nothing.
1524         }
1525         break;
1526         }
1527
1528         if (_pLabelNumberOfItems != null && _pLabelNumberOfItems->GetShowState() == true)
1529         {
1530                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
1531                 {
1532                         _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
1533
1534                         _pEditIconListView->Invalidate(true);
1535                 }
1536
1537                 if (_pEditListView != null && _pEditListView->IsVisible())
1538                 {
1539                         _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height  - H_DISPLAY_PATH_LABEL));
1540
1541                         _pEditListView->Invalidate(true);
1542                 }
1543         }
1544         else
1545         {
1546                 if (_pEditIconListView != null && _pEditIconListView->IsVisible())
1547                 {
1548                         _pEditIconListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
1549
1550                         _pEditIconListView->Invalidate(true);
1551                 }
1552
1553                 if (_pEditListView != null && _pEditListView->IsVisible())
1554                 {
1555                         _pEditListView->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, GetClientAreaBounds().height));
1556
1557                         _pEditListView->Invalidate(true);
1558                 }
1559         }
1560
1561         if (pNotiManager != null)
1562         {
1563                 delete pNotiManager;
1564                 pNotiManager = null;
1565         }
1566
1567         if (pArgs != null)
1568         {
1569                 pArgs->RemoveAll(true);
1570                 delete pArgs;
1571                 pArgs = null;
1572         }
1573
1574         return;
1575 CATCH:
1576
1577         if (pArgs != null)
1578         {
1579                 pArgs->RemoveAll(true);
1580                 delete pArgs;
1581                 pArgs = null;
1582         }
1583         if (pNotiManager != null)
1584         {
1585                 delete pNotiManager;
1586                 pNotiManager = null;
1587         }
1588         return;
1589 }
1590
1591 void
1592 SubBaseFileManageForm::LoadRenameForm(int index)
1593 {
1594         result r = E_SUCCESS;
1595         ArrayList* pArg = null;
1596         Integer* pSourceSelected = null;
1597         SceneManager* pSceneManager = null;
1598         DirectoryEntry* pDirectory = null;
1599
1600         if (_pFilenames != null)
1601         {
1602                 pDirectory = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
1603         }
1604
1605         pSceneManager = SceneManager::GetInstance();
1606         TryCatch(pSceneManager != null, , "Failed to Get SceneManager Instance");
1607
1608         pArg = new (std::nothrow) ArrayList();
1609         pArg->Construct();
1610
1611         pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
1612
1613         r = pArg->Add(pSourceSelected);
1614         TryCatch(r == E_SUCCESS, , "Failed to Add Entry to ArrayList");
1615         if (pDirectory != null)
1616         {
1617                 r = pArg->Add(pDirectory);
1618                 TryCatch(r == E_SUCCESS, , "Failed to Add Entry to ArrayList");
1619         }
1620         AppLogDebug("SubBaseFileManageForm: pArgs Count is %d", pArg->GetCount());
1621
1622         if (pSceneManager != null)
1623         {
1624                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
1625         }
1626         AppLogDebug("Exit %s", GetErrorMessage(r));
1627         return;
1628
1629 CATCH:
1630
1631         if (pSourceSelected != null)
1632         {
1633                 delete pSourceSelected;
1634                 pSourceSelected = null;
1635         }
1636         if (pArg != null)
1637         {
1638                 delete pArg;
1639                 pArg = null;
1640         }
1641         AppLogDebug("Exit %s", GetErrorMessage(r));
1642         return;
1643
1644 }
1645
1646 result
1647 SubBaseFileManageForm::CreateDeleteConfirmationPopUp(void)
1648 {
1649
1650         result r = E_SUCCESS;
1651         Rectangle popupBounds;
1652
1653         //Create a new popup control
1654         _pDeleteConfirmationPopUp = new (std::nothrow) Popup();
1655         _pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
1656
1657         _pDeleteFile = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
1658         TryCatch(_pDeleteFile != null, , "MfMyFilesApp::Button For Popup not created!");
1659
1660         _pDeleteFile->SetActionId(IDA_DELETE_FILE);
1661         _pDeleteFile->AddActionEventListener(*this);
1662         _pDeleteFile->SetShowState(true);
1663
1664         _pCancelDeletion = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
1665         TryCatch(_pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
1666
1667         _pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
1668         _pCancelDeletion->AddActionEventListener(*this);
1669         _pCancelDeletion->SetShowState(true);
1670         return r;
1671
1672 CATCH:
1673
1674         delete _pDeleteConfirmationPopUp;
1675         _pDeleteConfirmationPopUp = null;
1676
1677         return r;
1678 }
1679
1680 result
1681 SubBaseFileManageForm::CreateShareContextMenu(void)
1682 {
1683         AppLogDebug("Enter");
1684         result r = E_SUCCESS;
1685
1686         if (_pShareContextMenu != null)
1687         {
1688                 return E_SUCCESS;
1689         }
1690
1691         int x_Footer = 0;
1692         int y_Footer = 0;
1693
1694         String message;
1695         String eMail;
1696         String bluetooth;
1697         String wifiDirect;
1698
1699         AppResource* pAppResource = null;
1700         Bitmap* pBitmapEmailContextItem = null;
1701         Bitmap* pBitmapMessageContextItem = null;
1702 //      Bitmap* pBitmapBluetoothContextItem = null;
1703 //      Bitmap* pBitmapWiFiDirectContextItem = null;
1704
1705         _pFooter = GetFooter();
1706         if (_pFooter != null)
1707         {
1708                 _pFooter->GetPosition(x_Footer, y_Footer);
1709         }
1710
1711         Point startPosition(GetClientAreaBounds().width / 2, y_Footer - H_DISPLAY_PATH_LABEL);
1712
1713         pAppResource = Application::GetInstance()->GetAppResource();
1714         if (pAppResource != null)
1715         {
1716                 pAppResource->GetString(L"IDS_COM_BODY_MESSAGE", message);
1717                 pAppResource->GetString(L"IDS_COM_BODY_EMAIL", eMail);
1718                 pAppResource->GetString(L"IDS_COM_BODY_BLUETOOTH", bluetooth);
1719                 pAppResource->GetString(L"IDS_COM_OPT1_WI_FI_DIRECT", wifiDirect);
1720                 pBitmapEmailContextItem = pAppResource->GetBitmapN(IDB_POPUP_EMAIL_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1721                 pBitmapMessageContextItem = pAppResource->GetBitmapN(IDB_POPUP_MESSAGE_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1722
1723                 //pBitmapBluetoothContextItem = pAppResource->GetBitmapN(IDB_POPUP_BLUETOOTH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1724                 //pBitmapWiFiDirectContextItem = pAppResource->GetBitmapN(IDB_POPUP_WIFIDIRECT_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
1725         }
1726         AppLogDebug("enter1");
1727         _pShareContextMenu = new (std::nothrow) ContextMenu();
1728         _pShareContextMenu->Construct(startPosition, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
1729         _pShareContextMenu->AddItem(message, IDA_BTN_SHARE_MESSAGE, *pBitmapMessageContextItem, null, null);
1730         _pShareContextMenu->AddItem(eMail, IDA_BTN_SHARE_EMAIL, *pBitmapEmailContextItem, null, null);
1731 #if 0
1732         _pShareContextMenu->AddItem(bluetooth, IDA_BTN_SHARE_BLUETOOTH, *pBitmapBluetoothContextItem, null, null);
1733         _pShareContextMenu->AddItem(wifiDirect, IDA_BTN_SHARE_WIFI_DIRECT, *pBitmapWiFiDirectContextItem, null, null);
1734 #endif
1735
1736         _pShareContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_BLACK));
1737         _pShareContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
1738
1739         _pShareContextMenu->SetShowState(false);
1740
1741         _pShareContextMenu->AddActionEventListener(*this);
1742
1743         AppLogDebug("EXIT");
1744         return r;
1745 }
1746
1747 void
1748 SubBaseFileManageForm::SortArrayList(Tizen::Base::Collection::ArrayList* pArrList)
1749 {
1750         for (int i = 0; i < pArrList->GetCount(); i++)
1751         {
1752                 Integer* PValue1 = (Integer*) pArrList->GetAt(i);
1753                 for (int j = i + 1; j < pArrList->GetCount(); j++)
1754                 {
1755                         Integer* PValue2 = (Integer*) pArrList->GetAt(j);
1756                         if (PValue1->ToInt() > PValue2->ToInt())
1757                         {
1758                                 int temp;
1759                                 temp = PValue1->ToInt();
1760                                 *PValue1 = *PValue2;
1761                                 *PValue2 = temp;
1762                         }
1763                 }
1764         }
1765         for (int i = 0; i < pArrList->GetCount(); i++)
1766         {
1767                 Integer* PValue1 = (Integer*) pArrList->GetAt(i);
1768                 AppLogDebug("%d", PValue1->ToInt());
1769         }
1770 }
1771
1772 void
1773 SubBaseFileManageForm::ToggleFooter(void)
1774 {
1775         int xPos = 0, yPos = 0;
1776
1777         _pFooter = GetFooter();
1778         TryReturn(_pFooter != null, , "Footer is Null");
1779         _pFooter->RemoveAllItems();
1780         _pFooter->RemoveAllButtons();
1781         _pFooter->SetBackButton();
1782         _pFooter->SetBackButtonEnabled(true);
1783
1784         switch (_editOrShare)
1785         {
1786         case FILE_MANAGE_EDIT:
1787         {
1788                 _pFooter->AddItem(*_pDelete);
1789                 _pFooter->SetButton(BUTTON_POSITION_LEFT, _pButtonItemMore);
1790                 _pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1791
1792                 _pMoreContextMenu = new (std::nothrow) ContextMenu();
1793                 _pFooter->GetPosition(xPos, yPos);
1794                 _pMoreContextMenu->Construct(Point(0 , yPos), CONTEXT_MENU_STYLE_LIST);
1795                 _pMoreContextMenu->AddActionEventListener(*this);
1796                 _pMoreContextMenu->SetShowState(false);
1797         }
1798         break;
1799         case FILE_MANAGE_SHARE:
1800         {
1801                 _pFooter->AddItem(*_pShare);
1802         }
1803         break;
1804
1805         default:
1806         break;
1807         }
1808         _pFooter->Invalidate(true);
1809 }
1810
1811 void
1812 SubBaseFileManageForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int      eventId)
1813 {
1814         AppLogDebug("SubBaseFileManageForm::OnFileEventOccured");
1815         if (events & FILE_EVENT_TYPE_MOVE_SELF)
1816         {
1817                 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
1818         }
1819         else
1820         {
1821                 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1822         }
1823 }
1824
1825 void
1826 SubBaseFileManageForm::OnAppControlCompleted(void)
1827 {
1828         AppLogDebug("SubBaseFileManageForm::OnAppControlCompleted");
1829         //On coming back from Email/Message appcontrol, Enable the Form and
1830         //register the FileEvent Listener back
1831         SetEnabled(true);
1832         if(_pFileEventManager == null)
1833         {
1834                 _pFileEventManager = new (std::nothrow)FileEventManager();
1835                 _pFileEventManager->Construct(*this);
1836         }
1837         _pFileEventManager->AddPath(FolderNavigationPresentationModel::GetCurrentPath(), FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_MOVE_SELF);
1838 }
1839
1840 void
1841 SubBaseFileManageForm::OnSettingValueChanged(void)
1842 {
1843         //Empty Implementation.
1844 }