delete progress bar implementation
[apps/osp/Gallery.git] / src / GlAlbumListEditorForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (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                GlAlbumListEditorForm.cpp
19  * @brief               This is the implementation file for AlbumListEditorForm class.
20  */
21
22 #include <FApp.h>
23 #include "GlAlbumInfo.h"
24 #include "GlAlbumListEditorForm.h"
25 #include "GlAlbumListPresentationModel.h"
26 #include "GlResourceManager.h"
27 #include "GlTypes.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Content;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Io;
35 using namespace Tizen::Media;
36 using namespace Tizen::System;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
40
41 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
42 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
43 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
44
45 static const int GAP_W_POPUP_ITEM = 5;
46 static const int W_DELETE_POPUP = 600;
47 static const int H_DELETE_POPUP = 300;
48 static const int H_DELETE_LABEL = 180;
49 static const int Y_DELETE_BUTTON = 180;
50 static const int H_DELETE_BUTTON = 80;
51
52 static const int FORMAT_BUFFER_SIZE = 256;
53
54 static const int X_POSITION_SHARE_CONTEXTMENU = 280;
55 static const int Y_POSITION_SHARE_CONTEXTMENU = 1150;
56
57 static const Color COLOR_FOLDER_BITMAP_DIM(Color::GetColor(COLOR_ID_BLACK));
58 static const int ALPHA_FOLDER_BITMAP_DIM = 70;
59
60 static const int IDA_ALBUM_EDIT = 503 ;
61
62 AlbumListEditorForm::AlbumListEditorForm()
63         : __checkedCount(0)
64         , __pSelectCountLabel(null)
65         , __pEditorFolderIconList(null)
66         , __pShareContextMenu(null)
67         , __pDeletePopup(null)
68         , __pPresentationModel(null)
69         , __pFileDeleteTimer(null)
70 {
71         AppLogDebug("ENTER");
72         __overlayMsg = false;
73         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
74 }
75
76 AlbumListEditorForm::~AlbumListEditorForm()
77 {
78         AppLogDebug("ENTER");
79         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
80 }
81
82 result
83 AlbumListEditorForm::Initialize(void)
84 {
85         AppLogDebug("ENTER");
86         result r = Form::Construct(IDL_FORM_ALBUM_LIST_EDITOR);
87         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
88
89         return r;
90 }
91
92 result
93 AlbumListEditorForm::OnInitializing(void)
94 {
95         AppLogDebug("ENTER");
96         __pPresentationModel = AlbumListPresentationModel::GetInstance();
97         __pPresentationModel->ClearThumbnailRequests();
98         __pPresentationModel->AddPresentationModelListener(this);
99
100         SetFormBackEventListener(this);
101         GetHeader()->AddActionEventListener(*this);
102         GetFooter()->AddActionEventListener(*this);
103
104         result r = InitializeControl();
105         if (r != E_SUCCESS)
106         {
107                 AppLogDebug("[%s] Unable to set InitializeControl.", GetErrorMessage(r));
108         }
109
110         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
111
112         return r;
113 }
114
115 result
116 AlbumListEditorForm::OnTerminating(void)
117 {
118         AppLogDebug("ENTER");
119         __pPresentationModel->RemovePresentationModelListener(*this);
120
121         if (__pDeletePopup != null)
122         {
123                 delete __pDeletePopup;
124                 __pDeletePopup = null;
125         }
126         if (__pFileDeleteTimer != null)
127         {
128                 delete __pFileDeleteTimer;
129                 __pFileDeleteTimer = null;
130         }
131         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
132
133         return E_SUCCESS;
134 }
135
136 void
137 AlbumListEditorForm::OnContentUpdated()
138 {
139         AppLogDebug("ENTER");
140         SceneManager* pSceneManager = SceneManager::GetInstance();
141         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
142         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
143 }
144
145 result
146 AlbumListEditorForm::InitializeControl()
147 {
148         AppLogDebug("ENTER");
149         String tempString;
150
151         CreateIconListView();
152         __checkedCount = GetCheckedFolderCount();
153
154         __pSelectCountLabel = static_cast<Label*>(GetControl(L"IDC_LABEL_ALBUM_LIST_EDITOR_SELECTED"));
155         AppAssert(__pSelectCountLabel);
156
157         __pShareContextMenu = new ContextMenu();
158         __pShareContextMenu->Construct(Point(X_POSITION_SHARE_CONTEXTMENU, Y_POSITION_SHARE_CONTEXTMENU),
159                         CONTEXT_MENU_STYLE_LIST);
160         __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
161                         ACTION_ID_CONTEXT_MENU_MESSAGE);
162         __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXT_MENU_EMAIL);
163         __pShareContextMenu->AddActionEventListener(*this);
164
165         InitializePopup();
166         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
167
168         return E_SUCCESS;
169 }
170
171 result
172 AlbumListEditorForm::InitializePopup(void)
173 {
174         AppLogDebug("ENTER");
175         if (__pDeletePopup == null)
176         {
177                 __pDeletePopup = new (std::nothrow) Popup();
178                 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
179
180                 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
181
182                 Label* pLabel = new (std::nothrow) Label();
183                 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
184                                 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
185
186                 Button* pDeleteButton = new (std::nothrow) Button();
187                 pDeleteButton->Construct(
188                                 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
189                                 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
190                 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
191                 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
192                 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
193                 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
194                 pDeleteButton->AddActionEventListener(*this);
195
196                 Button* pCancelButton = new (std::nothrow) Button();
197                 pCancelButton->Construct(
198                                 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
199                                                 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
200                                                 ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
201                 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
202                 pCancelButton->AddActionEventListener(*this);
203
204                 __pDeletePopup->AddControl(*pLabel);
205                 __pDeletePopup->AddControl(*pDeleteButton);
206                 __pDeletePopup->AddControl(*pCancelButton);
207         }
208         else
209         {
210                 __pDeletePopup->SetShowState(true);
211                 __pDeletePopup->Show();
212         }
213         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
214
215         return E_SUCCESS;
216 }
217
218 void
219 AlbumListEditorForm::CreateIconListView(void)
220 {
221         AppLogDebug("ENTER");
222         __pEditorFolderIconList = static_cast< IconListView* >(GetControl(L"IDC_ICONLISTVIEW_ALBUM_LIST_EDITOR"));
223         AppAssert(__pEditorFolderIconList);
224
225         __pEditorFolderIconList->SetItemProvider(*this);
226         __pEditorFolderIconList->AddIconListViewItemEventListener(*this);
227         __pEditorFolderIconList->SetShowState(true);
228         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
229 }
230
231 int
232 AlbumListEditorForm::GetItemCount(void)
233 {
234         AppLogDebug("ENTER");
235         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
236
237         return __pPresentationModel->GetFolderCount();
238 }
239
240 IconListViewItem*
241 AlbumListEditorForm::CreateItem(int index)
242 {
243         AppLogDebug("ENTER : index(%d)", index);
244         Bitmap* pBitmap = null;
245         Canvas* pEditAlbumCanvas = null;
246         Bitmap* pEditAlbumBitmap = null;
247         Bitmap* pBitmapRenameBg = null;
248         Bitmap* pBitmapRename = null;
249         String albumName ;
250         int canvasWidth = 64;
251         int canvasHeight = 64;
252
253         IconListViewItem* pIconListviewItem = new IconListViewItem();
254
255         IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
256         AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(index));
257
258         Bitmap* pAlbumBitmap = pAlbumInfo->GetFolderThumnailBitmap();
259         if (pAlbumBitmap == null)
260         {
261                 __pPresentationModel->RequestThumbnail(index, 0);
262         }
263
264         pBitmap = __pPresentationModel->CreateMergeBitmapN(index);
265
266         if (__pEditorFolderIconList->IsItemChecked(index) == true)
267         {
268                 if (pBitmap != null)
269                 {
270                         BufferInfo bufferInfo;
271                         pBitmap->Lock(bufferInfo, INFINITE);
272                         pBitmap->Unlock();
273                         Color dimColor(COLOR_FOLDER_BITMAP_DIM);
274                         dimColor.SetAlpha(ALPHA_FOLDER_BITMAP_DIM);
275                         Canvas canvas;
276                         canvas.Construct(bufferInfo);
277                         canvas.FillRectangle(dimColor, canvas.GetBounds());
278                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
279                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
280                         pIconListviewItem->Construct(*pBitmap, null, pSelectedBitmap);
281                         delete pSelectedBitmap;
282                 }
283         }
284         else
285         {
286                 pIconListviewItem->Construct(*pBitmap);
287         }
288
289         if (pBitmap != null)
290         {
291                 delete pBitmap;
292         }
293
294         pBitmapRenameBg = ResourceManager::GetBitmapN(IDB_ALBUM_EDIT_RENAME_BG);
295         pBitmapRename = ResourceManager::GetBitmapN(IDB_ALBUM_EDIT_RENAME);
296
297         if (pBitmapRenameBg != null &&  pBitmapRename != null)
298         {
299
300                 pEditAlbumCanvas = new (std::nothrow) Canvas();
301                 pEditAlbumCanvas->Construct(Rectangle(0,0,canvasWidth,canvasHeight));
302                 pEditAlbumCanvas->DrawBitmap(Point(0,0),*pBitmapRenameBg);
303                 pEditAlbumCanvas->DrawBitmap(Point(0,0),*pBitmapRename);
304
305
306                 pEditAlbumBitmap = new (std::nothrow) Bitmap();
307
308                 if (pEditAlbumBitmap != NULL)
309                 {
310                         pEditAlbumBitmap->Construct(*pEditAlbumCanvas,Rectangle(0,0,canvasWidth,canvasHeight));
311                         delete pEditAlbumCanvas;
312                 }
313
314                 albumName = pAlbumInfo->GetAlbumName();
315                 String reservedCameraName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
316
317                 if (index == 0  || reservedCameraName.Equals(albumName,true))
318                 {
319                         // rename disabled
320                 }
321                 else
322                 {
323                         pIconListviewItem->SetOverlayBitmap(IDA_ALBUM_EDIT, pEditAlbumBitmap, ALIGNMENT_RIGHT, ALIGNMENT_TOP);
324                 }
325         }
326
327
328         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
329
330         return pIconListviewItem;
331 }
332
333 void
334 AlbumListEditorForm::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
335 {
336         AppLogDebug("ENTER");
337
338         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
339         {
340                 if (status == ICON_LIST_VIEW_ITEM_CHECKED) //to be unchecked after this call
341                 {
342                         --__checkedCount;
343                 }
344                 else if (status == ICON_LIST_VIEW_ITEM_UNCHECKED) //will get checked after this call hence increment
345                 {
346                         ++__checkedCount;
347                 }
348
349                 String tempString;
350                 if (__checkedCount == 0)
351                 {
352                         tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
353                 }
354                 else if (__checkedCount == 1)
355                 {
356                         tempString = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
357                 }
358                 else
359                 {
360                         tempString.Format(FORMAT_BUFFER_SIZE, ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), __checkedCount);
361                 }
362
363                 __pSelectCountLabel->SetText(tempString);
364                 __pSelectCountLabel->RequestRedraw();
365                 __pEditorFolderIconList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
366         }
367         SetButtonState();
368         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
369 }
370
371 void
372 AlbumListEditorForm::OnIconListViewOverlayBitmapSelected (IconListView &iconListView, int index,
373                 int overlayBitmapId)
374 {
375         AppLogDebug("ENTER");
376         SceneManager* pSceneManager = SceneManager::GetInstance();
377
378         ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
379         pSelectedIndex->Construct();
380         //Adding the Action Type
381         pSelectedIndex->Add(new (std::nothrow) Integer(ALBUM_RENAME));
382         pSelectedIndex->Add(new (std::nothrow) Integer(FILE_MOVE_ACTION));
383         pSelectedIndex->Add(new (std::nothrow) Integer(index));
384
385         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pSelectedIndex);
386         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
387 }
388
389 bool
390 AlbumListEditorForm::DeleteItem(int index, IconListViewItem* pItem)
391 {
392         AppLogDebug("ENTER");
393         delete pItem;
394         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
395
396         return true;
397 }
398
399 result
400 AlbumListEditorForm::DeleteFolder()
401 {
402
403         AppLogDebug("ENTER");
404         IList* pIndexList = GetItemCheckedIndexListN();
405         if (pIndexList->GetCount() <= 0)
406         {
407                 delete pIndexList;
408                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
409                 return E_FAILURE;
410         }
411
412         if (__pFileDeleteTimer != null)
413         {
414                 delete __pFileDeleteTimer;
415         }
416         __pFileDeleteTimer = new FileDeleteTimer(pIndexList, __pPresentationModel, this);
417         result r = __pFileDeleteTimer->StartTimer();
418
419         if (IsFailed(r))
420         {
421                 delete __pFileDeleteTimer;
422                 __pFileDeleteTimer = null;
423                 return E_FAILURE;
424         }
425         else
426         {
427                 __pPresentationModel->SetUpdateProgressStatus(true);
428         }
429         return E_SUCCESS;
430 }
431
432 IList*
433 AlbumListEditorForm::GetItemCheckedIndexListN(void) const
434 {
435         AppLogDebug("ENTER");
436         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
437         Integer* pIndex = null;
438
439         if (__pEditorFolderIconList!=null)
440         {
441                 int loopCount = __pPresentationModel->GetFolderCount();
442                 for (int i = 0; i < loopCount; ++i)
443                 {
444                         if (__pEditorFolderIconList->IsItemChecked(i) == true)
445                         {
446                                 pIndex = new (std::nothrow) Integer(i);
447                                 pList->Add(pIndex);
448                                 AppLogDebug("checked index(%d)", i);
449                         }
450                 }
451         }
452         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
453
454         return pList;
455 }
456
457 void
458 AlbumListEditorForm::SetAllCheckState(bool state)
459 {
460         AppLogDebug("ENTER");
461         int maxCount = __pPresentationModel->GetFolderCount();
462         String tempString;
463
464         if (state == true)
465         {
466                 if (maxCount == 1)
467                 {
468                         tempString = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED;");
469                 }
470                 else
471                 {
472                         tempString.Format(FORMAT_BUFFER_SIZE,
473                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), maxCount);
474                 }
475         }
476         else
477         {
478                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
479         }
480
481         for (int i = 0 ; i < maxCount; ++i)
482         {
483                 __pEditorFolderIconList->SetItemChecked(i, state);
484                 __pEditorFolderIconList->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
485         }
486
487         __pEditorFolderIconList->Draw();
488         __pSelectCountLabel->SetText(tempString);
489         __pSelectCountLabel->RequestRedraw();
490         __checkedCount = GetCheckedFolderCount();
491
492         SetButtonState();
493         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
494 }
495
496 int
497 AlbumListEditorForm::GetCheckedFolderCount()
498 {
499         AppLogDebug("ENTER");
500         int maxCount = __pPresentationModel->GetFolderCount();
501         int count = 0;
502
503         for (int i = 0 ; i < maxCount; ++i)
504         {
505                 if (__pEditorFolderIconList->IsItemChecked (i))
506                 {
507                         count++;
508                 }
509         }
510         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
511
512         return count;
513 }
514
515 void
516 AlbumListEditorForm::OnActionPerformed(const Control& source, int actionId)
517 {
518         AppLogDebug("ENTER");
519         switch (actionId)
520         {
521         case ACTION_ID_ALBUM_LIST_SELECT_ALL:
522                 if (__pPresentationModel->GetFolderCount() == GetCheckedFolderCount())
523                 {
524                         SetAllCheckState(false);
525                 }
526                 else
527                 {
528                         SetAllCheckState(true);
529                 }
530                 break;
531         case ACTION_ID_FOOTER_DELETE:
532         {
533                 __pDeletePopup->SetShowState(true);
534                 __pDeletePopup->Show();
535         }
536         break;
537         case ACTION_ID_FOOTER_SHARE:
538                 __pShareContextMenu->SetShowState(true);
539                 __pShareContextMenu->Show();
540                 break;
541         case ACTION_ID_CONTEXT_MENU_MESSAGE:
542         {
543                 OnRequestMessage();
544                 break;
545         }
546         case ACTION_ID_CONTEXT_MENU_EMAIL:
547         {
548                 OnRequestEmail();
549                 break;
550         }
551         case ACTION_ID_DELETE_POPUP_DEL:
552         {
553                 __pDeletePopup->SetShowState(false);
554                 __pDeletePopup->Show();
555                 DeleteFolder();
556                 break;
557         }
558         case ACTION_ID_DELETE_POPUP_CANCEL:
559         {
560                 __pDeletePopup->SetShowState(false);
561                 __pDeletePopup->Show();
562                 break;
563         }
564         default:
565                 break;
566         }
567         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
568 }
569
570 void
571 AlbumListEditorForm::OnFormBackRequested(Form& source)
572 {
573         AppLogDebug("ENTER");
574         SceneManager* pSceneManager = SceneManager::GetInstance();
575         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
576         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
577 }
578
579 void
580 AlbumListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
581                 const SceneId& currentSceneId, IList* pArgs)
582 {
583         AppLogDebug("ENTER OnSceneActivatedN");
584         __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_ALL);
585         __pEditorFolderIconList->UpdateList();
586         __pPresentationModel->AddContentEventListener(this);
587
588         __checkedCount = GetCheckedFolderCount();
589
590         String tempString;
591
592         if (__checkedCount == 0)
593         {
594                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
595         }
596         else if (__checkedCount == 1)
597         {
598                 tempString = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
599         }
600         else
601         {
602                 tempString.Format(FORMAT_BUFFER_SIZE,
603                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), __checkedCount);
604         }
605
606         __pSelectCountLabel->SetText(tempString);
607         __pSelectCountLabel->RequestRedraw();
608
609         SetButtonState();
610         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
611 }
612
613 void
614 AlbumListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
615 {
616         AppLogDebug("ENTER");
617         __pPresentationModel->RemoveContentEventListener(*this);
618         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
619 }
620
621 void
622 AlbumListEditorForm::OnFileInfoChanged(const ContentType contentType)
623 {
624         AppLogDebug("ENTER");
625         Update();
626         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
627 }
628
629 void
630 AlbumListEditorForm::OnThumbnailDecoded(const int index)
631 {
632         AppLogDebug("ENTER : index(%d)", index);
633         __pEditorFolderIconList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
634         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
635 }
636
637 void AlbumListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
638 {
639         Invalidate(true);
640 }
641
642 void AlbumListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
643 {
644         AppLogDebug("ENTER");
645         __pPresentationModel->SetUpdateProgressStatus(false);
646         SetAllCheckState(false);
647         __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_ALL);
648         __pEditorFolderIconList->UpdateList();
649
650         SceneManager* pSceneManager = SceneManager::GetInstance();
651         AppAssert(pSceneManager);
652         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
653 }
654
655 result
656 AlbumListEditorForm::Update(void)
657 {
658         AppLogDebug("ENTER");
659         result r = __pEditorFolderIconList->UpdateList();
660         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
661
662         return r;
663 }
664
665 void
666 AlbumListEditorForm::OnRequestMessage(void)
667 {
668         AppLogDebug("ENTER");
669
670         int checkCount = GetCheckedFolderCount();
671
672         if (checkCount <= 0)
673         {
674                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
675
676                 return;
677         }
678
679         IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
680
681         int maxCount = __pPresentationModel->GetFolderCount();
682         ContentManager contentManager;
683         result r = contentManager.Construct();
684         if (r == E_SUCCESS)
685         {
686                 if (maxCount <= 0)
687                 {
688                         AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
689                         return;
690                 }
691
692                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
693                 pArrayList->Construct();
694                 for (int i = 0 ; i < maxCount; ++i)
695                 {
696                         if (__pEditorFolderIconList->IsItemChecked (i))
697                         {
698                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(i));
699                                 IList* pContentIdList = pAlbumInfo->GetContentIdListN();
700                                 int loopCount = pContentIdList->GetCount();
701                                 for (int k = 0; k < loopCount; ++k)
702                                 {
703                                         ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(k));
704                                         ContentInfo* pContentInfo = contentManager.GetContentInfoN(*pContentId);
705
706                                         if (pContentInfo == null)
707                                         {
708                                                 break;
709                                         }
710                                         pArrayList->Add(new (std::nothrow) String(pContentInfo->GetContentPath()));
711                                 }
712
713                                 if (i == 0)
714                                 {
715                                         break;
716                                 }
717                         }
718                 }
719
720                 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
721                 pDataList->Construct();
722                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
723                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
724
725                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE,
726                                 null, null, pDataList, null);
727         }
728         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
729 }
730
731 void
732 AlbumListEditorForm::OnRequestEmail(void)
733 {
734         AppLogDebug("ENTER");
735
736         int checkCount = GetCheckedFolderCount();
737
738         if (checkCount <= 0)
739         {
740                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
741
742                 return;
743         }
744
745         IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
746
747         int maxCount = __pPresentationModel->GetFolderCount();
748         ContentManager contentManager;
749         result r = contentManager.Construct();
750         if (r == E_SUCCESS)
751         {
752                 if (maxCount <= 0)
753                 {
754                         AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
755                         return;
756                 }
757
758                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
759                 pArrayList->Construct();
760                 for (int i = 0 ; i < maxCount; ++i)
761                 {
762                         if (__pEditorFolderIconList->IsItemChecked (i))
763                         {
764                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(i));
765                                 IList* pContentIdList = pAlbumInfo->GetContentIdListN();
766                                 int loopCount = pContentIdList->GetCount();
767                                 for (int k = 0; k < loopCount; ++k)
768                                 {
769                                         ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(k));
770                                         ContentInfo* pContentInfo = contentManager.GetContentInfoN(*pContentId);
771
772                                         if (pContentInfo == null)
773                                         {
774                                                 break;
775                                         }
776                                         pArrayList->Add(new (std::nothrow) String(pContentInfo->GetContentPath()));
777                                 }
778
779                                 if (i == 0)
780                                 {
781                                         break;
782                                 }
783                         }
784                 }
785
786                 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
787                 pDataList->Construct();
788                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
789
790                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
791                                 new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, null);
792         }
793         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
794 }
795
796 void
797 AlbumListEditorForm::SetFooterButtonsState(bool enableState)
798 {
799         AppLogDebug("ENTER");
800         Footer* pFooter = GetFooter();
801         AppAssert(pFooter);
802
803         if (enableState == true)
804         {
805                 pFooter->SetItemEnabled(0, true);
806                 pFooter->SetItemEnabled(1, true);
807         }
808         else
809         {
810                 pFooter->SetItemEnabled(0, false);
811                 pFooter->SetItemEnabled(1, false);
812         }
813
814         pFooter->RequestRedraw(true);
815         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
816 }
817
818 void
819 AlbumListEditorForm::SetButtonState(void)
820 {
821         AppLogDebug("ENTER");
822         if (GetCheckedFolderCount() > 0)
823         {
824                 AppLogDebug("BUTTONSTATE : Request Enable");
825                 SetFooterButtonsState(true);
826         }
827         else
828         {
829                 AppLogDebug("BUTTONSTATE : Request disable");
830                 SetFooterButtonsState(false);
831         }
832         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
833 }