Fixed prevent issue
[apps/osp/Gallery.git] / src / GlAlbumListPresentationModel.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                GlAlbumListPresentationModel.cpp
19  * @brief               This is the implementation file for AlbumListPresentationModel class.
20  */
21
22 #include <cstdlib>
23 #include <FMedia.h>
24 #include <FSystem.h>
25
26 #include "GlAlbumInfo.h"
27 #include "GlAlbumListPresentationModel.h"
28 #include "GlAlbumRenameEventListener.h"
29 #include "GlContentUpdateEventListener.h"
30 #include "GlFileListPresentationModel.h"
31 #include "GlGalleryApp.h"
32 #include "GlThumbnailEvent.h"
33 #include "GlThumbnailEventArg.h"
34 #include "GlThumbnailProvider.h"
35 #include "GlTimerScanDirListener.h"
36
37 using namespace Tizen::App;
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Collection;
40 using namespace Tizen::Base::Runtime;
41 using namespace Tizen::Base::Utility;
42 using namespace Tizen::Content;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Media;
46 using namespace Tizen::System;
47 using namespace Tizen::Ui::Controls;
48
49 static const int ICON_CAP = 3;
50 static const int FOLDER_CAP = 8;
51 static const int ICON_SIZE = 107;
52 static const int FOLDER_SIZE_WIDTH = 348;
53 static const int FOLDER_SIZE_HEIGHT = 348;
54
55 static const int CANVAS_HEIGHT = 71;
56 static const int CANVAS_WIDTH = 326;
57
58 static const int FONT_SIZE_FOLDER_NAME = 32;
59 static const int FONT_SIZE_FOLDER_DATE = 25;
60 static const int FONT_SIZE_FOLDER_COUNT = 45;
61 static const int FONT_SIZE_FOLDER_COUNT_SMALL = 35;
62
63 static const int CANVAS_IMAGE_FOLDER_HEIGHT = 48;
64 static const int CANVAS_IMAGE_FOLDER_WIDTH = 48;
65 static const int IMAGE_COUNT_WIDTH = 100;
66 static const int IMAGE_COUNT_HEIGHT = 60;
67 static const int CANVAS_MARGIN_LEFT = 10;
68 static const int GAP = 10;
69 static const int HEIGHT_OFFSET = 5;
70 static const int Y_POS_CANVAS = 260;
71 static const int FOLDER_NAME_WIDTH = 165;
72 static const int FOLDER_NAME_HEIGHT = 38;
73
74
75 static const int ALPHA_BG = 110;
76
77 static const Color COLOR_CANVAS_BG (Color::GetColor(COLOR_ID_BLACK));
78
79 static const String RESERVED_MEDIA_PATH = Environment::GetMediaPath();
80 static const String RESERVED_CAMERA_PATH = Environment::GetMediaPath() + L"Camera";
81 static const String RESERVED_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera";
82 static const String RESERVED_DOWNLOAD_PATH = Environment::GetMediaPath() + L"Downloads";
83 static const String DATE_TIME = L"DateTime";
84
85 static const int FORMAT_BUFFER_SIZE = 256;
86
87 static const int DOUBLE_NUMBER = 2;
88 static const int TRIPLE_NUMBER = 3;
89
90 AlbumListPresentationModel* AlbumListPresentationModel::__pPresentationModelInstance = null;
91 ArrayList* AlbumListPresentationModel::__pPresentationModelListener = null;
92 ArrayList* AlbumListPresentationModel::__pContentEventListener = null;
93 ThumbnailProvider* AlbumListPresentationModel::__pThumbnailProvider = null;
94 ThumbnailEvent* AlbumListPresentationModel::__pThumbnailEvent = null;
95 IList* AlbumListPresentationModel::__pAlbumInfoList = null;
96
97 AlbumListPresentationModel::AlbumListPresentationModel(void)
98         : __pFolderBackgroundBitmap(null)
99         , __pAlbumListener(null)
100         , __appControlMode(APPCONTROL_MODE_MAIN)
101         , __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
102         , __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
103         , __updateProgressStatus(false)
104         , __pTimerScanListener(null)
105         , __scanCount(0)
106 {
107         AppLogDebug("ENTER");
108         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
109 }
110
111 AlbumListPresentationModel::~AlbumListPresentationModel(void)
112 {
113         AppLogDebug("ENTER");
114         DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
115         delete __pFolderBackgroundBitmap;
116         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
117 }
118
119 AlbumListPresentationModel*
120 AlbumListPresentationModel::GetInstance(void)
121 {
122         AppLogDebug("ENTER");
123         if (__pPresentationModelInstance == null)
124         {
125                 CreateInstance();
126         }
127         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
128
129         return __pPresentationModelInstance;
130 }
131
132 result
133 AlbumListPresentationModel::Construct(void)
134 {
135         AppLogDebug("ENTER");
136         __pPresentationModelListener = new (std::nothrow) ArrayList();
137         __pPresentationModelListener->Construct();
138
139         ContentUpdateEventListener::GetInstance();
140         __pContentEventListener = new (std::nothrow) ArrayList();
141         __pContentEventListener->Construct();
142
143         IThumbnailEventListener* pThumbnailEventListener = static_cast<IThumbnailEventListener*>(this);
144         __pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
145         __pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
146
147         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
148
149         __pThumbnailProvider = ThumbnailProvider::GetInstance();
150         AppLogDebug("ENTER1");
151         GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
152         const IMap* pArguments = pApp->GetAppControlArguments();
153         String operationId = pApp->GetAppControlOperationId();
154
155         if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
156         {
157                 __appControlMode = APPCONTROL_MODE_MAIN;
158         }
159         else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
160         {
161                 __appControlMode = APPCONTROL_MODE_PICK;
162
163                 String mimeType = pApp->GetMimeType();
164                 if (mimeType.IsEmpty() != true)
165                 {
166                         if (mimeType.StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
167                         {
168                                 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
169                         }
170                 }
171                 if (pArguments != null)
172                 {
173                         const String* selectionMode =
174                                         static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
175                         if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
176                         {
177                                 __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
178                         }
179                 }
180         }
181         else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
182         {
183                 __appControlMode = APPCONTROL_MODE_SETTING;
184         }
185
186         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
187
188         return E_SUCCESS;
189 }
190
191 void
192 AlbumListPresentationModel::CreateInstance(void)
193 {
194         AppLogDebug("ENTER");
195         __pPresentationModelInstance = new (std::nothrow) AlbumListPresentationModel;
196         result r = __pPresentationModelInstance->Construct();
197
198         if (IsFailed(r) == true)
199         {
200                 delete __pPresentationModelInstance;
201                 __pPresentationModelInstance = null;
202                 AppLogDebug("EXIT false");
203                 return;
204         }
205         std::atexit(DestroyInstance);
206         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
207 }
208
209 void
210 AlbumListPresentationModel::DestroyInstance(void)
211 {
212         AppLogDebug("ENTER");
213
214         delete __pThumbnailEvent;
215         __pThumbnailEvent = null;
216
217         if (__pAlbumInfoList != null)
218         {
219                 delete __pAlbumInfoList;
220                 __pAlbumInfoList = null;
221         }
222
223         if (__pPresentationModelListener != null)
224         {
225                 delete __pPresentationModelListener;
226                 __pPresentationModelListener = null;
227         }
228
229         if (__pContentEventListener != null)
230         {
231                 delete __pContentEventListener;
232                 __pContentEventListener = null;
233         }
234
235         delete __pPresentationModelInstance;
236         __pPresentationModelInstance = null;
237
238         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
239 }
240
241 result
242 AlbumListPresentationModel::AddPresentationModelListener(IAlbumEventListener* listener)
243 {
244         AppLogDebug("ENTER");
245         result r = __pPresentationModelListener->Add(listener);
246         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
247
248         return r;
249 }
250
251 result
252 AlbumListPresentationModel::RemovePresentationModelListener(IAlbumEventListener& listner)
253 {
254         AppLogDebug("ENTER");
255         result r = __pPresentationModelListener->Remove(listner);
256         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
257
258         return r;
259 }
260
261 void
262 AlbumListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
263 {
264         AppLogDebug("ENTER");
265         if (__pContentEventListener != null)
266         {
267                 __pContentEventListener->RemoveAll();
268                 __pContentEventListener->Add((Object*)listener);
269                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
270         }
271 }
272
273 void
274 AlbumListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener& listener)
275 {
276         AppLogDebug("ENTER");
277         __pContentEventListener->Remove(listener);
278         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
279 }
280
281 void
282 AlbumListPresentationModel::CallAlbumChangedEvent(void)
283 {
284         AppLogDebug("ENTER");
285         if (__pPresentationModelListener->GetCount() > 0)
286         {
287                 IEnumerator* pEnum = __pPresentationModelListener->GetEnumeratorN();
288
289                 while (pEnum->MoveNext() == E_SUCCESS)
290                 {
291                         IAlbumEventListener* pListener = null;
292                         pListener = static_cast<IAlbumEventListener*>(pEnum->GetCurrent());
293                         pListener->OnFileInfoChanged(CONTENT_TYPE_ALL);
294                 }
295
296                 delete pEnum;
297         }
298         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
299 }
300
301 result
302 AlbumListPresentationModel::RenameAlbum(const String& orgPath, const String& newPath,
303                 IAlbumRenameEventListener* pAlbumListener)
304 {
305         AppLogDebug("ENTER");
306         result r = Directory::Rename(orgPath, newPath);
307         if (IsFailed(r))
308         {
309                 AppLogDebug("Album Rename failed(%s)", GetErrorMessage(r));
310         }
311         else
312         {
313                 __pAlbumListener = pAlbumListener;
314                 __renameNewPath = newPath;\r
315                 r = ContentManager::ScanDirectory(newPath, true, NULL, __reqId);\r
316                 AppLogDebug("Content scan failed (%s)", GetErrorMessage(r));
317                 r = ContentManager::ScanDirectory(orgPath, true, NULL, __reqId);\r
318                 AppLogDebug("Content scan failed (%s)", GetErrorMessage(r));
319         }
320         AppLogDebug("EXIT");
321         return r;
322 }
323
324 void
325 AlbumListPresentationModel::ShowAnimation(void)
326 {
327         IFormContentUpdateEventListener* pInterface = null;
328         IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
329         while (pEventEnum->MoveNext() == E_SUCCESS)
330         {
331                 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
332                 pInterface->ShowAnimation();
333         }
334         delete pEventEnum;
335 }
336
337 void
338 AlbumListPresentationModel::StopAnimation(void)
339 {
340         IFormContentUpdateEventListener* pInterface = null;
341         IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
342         while (pEventEnum->MoveNext() == E_SUCCESS)
343         {
344                 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
345                 pInterface->StopAnimation();
346         }
347         delete pEventEnum;
348 }
349
350 void
351 AlbumListPresentationModel::AddTimerScanListener(ITimerScanDirListener* pListener, int scanCount)
352 {
353         __pTimerScanListener = pListener;
354         __scanCount = scanCount;
355 }
356
357 void
358 AlbumListPresentationModel::RemoveTimerScanListener(void)
359 {
360         __pTimerScanListener = null;
361         __scanCount = 0;
362 }
363
364 bool
365 AlbumListPresentationModel::OnContentScanCompleted (const Tizen::Base::String &scanPath)\r
366 {
367         AppLogDebug("ENTER");\r
368         if (__pTimerScanListener)
369         {
370                 __scanCount--;
371                 if ( __scanCount == 0 )
372                 {
373                         __pTimerScanListener->OnTimerScanDirComplete();
374                 }
375                 return false;
376         }
377         if (__pAlbumListener && ( scanPath == __renameNewPath))\r
378         {
379                 InitializeAlbumInfoList(CONTENT_TYPE_ALL);
380                 __pAlbumListener->OnAlbumRenameComplete();
381                 __renameNewPath = L"";
382                 AppLogDebug("EXIT");
383                 return true;
384         }
385         AppLogDebug("EXIT");
386         return false;
387 }
388
389 void
390 AlbumListPresentationModel::DrawPartialImage(Canvas& canvas, AlbumInfo* pAlbumInfo, const Rectangle& rectNew)
391 {
392         AppLogDebug("ENTER");
393         if (&canvas == null || __pFolderBackgroundBitmap == null || pAlbumInfo == null)
394         {
395                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
396                 return;
397         }
398
399         canvas.DrawBitmap(rectNew, *__pFolderBackgroundBitmap);
400
401         Bitmap* pBitmap = pAlbumInfo->GetFolderThumnailBitmap();
402
403         if (pBitmap != null)
404         {
405                 Rectangle rectFirst(ICON_CAP+FOLDER_CAP, ICON_CAP,
406                                 ICON_CAP * DOUBLE_NUMBER + ICON_SIZE * TRIPLE_NUMBER,
407                                 ICON_CAP * DOUBLE_NUMBER + ICON_SIZE * TRIPLE_NUMBER);
408                 canvas.DrawBitmap(rectFirst, *pBitmap);
409         }
410
411         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
412 }
413
414 void
415 AlbumListPresentationModel::DrawFontImage(Canvas& canvas, AlbumInfo* pAlbumInfo, int index)
416 {
417         AppLogDebug("ENTER");
418
419         if (&canvas == null)
420         {
421                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
422
423                 return;
424         }
425
426         Point pointText;
427         String strCnt;
428         Bitmap* pBitmap = null;
429         Font ftFolderName, ftDate, ftCnt,ftCntSmall;
430         EnrichedText enText;
431         EnrichedText enTextCount;
432         TextElement textElement;
433         TextElement textElementCount;
434
435         int allContentCount = pAlbumInfo->GetContentIdCount();
436         strCnt.Format(FORMAT_BUFFER_SIZE, L"%d", allContentCount);
437
438         String strFolderName = pAlbumInfo->GetAlbumName();
439
440         if (strFolderName == ALL_ALBUMS_REAL_NAME)
441         {
442                 strFolderName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS");
443         }
444
445         String strDirectory = pAlbumInfo->GetDirectory(0);
446         AppLog("The directory path is  %ls" , strDirectory.GetPointer());
447
448         Rectangle rectCanvas(ICON_CAP + FOLDER_CAP, Y_POS_CANVAS, CANVAS_WIDTH, CANVAS_HEIGHT);
449         Color bgColor(COLOR_CANVAS_BG);
450         bgColor.SetAlpha(ALPHA_BG);
451         canvas.FillRectangle(bgColor, rectCanvas);
452
453
454         if (strDirectory == RESERVED_DOWNLOAD_PATH)
455         {
456                 pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_DOWNLOAD);
457         }
458         else if (strDirectory == RESERVED_CAMERA_PATH ||  strDirectory == RESERVED_CAMERA_PATH_EXT)
459         {
460                 pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_CAMERA);
461         }
462         else
463         {
464                 pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_FOLDER);
465         }
466
467         if (pBitmap != null)
468         {
469                 canvas.DrawBitmap(Rectangle(ICON_CAP + FOLDER_CAP, rectCanvas.y + HEIGHT_OFFSET, CANVAS_IMAGE_FOLDER_WIDTH,
470                                         CANVAS_IMAGE_FOLDER_HEIGHT), *pBitmap);
471                 delete pBitmap;
472         }
473
474         ftFolderName.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_NAME);
475         ftDate.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_DATE);
476         ftCnt.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_COUNT);
477         ftCntSmall.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_COUNT_SMALL);
478
479         enText.Construct(Dimension(FOLDER_NAME_WIDTH, FOLDER_NAME_HEIGHT));
480         enText.SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
481
482         textElement.Construct(strFolderName);
483         textElement.SetFont(ftFolderName);
484         textElement.SetTextColor(Color::GetColor(COLOR_ID_WHITE));
485         enText.SetTextAbbreviationEnabled(true);
486         enText.Add(textElement);
487
488         enTextCount.Construct(Dimension(IMAGE_COUNT_WIDTH, IMAGE_COUNT_HEIGHT));
489         enTextCount.SetHorizontalAlignment(TEXT_ALIGNMENT_RIGHT);
490
491         textElementCount.Construct(strCnt);
492
493         if (strCnt.GetLength() > 3)
494         {
495                 textElementCount.SetFont(ftCntSmall);
496         }
497         else
498         {
499                 textElementCount.SetFont(ftCnt);
500         }
501         textElementCount.SetTextColor(Color::GetColor(COLOR_ID_WHITE));
502         enTextCount.SetTextAbbreviationEnabled(true);
503         enTextCount.Add(textElementCount);
504
505         pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH,
506                         rectCanvas.y + HEIGHT_OFFSET);
507         canvas.SetFont(ftCnt);
508         canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
509         canvas.DrawText(pointText, enTextCount);
510
511         pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP,
512                         rectCanvas.y + GAP + HEIGHT_OFFSET);
513         canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
514         canvas.DrawText(pointText, enText);
515
516         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
517 }
518
519 Bitmap*
520 AlbumListPresentationModel::CreateMergeBitmapN(const int index)
521 {
522         AppLogDebug("ENTER index(%d)", index);
523
524         if (__pAlbumInfoList == null)
525         {
526                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
527
528                 return null;
529         }
530
531         AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(index));
532
533         Bitmap* pBitmapNew = new (std::nothrow) Bitmap();
534         BufferInfo bufferinfo;
535         Canvas canvas;
536         Rectangle rectNew(0, 0, FOLDER_SIZE_WIDTH, FOLDER_SIZE_HEIGHT);
537         Dimension size(FOLDER_SIZE_WIDTH, FOLDER_SIZE_HEIGHT);
538
539         result r = pBitmapNew->Construct(size, BITMAP_PIXEL_FORMAT_ARGB8888);
540         if (r != E_SUCCESS)
541         {
542                 delete pBitmapNew;
543                 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
544
545                 return null;
546         }
547
548         pBitmapNew->Lock(bufferinfo);
549         r = canvas.Construct(bufferinfo);
550         if (r != E_SUCCESS)
551         {
552                 delete pBitmapNew;
553                 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
554
555                 return null;
556         }
557
558         DrawPartialImage(canvas, pAlbumInfo, rectNew);
559         DrawFontImage(canvas, pAlbumInfo, index);
560
561         pBitmapNew->Unlock();
562         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
563
564         return pBitmapNew;
565 }
566
567 result
568 AlbumListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
569                 const String* pUriData, const String* pMimeType, const HashMap* pDataList,
570                 IAppControlResponseListener* pListener)
571 {
572         AppLogDebug("ENTER");
573         FileListPresentationModel::GetInstance()->ClearProviderId();
574         AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
575         if (pAc == null)
576         {
577                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
578
579                 return E_FAILURE;
580         }
581         result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
582
583         if (r == E_SUCCESS)
584         {
585                 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
586                 pGalleryApp->SetFrameEnabled(false);
587         }
588
589         delete pAc;
590
591         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
592
593         return r;
594 }
595
596 String
597 AlbumListPresentationModel::GetDirectoryName(String& directoryPath) const
598 {
599         AppLogDebug("ENTER");
600         String directoryName;
601         int lastIndex = -1;
602
603         directoryPath.LastIndexOf(DIRECTORY_SEPARATOR, directoryPath.GetLength() - 1, lastIndex);
604         directoryPath.SubString(lastIndex + 1, directoryName);
605         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
606
607         return directoryName;
608 }
609
610 int
611 AlbumListPresentationModel::GetFolderCount(void) const
612 {
613         AppLogDebug("ENTER");
614         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
615
616         return __pAlbumInfoList->GetCount();
617 }
618
619 void
620 AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentType)
621 {
622         AppLogDebug("ENTER");
623
624         if (__pFolderBackgroundBitmap == null)
625         {
626                 __pFolderBackgroundBitmap = ResourceManager::GetBitmapN(IDB_MAIN_FOLDER_BACKGROUND);
627         }
628
629         if (__pAlbumInfoList != null)
630         {
631                 delete __pAlbumInfoList;
632         }
633         __pAlbumInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
634
635         ContentDirectory directory;
636
637         if (contentType == CONTENT_TYPE_ALL)
638         {
639                 IListT<ContentType>* pListT = new (std::nothrow) ArrayListT<ContentType>();
640                 TryReturnVoid(pListT != null, "Unable to Create ArrayListT");
641                 pListT->Add(CONTENT_TYPE_IMAGE);
642                 pListT->Add(CONTENT_TYPE_VIDEO);
643
644                 result r = directory.Construct(*pListT);
645                 delete pListT;
646
647                 if (r != E_SUCCESS)
648                 {
649                         delete __pAlbumInfoList;
650                         __pAlbumInfoList = null;
651                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(r));
652                         return;
653                 }
654         }
655         else
656         {
657                 result r = directory.Construct(contentType);
658                 if (r != E_SUCCESS)
659                 {
660                         delete __pAlbumInfoList;
661                         __pAlbumInfoList = null;
662                         AppLogDebug("EXIT 2(%s)", GetErrorMessage(r));
663                         return;
664                 }
665         }
666
667         IList* pContentDirectoryPathList = directory.GetContentDirectoryPathListN(SORT_ORDER_ASCENDING);
668         String* pDirPath = null;
669         AlbumInfo* pAlbumInfo = null;
670
671         AlbumInfo* pAllAlbumInfo = new (std::nothrow) AlbumInfo();
672         AlbumInfo* pCameraAlbumInfo = new (std::nothrow) AlbumInfo();
673         AlbumInfo* pDownloadAlbumInfo = new (std::nothrow) AlbumInfo();
674         AlbumInfo* pNoNameAlbumInfo = new (std::nothrow) AlbumInfo();
675
676         result r = pAllAlbumInfo->Construct();
677         TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
678         pAllAlbumInfo->SetAlbumName(ALL_ALBUMS_REAL_NAME);
679
680         r = pCameraAlbumInfo->Construct();
681         TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
682         pCameraAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB"));
683
684         r = pDownloadAlbumInfo->Construct();
685         TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
686         pDownloadAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS"));
687
688         r = pNoNameAlbumInfo->Construct();
689         TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
690         pNoNameAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME"));
691
692         if ((pContentDirectoryPathList != null) && (pContentDirectoryPathList->GetCount() > 0))
693         {
694                 IEnumerator* pEnum = pContentDirectoryPathList->GetEnumeratorN();
695                 while (pEnum->MoveNext() == E_SUCCESS)
696                 {
697                         pDirPath = static_cast<String*>(pEnum->GetCurrent());
698                         String mediaPath = RESERVED_MEDIA_PATH;
699                         int length = mediaPath.GetLength();
700                         mediaPath.Remove(length-1,1);
701
702                         if (pDirPath == null)
703                         {
704                                 continue;
705                         }
706                         if ((*pDirPath == RESERVED_CAMERA_PATH) ||(*pDirPath == RESERVED_CAMERA_PATH_EXT))
707                         {
708                                 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
709
710                                 if (pContentIdList != null)
711                                 {
712                                         pCameraAlbumInfo->AppendDirectory(*pDirPath);
713                                         pCameraAlbumInfo->AppendContentIdList(*pContentIdList);
714
715                                         pAllAlbumInfo->AppendDirectory(*pDirPath);
716                                         pAllAlbumInfo->AppendContentIdList(*pContentIdList);
717                                         delete pContentIdList;
718                                 }
719                         }
720                         else if (*pDirPath == RESERVED_DOWNLOAD_PATH)
721                         {
722                                 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
723
724                                 if (pContentIdList != null)
725                                 {
726                                         pDownloadAlbumInfo->AppendDirectory(*pDirPath);
727                                         pDownloadAlbumInfo->AppendContentIdList(*pContentIdList);
728
729                                         pAllAlbumInfo->AppendDirectory(*pDirPath);
730                                         pAllAlbumInfo->AppendContentIdList(*pContentIdList);
731
732                                         pContentIdList->RemoveAll(true);
733                                         delete pContentIdList;
734                                 }
735                         }
736                         else if (*pDirPath == mediaPath)
737                         {
738                                 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
739
740                                 if (pContentIdList != null)
741                                 {
742                                         pNoNameAlbumInfo->AppendDirectory(*pDirPath);
743                                         pNoNameAlbumInfo->AppendContentIdList(*pContentIdList);
744
745                                         pAllAlbumInfo->AppendDirectory(*pDirPath);
746                                         pAllAlbumInfo->AppendContentIdList(*pContentIdList);
747
748                                         pContentIdList->RemoveAll(true);
749                                         delete pContentIdList;
750                                 }
751                         }
752                         else
753                         {
754                                 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
755
756                                 if (pContentIdList != null)
757                                 {
758                                         if (pContentIdList->GetCount() > 0)
759                                         {
760                                                 pAlbumInfo = new (std::nothrow) AlbumInfo();
761                                                 IList* pSubDirList = new (std::nothrow) ArrayList(SingleObjectDeleter);
762
763                                                 pSubDirList->Add(new (std::nothrow) String(*pDirPath));
764
765                                                 pAlbumInfo->Construct(GetDirectoryNameFromFullPath(*pDirPath), contentType, *pSubDirList,
766                                                                 *pContentIdList);
767
768                                                 pAllAlbumInfo->AppendDirectory(*pDirPath);
769                                                 pAllAlbumInfo->AppendContentIdList(*pContentIdList);
770
771                                                 pSubDirList->RemoveAll(true);
772                                                 delete pSubDirList;
773                                         }
774
775                                         if (pContentIdList != NULL)
776                                         {
777                                                 pContentIdList->RemoveAll(true);
778                                                 delete pContentIdList;
779                                         }
780                                 }
781                                 if (pAlbumInfo != null && pAlbumInfo->GetContentIdCount() > 0)
782                                 {
783                                         __pAlbumInfoList->Add(pAlbumInfo);
784                                         AppLog("Adding album");
785                                 }
786                                 else
787                                 {
788                                         delete pAlbumInfo;
789                                 }
790                                 pAlbumInfo = null;
791                         }
792                 }
793
794                 int insertIndex = 0;
795                 if (pAllAlbumInfo->GetContentIdCount() > 0)
796                 {
797                         __pAlbumInfoList->InsertAt((Object&)*pAllAlbumInfo, insertIndex++);
798                 }
799                 else
800                 {
801                         delete pAllAlbumInfo;
802                 }
803
804                 if (pCameraAlbumInfo->GetContentIdCount() > 0)
805                 {
806                         __pAlbumInfoList->InsertAt((Object&)*pCameraAlbumInfo, insertIndex++);
807                 }
808                 else
809                 {
810                         delete pCameraAlbumInfo;
811                 }
812
813                 if (pDownloadAlbumInfo->GetContentIdCount() > 0)
814                 {
815                         __pAlbumInfoList->InsertAt((Object&)*pDownloadAlbumInfo, insertIndex++);
816                 }
817                 else
818                 {
819                         delete pDownloadAlbumInfo;
820                 }
821
822                 if (pNoNameAlbumInfo->GetContentIdCount() > 0)
823                 {
824                         __pAlbumInfoList->InsertAt((Object&)*pNoNameAlbumInfo, insertIndex++);
825                 }
826                 else
827                 {
828                         delete pNoNameAlbumInfo;
829                 }
830
831                 delete pEnum;
832         }
833         else
834         {
835                 delete pAllAlbumInfo;
836                 delete pCameraAlbumInfo;
837                 delete pDownloadAlbumInfo;
838                 delete pNoNameAlbumInfo;
839         }
840
841         if (pContentDirectoryPathList != null)
842         {
843                 pContentDirectoryPathList->RemoveAll(true);
844                 delete pContentDirectoryPathList;
845         }
846         ClearThumbnailRequests(false);
847         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
848         return;
849
850 CATCH:
851 if (pContentDirectoryPathList != null)
852 {
853         pContentDirectoryPathList->RemoveAll(true);
854         delete pContentDirectoryPathList;
855 }
856         delete pAllAlbumInfo;
857         delete pCameraAlbumInfo;
858         delete pDownloadAlbumInfo;
859         delete pNoNameAlbumInfo;
860 }
861
862 String
863 AlbumListPresentationModel::GetDirectoryNameFromFullPath(const String& fullPath)const
864 {
865         AppLogDebug("ENTER");
866         if (fullPath == null)
867         {
868                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
869
870                 return null;
871         }
872         String delim(DIRECTORY_SEPARATOR);
873         StringTokenizer st(fullPath,delim);
874         String token;
875         while (st.HasMoreTokens())
876         {
877                 st.GetNextToken(token);
878         }
879         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
880
881         return token;
882 }
883
884 IList*
885 AlbumListPresentationModel::GetContentIdListInDirectoryN(const String& directoryPath, ContentType contentType)const
886 {
887         AppLogDebug("ENTER");
888
889         if (&directoryPath == null)
890         {
891                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
892                 return null;
893         }
894
895         ContentDirectory directory;
896         const String contentDirectoryPath = directoryPath;
897         if (contentType == CONTENT_TYPE_ALL)
898         {
899                 IListT<ContentType>* pListT = new (std::nothrow) ArrayListT<ContentType>();
900                 pListT->Add(CONTENT_TYPE_IMAGE);
901                 pListT->Add(CONTENT_TYPE_VIDEO);
902                 result r = directory.Construct(*pListT);
903                 delete pListT;
904                 if (r != E_SUCCESS)
905                 {
906                         AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
907                         return null;
908                 }
909         }
910         else
911         {
912                 result r = directory.Construct(contentType);
913                 if (r != E_SUCCESS)
914                 {
915                         AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
916                         return null;
917                 }
918         }
919
920         int pageNo = 1;
921         int countPerPage = directory.GetContentDirectoryItemCount(contentDirectoryPath);
922
923         IList* pContentInfoList = directory.GetContentDirectoryItemListN(contentDirectoryPath, pageNo, countPerPage,
924                         DATE_TIME, SORT_ORDER_DESCENDING);
925
926         IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
927
928         if ((pContentInfoList != null) && (pContentInfoList->GetCount() > 0))
929         {
930                 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
931                 ContentId* pItem;
932                 while (pEnum->MoveNext() == E_SUCCESS)
933                 {
934                         ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
935                         pItem = new (std::nothrow) ContentId(pContentInfo->GetContentId());
936                         pContentIdList->Add(pItem);
937                 }
938                 delete pEnum;
939         }
940
941         if (pContentInfoList != NULL)
942         {
943                 pContentInfoList->RemoveAll(true);
944                 delete pContentInfoList;
945         }
946
947         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
948
949         return pContentIdList;
950 }
951
952 result
953 AlbumListPresentationModel::DeleteContentFile(const String& filePath)
954 {
955         AppLogDebug("ENTER");
956         result r = E_SUCCESS;
957         r = File::Remove(filePath);
958         AppLogDebug("Exit");
959         return r;
960 }
961
962 AppControlMode
963 AlbumListPresentationModel::GetAppControlMode(void) const
964 {
965         AppLogDebug("Enter");
966         AppLogDebug("Exit");
967         return __appControlMode;
968 }
969
970 AppControlMediaType
971 AlbumListPresentationModel::GetAppControlMediaType(void) const
972 {
973         AppLogDebug("Enter");
974         AppLogDebug("Exit");
975         return __appControlMediaType;
976 }
977
978 AppControlSelectionMode
979 AlbumListPresentationModel::GetAppControlSelectionMode(void) const
980 {
981         AppLogDebug("Enter");
982         AppLogDebug("Exit");
983         return __appControlSelectionMode;
984 }
985
986 IList*
987 AlbumListPresentationModel::GetAlbumInfoList(void) const
988 {
989         AppLogDebug("ENTER");
990         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
991
992         return __pAlbumInfoList;
993 }
994
995 IList* AlbumListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
996 {
997         AppLogDebug("ENTER");
998         ContentDirectory directory;
999         IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1000
1001         IListT<ContentType>* pListT = new (std::nothrow) ArrayListT<ContentType>();
1002         TryReturn(pListT != null,null, "Unable to Create ArrayListT");
1003         pListT->Add(CONTENT_TYPE_IMAGE);
1004         pListT->Add(CONTENT_TYPE_VIDEO);
1005
1006         result r = directory.Construct(*pListT);
1007         delete pListT;
1008
1009         if (r != E_SUCCESS)
1010         {
1011                 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
1012                 delete pContentIdList;
1013                 return null;
1014         }
1015
1016         if (static_cast<const Integer*>(indexList.GetAt(0))->ToInt() == 0) //if all-album is selected, get all files for delete
1017         {
1018                 IList* pContentDirectoryPathList = directory.GetContentDirectoryPathListN(SORT_ORDER_ASCENDING);
1019                 String* pDirPath = null;
1020                 if ((pContentDirectoryPathList != null) && (pContentDirectoryPathList->GetCount() > 0))
1021                 {
1022                         int loopCount = pContentDirectoryPathList->GetCount();
1023                         for (int i = 0; i < loopCount; ++i)
1024                         {
1025                                 pDirPath = static_cast<String*>(pContentDirectoryPathList->GetAt(i));
1026                                 pContentIdList->AddItems(*(GetContentIdListInDirectoryN(*pDirPath, CONTENT_TYPE_ALL)));
1027                         }
1028                 }
1029         }
1030         else
1031         {
1032                 if(__pAlbumInfoList != null)
1033                 {
1034                         int loopCount = indexList.GetCount();
1035                         AlbumInfo* pInfo = null;
1036                         for (int i = 0; i < loopCount; ++i)
1037                         {
1038                                 int index  = static_cast<const Integer*>(indexList.GetAt(i))->ToInt();
1039                                 pInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(index));
1040
1041                                 if(pInfo != null)
1042                                 {
1043                                         IList* pList = pInfo->GetContentIdListN();
1044                                         if(pList != null)
1045                                         {
1046                                                 pContentIdList->AddItems(*pList);
1047                                         }
1048                                 }
1049                         }
1050                 }
1051         }
1052         return pContentIdList;
1053 }
1054
1055 void
1056 AlbumListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
1057 {
1058         AppLogDebug("ENTER");
1059         if (&eventArg != null)
1060         {
1061                 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
1062                 if (pThumbnailEventArg == null)
1063                 {
1064                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1065
1066                         return;
1067                 }               
1068                 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
1069                 if (pThumbnailInfo == null)
1070                 {
1071                         AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1072
1073                         return;
1074                 }
1075
1076                 ContentId contentId = pThumbnailInfo->GetContentId();
1077                 ArrayList* pUpdateFolderIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1078
1079                 if (__pAlbumInfoList != null)
1080                 {
1081                         int outterLoopCount = __pAlbumInfoList->GetCount();
1082                         for (int x = 0; x < outterLoopCount; ++x)
1083                         {
1084                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(x));
1085                                 int innerLoopCount = pAlbumInfo->GetContentIdCount();
1086                                 for (int i = 0; i < innerLoopCount; ++i)
1087                                 {
1088                                         if (i >= FOLDER_BITMAP_MAX)
1089                                         {
1090                                                 break;
1091                                         }
1092
1093                                         if (contentId == pAlbumInfo->GetContentId(i))
1094                                         {
1095                                                 if (pAlbumInfo->GetFolderThumnailBitmap() == null)
1096                                                 {
1097                                                         pAlbumInfo->SetFolderThumnailBitmap(pThumbnailInfo->GetBitmapN());
1098                                                         pUpdateFolderIndex->Add(new (std::nothrow) Integer(x));
1099                                                 }
1100                                         }
1101                                 }
1102                         }
1103                 }
1104
1105                 delete pThumbnailInfo;
1106
1107                 if (__pPresentationModelListener->GetCount() > 0)
1108                 {
1109                         IEnumerator* pEnum = __pPresentationModelListener->GetEnumeratorN();
1110                         while (pEnum->MoveNext() == E_SUCCESS)
1111                         {
1112                                 IAlbumEventListener* pListener = null;
1113                                 pListener = static_cast<IAlbumEventListener*>(pEnum->GetCurrent());
1114
1115                                 int loopCount = pUpdateFolderIndex->GetCount();
1116                                 for (int k = 0; k < loopCount; ++k)
1117                                 {
1118                                         Integer *pIndex = (Integer*)pUpdateFolderIndex->GetAt(k);
1119                                         int folderIndex = pIndex->ToInt();
1120                                         pListener->OnThumbnailDecoded(folderIndex);
1121                                 }
1122                         }
1123                         delete pEnum;
1124                 }
1125
1126                 delete pUpdateFolderIndex;
1127         }
1128         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1129 }
1130
1131 void
1132 AlbumListPresentationModel::OnContentCreated(void)
1133 {
1134         AppLogDebug("ENTER");
1135         if (__updateProgressStatus == true)
1136         {
1137                 AppLogDebug("EXIT update in application");
1138                 return;
1139         }
1140         IFormContentUpdateEventListener* pInterface = null;
1141         IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1142         while (pEventEnum->MoveNext() == E_SUCCESS)
1143         {
1144                 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1145                 if (pInterface != null)
1146                 {
1147                         pInterface->OnContentUpdated();
1148                 }
1149         }
1150         delete pEventEnum;
1151         AppLogDebug("EXIT");
1152 }
1153
1154 void
1155 AlbumListPresentationModel::OnContentUpdated(void)
1156 {
1157         AppLogDebug("ENTER");
1158         if (__updateProgressStatus == true)
1159         {
1160                 AppLogDebug("EXIT update in application");
1161                 return;
1162         }
1163         IFormContentUpdateEventListener* pInterface = null;
1164         IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1165         while (pEventEnum->MoveNext() == E_SUCCESS)
1166         {
1167                 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1168                 pInterface->OnContentUpdated();
1169         }
1170         delete pEventEnum;
1171         AppLogDebug("EXIT");
1172 }
1173
1174 void
1175 AlbumListPresentationModel::OnContentDeleted(void)
1176 {
1177         AppLogDebug("ENTER");
1178         if (__updateProgressStatus == true)
1179         {
1180                 AppLogDebug("EXIT update in application");
1181                 return;
1182         }
1183         IFormContentUpdateEventListener* pInterface = null;
1184         IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1185         while (pEventEnum->MoveNext() == E_SUCCESS)
1186         {
1187                 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1188                 pInterface->OnContentUpdated();
1189         }
1190         delete pEventEnum;
1191         AppLogDebug("EXIT");
1192 }
1193
1194 void
1195 AlbumListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
1196 {
1197         AppLogDebug("ENTER");
1198         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
1199         {
1200                 IFormContentUpdateEventListener* pInterface = null;
1201                 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1202                 while (pEventEnum->MoveNext() == E_SUCCESS)
1203                 {
1204                         pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1205                         pInterface->OnContentUpdated();
1206                 }
1207                 delete pEventEnum;
1208         }
1209         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1210 }
1211
1212 void
1213 AlbumListPresentationModel::SetUpdateProgressStatus(const bool status)
1214 {
1215         AppLogDebug("ENTER status = %d",status);
1216         __updateProgressStatus = status;
1217         AppLogDebug("EXIT");
1218 }
1219
1220 result
1221 AlbumListPresentationModel::RotateImage(const ContentId&, RotateMode rotateMode)
1222 {
1223         return E_SUCCESS;
1224 }
1225
1226 void
1227 AlbumListPresentationModel::RequestThumbnail(const int folderIndex, const int pathIndex)
1228 {
1229         AppLogDebug("ENTER : folderIndex(%d), pathIndex(%d)", folderIndex, pathIndex);
1230
1231         ContentId contentId;
1232         if (__pAlbumInfoList != null)
1233         {
1234                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(folderIndex));
1235                 contentId = pAlbumInfo->GetContentId(pathIndex);
1236         }
1237
1238         __pThumbnailProvider->RequestThumbnail(contentId, __pThumbnailEvent);
1239         AppLogDebug("EXIT");
1240 }
1241
1242 void
1243 AlbumListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
1244 {
1245         AppLogDebug("ENTER");
1246         if (__pThumbnailProvider != null)
1247         {
1248                 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
1249         }
1250         AppLogDebug("EXIT");
1251 }