Change AlbumList look
[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::Media;
35 using namespace Tizen::Io;
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 = 300;
55 static const int Y_POSITION_SHARE_CONTEXTMENU = 1180;
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 AlbumListEditorForm::AlbumListEditorForm()
61         : __checkedCount(0)
62         , __pSelectCountLabel(null)
63         , __pEditorFolderIconList(null)
64         , __pShareContextMenu(null)
65         , __pDeletePopup(null)
66         , __pPresentationModel(null)
67 {
68         AppLogDebug("ENTER");
69         __overlayMsg = false;
70         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
71 }
72
73 AlbumListEditorForm::~AlbumListEditorForm()
74 {
75         AppLogDebug("ENTER");
76         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
77 }
78
79 result
80 AlbumListEditorForm::Initialize(void)
81 {
82         AppLogDebug("ENTER");
83         result r = Form::Construct(IDL_FORM_ALBUM_LIST_EDITOR);
84         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
85
86         return r;
87 }
88
89 result
90 AlbumListEditorForm::OnInitializing(void)
91 {
92         AppLogDebug("ENTER");
93         __pPresentationModel = AlbumListPresentationModel::GetInstance();
94         __pPresentationModel->ClearThumbnailRequests();
95         __pPresentationModel->AddPresentationModelListener(this);
96
97         SetFormBackEventListener(this);
98         GetHeader()->AddActionEventListener(*this);
99         GetFooter()->AddActionEventListener(*this);
100
101         result r = InitializeControl();
102         if (r != E_SUCCESS)
103         {
104                 AppLogDebug("[%s] Unable to set InitializeControl.", GetErrorMessage(r));
105         }
106
107         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
108
109         return r;
110 }
111
112 result
113 AlbumListEditorForm::OnTerminating(void)
114 {
115         AppLogDebug("ENTER");
116         __pPresentationModel->RemovePresentationModelListener(*this);
117
118         if (__pDeletePopup != null)
119         {
120                 delete __pDeletePopup;
121                 __pDeletePopup = null;
122         }
123         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
124
125         return E_SUCCESS;
126 }
127
128 void
129 AlbumListEditorForm::OnUpdateContentList()
130 {
131         AppLogDebug("ENTER");
132         SceneManager* pSceneManager = SceneManager::GetInstance();
133         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
134         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
135 }
136
137 result
138 AlbumListEditorForm::InitializeControl()
139 {
140         AppLogDebug("ENTER");
141         String tempString;
142
143         CreateIconListView();
144         __checkedCount = GetCheckedFolder();
145
146         __pSelectCountLabel = static_cast<Label*>(GetControl(L"IDC_LABEL_ALBUM_LIST_EDITOR_SELECTED"));
147         AppAssert(__pSelectCountLabel);
148
149         __pShareContextMenu = new ContextMenu();
150         __pShareContextMenu->Construct(Point(X_POSITION_SHARE_CONTEXTMENU, Y_POSITION_SHARE_CONTEXTMENU),
151                         CONTEXT_MENU_STYLE_LIST);
152         __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
153                         ACTION_ID_CONTEXT_MENU_MESSAGE);
154         __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXT_MENU_EMAIL);
155         __pShareContextMenu->AddActionEventListener(*this);
156
157         InitializePopup();
158         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
159
160         return E_SUCCESS;
161 }
162
163 result
164 AlbumListEditorForm::InitializePopup(void)
165 {
166         AppLogDebug("ENTER");
167         if (__pDeletePopup == null)
168         {
169                 __pDeletePopup = new (std::nothrow) Popup();
170                 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
171
172                 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
173
174                 Label* pLabel = new (std::nothrow) Label();
175                 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
176                                 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
177
178                 Button* pDeleteButton = new (std::nothrow) Button();
179                 pDeleteButton->Construct(
180                                 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
181                                 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
182                 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
183                 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
184                 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
185                 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
186                 pDeleteButton->AddActionEventListener(*this);
187
188                 Button* pCancelButton = new (std::nothrow) Button();
189                 pCancelButton->Construct(
190                                 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
191                                                 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
192                                                 ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
193                 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
194                 pCancelButton->AddActionEventListener(*this);
195
196                 __pDeletePopup->AddControl(*pLabel);
197                 __pDeletePopup->AddControl(*pDeleteButton);
198                 __pDeletePopup->AddControl(*pCancelButton);
199         }
200         else
201         {
202                 __pDeletePopup->SetShowState(true);
203                 __pDeletePopup->Show();
204         }
205         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
206
207         return E_SUCCESS;
208 }
209
210 void
211 AlbumListEditorForm::CreateIconListView(void)
212 {
213         AppLogDebug("ENTER");
214         __pEditorFolderIconList = static_cast< IconListView* >(GetControl(L"IDC_ICONLISTVIEW_ALBUM_LIST_EDITOR"));
215         AppAssert(__pEditorFolderIconList);
216
217         __pEditorFolderIconList->SetItemProvider(*this);
218         __pEditorFolderIconList->AddIconListViewItemEventListener(*this);
219         __pEditorFolderIconList->SetShowState(true);
220         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
221 }
222
223 int
224 AlbumListEditorForm::GetItemCount(void)
225 {
226         AppLogDebug("ENTER");
227         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
228
229         return __pPresentationModel->GetFolderCount();
230 }
231
232 IconListViewItem*
233 AlbumListEditorForm::CreateItem(int index)
234 {
235         AppLogDebug("ENTER : index(%d)", index);
236         Bitmap* pBitmap = null;
237         IconListViewItem* pIconListview = new IconListViewItem();
238
239         IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
240         AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(index));
241
242         Bitmap* pAlbumBitmap = pAlbumInfo->GetFolderThumnailBitmap();
243         if (pAlbumBitmap == null)
244         {
245                 __pPresentationModel->RequestThumbnail(index, 0);
246         }
247
248         pBitmap = __pPresentationModel->CreateMergeBitmapN(index);
249
250         if (__pEditorFolderIconList->IsItemChecked(index) == true)
251         {
252                 if (pBitmap != null)
253                 {
254                         BufferInfo bufferInfo;
255                         pBitmap->Lock(bufferInfo, INFINITE);
256                         pBitmap->Unlock();
257                         Color dimColor(COLOR_FOLDER_BITMAP_DIM);
258                         dimColor.SetAlpha(ALPHA_FOLDER_BITMAP_DIM);
259                         Canvas canvas;
260                         canvas.Construct(bufferInfo);
261                         canvas.FillRectangle(dimColor, canvas.GetBounds());
262                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
263                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
264                         pIconListview->Construct(*pBitmap, null, pSelectedBitmap);
265                         delete pSelectedBitmap;
266                 }
267         }
268         else
269         {
270                 pIconListview->Construct(*pBitmap);
271         }
272
273         if (pBitmap != null)
274         {
275                 delete pBitmap;
276         }
277         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
278
279         return pIconListview;
280 }
281
282 void
283 AlbumListEditorForm::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
284 {
285         AppLogDebug("ENTER");
286
287         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
288         {
289                 if (status == ICON_LIST_VIEW_ITEM_CHECKED)
290                 {
291                         --__checkedCount;
292                 }
293                 else if (status == ICON_LIST_VIEW_ITEM_UNCHECKED)
294                 {
295                         ++__checkedCount;
296                 }
297
298                 String tempString;
299                 if (__checkedCount == 0)
300                 {
301                         tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
302                 }
303                 else if (__checkedCount == 1)
304                 {
305                         tempString = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
306                 }
307                 else
308                 {
309                         tempString.Format(FORMAT_BUFFER_SIZE,
310                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), __checkedCount);
311                 }
312
313                 __pSelectCountLabel->SetText(tempString);
314                 __pSelectCountLabel->RequestRedraw();
315                 __pEditorFolderIconList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
316         }
317         SetButtonState();
318         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
319 }
320
321 void
322 AlbumListEditorForm::OnIconListViewOverlayBitmapSelected (IconListView &iconListView, int index,
323                 int overlayBitmapId)
324 {
325         AppLogDebug("ENTER");
326         SceneManager* pSceneManager = SceneManager::GetInstance();
327
328         if (overlayBitmapId == ACTION_ID_EDITE_FOLDER)
329         {
330                 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
331                 pSelectedIndex->Construct();
332                 pSelectedIndex->Add(new (std::nothrow) Integer(index));
333
334                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pSelectedIndex);
335         }
336         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
337 }
338
339 bool
340 AlbumListEditorForm::DeleteItem(int index, IconListViewItem* pItem)
341 {
342         AppLogDebug("ENTER");
343         delete pItem;
344         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
345
346         return true;
347 }
348
349 result
350 AlbumListEditorForm::DeleteFolder()
351 {
352         AppLogDebug("ENTER");
353         int maxCount = __pPresentationModel->GetFolderCount();
354         result r = E_FAILURE;
355
356         int checkedCount = 0;
357
358         for (int i = 0 ; i < maxCount; ++i)
359         {
360                 if (__pEditorFolderIconList->IsItemChecked(i) == true)
361                 {
362                         ++checkedCount;
363                         __pPresentationModel->DeleteContentInfoInDirectory(i, CONTENT_TYPE_ALL);
364                         if (i == 0)
365                         {
366                                 break;
367                         }
368                 }
369         }
370
371         if (checkedCount == 0)
372         {
373                 r = E_FAILURE;
374         }
375         else
376         {
377                 r = E_SUCCESS;
378         }
379
380         SetAllCheckState(false);
381         __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_ALL);
382         __pEditorFolderIconList->UpdateList();
383         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
384
385         return r;
386 }
387
388 void
389 AlbumListEditorForm::SetAllCheckState(bool state)
390 {
391         AppLogDebug("ENTER");
392         int maxCount = __pPresentationModel->GetFolderCount();
393         String tempString;
394
395         if (state == true)
396         {
397                 if (maxCount == 1)
398                 {
399                         tempString = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED;");
400                 }
401                 else
402                 {
403                         tempString.Format(FORMAT_BUFFER_SIZE,
404                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), maxCount);
405                 }
406         }
407         else
408         {
409                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
410         }
411
412         for (int i = 0 ; i < maxCount; ++i)
413         {
414                 __pEditorFolderIconList->SetItemChecked(i, state);
415                 __pEditorFolderIconList->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
416         }
417
418         __pEditorFolderIconList->Draw();
419         __pSelectCountLabel->SetText(tempString);
420         __pSelectCountLabel->RequestRedraw();
421         __checkedCount = GetCheckedFolder();
422
423         SetButtonState();
424         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
425 }
426
427 int
428 AlbumListEditorForm::GetCheckedFolder()
429 {
430         AppLogDebug("ENTER");
431         int maxCount = __pPresentationModel->GetFolderCount();
432         int count = 0;
433
434         for (int i = 0 ; i < maxCount; ++i)
435         {
436                 if (__pEditorFolderIconList->IsItemChecked (i))
437                 {
438                         count++;
439                 }
440         }
441         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
442
443         return count;
444 }
445
446 void
447 AlbumListEditorForm::OnActionPerformed(const Control& source, int actionId)
448 {
449         AppLogDebug("ENTER");
450         switch (actionId)
451         {
452         case ACTION_ID_ALBUM_LIST_SELECT_ALL:
453                 if (__pPresentationModel->GetFolderCount() == GetCheckedFolder())
454                 {
455                         SetAllCheckState(false);
456                 }
457                 else
458                 {
459                         SetAllCheckState(true);
460                 }
461                 break;
462         case ACTION_ID_FOOTER_DELETE:
463                 if (__checkedCount > 0)
464                 {
465                         __pDeletePopup->SetShowState(true);
466                         __pDeletePopup->Show();
467                 }
468                 break;
469         case ACTION_ID_FOOTER_SHARE:
470                 __pShareContextMenu->SetShowState(true);
471                 __pShareContextMenu->Show();
472                 break;
473         case ACTION_ID_CONTEXT_MENU_MESSAGE:
474         {
475                 OnRequestMessage();
476                 break;
477         }
478         case ACTION_ID_CONTEXT_MENU_EMAIL:
479         {
480                 OnRequestEmail();
481                 break;
482         }
483         case ACTION_ID_DELETE_POPUP_DEL:
484         {
485                 __pDeletePopup->SetShowState(false);
486                 __pDeletePopup->Show();
487                 result r = DeleteFolder();
488                 AppLogDebug("CHECKBUTTONSTATE : R1");
489                 if (r == E_SUCCESS)
490                 {
491                         AppLogDebug("CHECKBUTTONSTATE : R2");
492                         SceneManager* pSceneManager = SceneManager::GetInstance();
493                         AppAssert(pSceneManager);
494                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
495                 }
496                 AppLogDebug("CHECKBUTTONSTATE : R3");
497                 break;
498         }
499         case ACTION_ID_DELETE_POPUP_CANCEL:
500         {
501                 __pDeletePopup->SetShowState(false);
502                 __pDeletePopup->Show();
503                 break;
504         }
505         default:
506                 break;
507         }
508         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
509 }
510
511 void
512 AlbumListEditorForm::OnFormBackRequested(Form& source)
513 {
514         AppLogDebug("ENTER");
515         SceneManager* pSceneManager = SceneManager::GetInstance();
516         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
517         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
518 }
519
520 void
521 AlbumListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
522                 const SceneId& currentSceneId, IList* pArgs)
523 {
524         AppLogDebug("ENTER OnSceneActivatedN");
525         __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_ALL);
526         __pEditorFolderIconList->UpdateList();
527
528         __checkedCount = GetCheckedFolder();
529
530         String tempString;
531
532         if (__checkedCount == 0)
533         {
534                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
535         }
536         else if (__checkedCount == 1)
537         {
538                 tempString = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
539         }
540         else
541         {
542                 tempString.Format(FORMAT_BUFFER_SIZE,
543                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), __checkedCount);
544         }
545
546         __pSelectCountLabel->SetText(tempString);
547         __pSelectCountLabel->RequestRedraw();
548
549         SetButtonState();
550         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
551 }
552
553 void
554 AlbumListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
555                 const SceneId& nextSceneId)
556 {
557         AppLogDebug("ENTER");
558         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
559 }
560
561 void
562 AlbumListEditorForm::OnFileInfoChanged(const ContentType contentType)
563 {
564         AppLogDebug("ENTER");
565         Update();
566         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
567 }
568
569 void
570 AlbumListEditorForm::OnThumbnailDecoded(const int index)
571 {
572         AppLogDebug("ENTER : index(%d)", index);
573         __pEditorFolderIconList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
574         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
575 }
576
577 result
578 AlbumListEditorForm::Update(void)
579 {
580         AppLogDebug("ENTER");
581         result r = __pEditorFolderIconList->UpdateList();
582         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
583
584         return r;
585 }
586
587 void
588 AlbumListEditorForm::OnRequestMessage(void)
589 {
590         AppLogDebug("ENTER");
591
592         int checkCount = GetCheckedFolder();
593
594         if (checkCount <= 0)
595         {
596                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
597
598                 return;
599         }
600
601         String combineText;
602
603         IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
604
605         int maxCount = __pPresentationModel->GetFolderCount();
606         ContentManager contentManager;
607         result r = contentManager.Construct();
608         if (r == E_SUCCESS)
609         {
610                 if (maxCount <= 0)
611                 {
612                         AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
613
614                         return;
615                 }
616                 for (int i = 0 ; i < maxCount; ++i)
617                 {
618                         if (__pEditorFolderIconList->IsItemChecked (i))
619                         {
620                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(i));
621                                 IList* pContentIdList = pAlbumInfo->GetContentIdListN();
622                                 int loopCount = pContentIdList->GetCount();
623                                 for (int k = 0; k < loopCount; ++k)
624                                 {
625                                         ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(k));
626                                         ContentInfo* pContentInfo = contentManager.GetContentInfoN(*pContentId);
627
628                                         if (pContentInfo == null)
629                                         {
630                                                 break;
631                                         }
632                                         String path = pContentInfo->GetContentPath();
633                                         if (combineText.CompareTo(EMPTY_SPACE) != 0)
634                                         {
635                                                 combineText.Append(L";");
636                                         }
637                                         combineText.Append(path);
638                                 }
639
640                                 if (i == 0)
641                                 {
642                                         break;
643                                 }
644                         }
645                 }
646
647                 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
648                 pDataList->Construct();
649                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),
650                                 new (std::nothrow) String(APPCONTROL_DATA_MMS));
651                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS),
652                                 new (std::nothrow) String(combineText));
653
654                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE,
655                                 pDataList, null);
656         }
657         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
658 }
659
660 void
661 AlbumListEditorForm::OnRequestEmail(void)
662 {
663         AppLogDebug("ENTER");
664
665         int checkCount = GetCheckedFolder();
666
667         if (checkCount <= 0)
668         {
669                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
670
671                 return;
672         }
673
674         String combineText;
675
676         IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
677
678         int maxCount = __pPresentationModel->GetFolderCount();
679         ContentManager contentManager;
680         result r = contentManager.Construct();
681         if (r == E_SUCCESS)
682         {
683                 if (maxCount <= 0)
684                 {
685                         AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
686
687                         return;
688                 }
689                 for (int i = 0 ; i < maxCount; ++i)
690                 {
691                         if (__pEditorFolderIconList->IsItemChecked (i))
692                         {
693                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(i));
694                                 IList* pContentIdList = pAlbumInfo->GetContentIdListN();
695                                 int loopCount = pContentIdList->GetCount();
696                                 for (int k = 0; k < loopCount; ++k)
697                                 {
698                                         ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(k));
699                                         ContentInfo* pContentInfo = contentManager.GetContentInfoN(*pContentId);
700
701                                         if (pContentInfo == null)
702                                         {
703                                                 break;
704                                         }
705                                         String path = pContentInfo->GetContentPath();
706                                         if (combineText.CompareTo(EMPTY_SPACE) != 0)
707                                         {
708                                                 combineText.Append(L";");
709                                         }
710                                         combineText.Append(path);
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_ATTACHMENTS),
723                                 new (std::nothrow) String(combineText));
724
725                 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL,
726                                 APPCONTROL_OPERATION_ID_COMPOSE, pDataList, null);
727         }
728         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
729 }
730
731 void
732 AlbumListEditorForm::SetFooterButtonsState(bool enableState)
733 {
734         AppLogDebug("ENTER");
735         Footer* pFooter = GetFooter();
736         AppAssert(pFooter);
737
738         if (enableState == true)
739         {
740                 pFooter->SetItemEnabled(0, true);
741                 pFooter->SetItemEnabled(1, true);
742         }
743         else
744         {
745                 pFooter->SetItemEnabled(0, false);
746                 pFooter->SetItemEnabled(1, false);
747         }
748
749         pFooter->RequestRedraw(true);
750         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
751 }
752
753 void
754 AlbumListEditorForm::SetButtonState(void)
755 {
756         AppLogDebug("ENTER");
757         if (GetCheckedFolder() > 0)
758         {
759                 AppLogDebug("BUTTONSTATE : Request Enable");
760                 SetFooterButtonsState(true);
761         }
762         else
763         {
764                 AppLogDebug("BUTTONSTATE : Request disable");
765                 SetFooterButtonsState(false);
766         }
767         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
768 }