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