2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
18 * @file GlAlbumListPresentationModel.cpp
19 * @brief This is the implementation file for AlbumListPresentationModel class.
26 #include "GlAlbumInfo.h"
27 #include "GlAlbumListPresentationModel.h"
28 #include "GlGalleryApp.h"
29 #include "GlThumbnailEvent.h"
30 #include "GlThumbnailEventArg.h"
31 #include "GlThumbnailProvider.h"
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Base::Utility;
38 using namespace Tizen::Content;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Io;
41 using namespace Tizen::Media;
42 using namespace Tizen::System;
43 using namespace Tizen::Ui::Controls;
45 static const int ICON_CAP = 3;
46 static const int FOLDER_CAP = 8;
47 static const int ICON_SIZE = 107;
48 static const int FOLDER_SIZE_WIDTH = 348;
49 static const int FOLDER_SIZE_HEIGHT = 348;
51 static const int CANVAS_HEIGHT = 71;
52 static const int CANVAS_WIDTH = 326;
54 static const int FONT_SIZE_FOLDER_NAME = 32;
55 static const int FONT_SIZE_FOLDER_DATE = 25;
56 static const int FONT_SIZE_FOLDER_COUNT = 45;
57 static const int FONT_SIZE_FOLDER_COUNT_SMALL = 35;
59 static const int CANVAS_IMAGE_FOLDER_HEIGHT = 48;
60 static const int CANVAS_IMAGE_FOLDER_WIDTH = 48;
61 static const int IMAGE_COUNT_WIDTH = 100;
62 static const int IMAGE_COUNT_HEIGHT = 60;
63 static const int CANVAS_MARGIN_LEFT = 10;
64 static const int GAP = 10;
65 static const int HEIGHT_OFFSET = 5;
66 static const int Y_POS_CANVAS = 260;
67 static const int FOLDER_NAME_WIDTH = 165;
68 static const int FOLDER_NAME_HEIGHT = 38 ;
71 static const int ALPHA_BG = 110;
73 static const Color COLOR_CANVAS_BG (Color::GetColor(COLOR_ID_BLACK));
75 static const String RESERVED_MEDIA_PATH = Environment::GetMediaPath();
76 static const String RESERVED_CAMERA_PATH = Environment::GetMediaPath() + L"Camera";
77 static const String RESERVED_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera";
78 static const String RESERVED_DOWNLOAD_PATH = Environment::GetMediaPath() + L"Downloads";
79 static const String CONTENT_INFO_ORDER = L"ContentFileName";
81 static const int FORMAT_BUFFER_SIZE = 256;
83 static const int DOUBLE_NUMBER = 2;
84 static const int TRIPLE_NUMBER = 3;
86 AlbumListPresentationModel* AlbumListPresentationModel::__pPresentationModelInstance = null;
87 ArrayList* AlbumListPresentationModel::__pPresentationModelListener = null;
88 ThumbnailProvider* AlbumListPresentationModel::__pThumbnailProvider = null;
89 ThumbnailEvent* AlbumListPresentationModel::__pThumbnailEvent = null;
90 IList* AlbumListPresentationModel::__pAlbumInfoList = null;
92 AlbumListPresentationModel::AlbumListPresentationModel(void)
93 : __pFolderBackgroundBitmap(null)
94 , __appControlMode(APP_CONTROL_MODE_MAIN)
95 , __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
96 , __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
99 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
102 AlbumListPresentationModel::~AlbumListPresentationModel(void)
104 AppLogDebug("ENTER");
105 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
108 AlbumListPresentationModel*
109 AlbumListPresentationModel::GetInstance(void)
111 AppLogDebug("ENTER");
112 if (__pPresentationModelInstance == null)
116 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
118 return __pPresentationModelInstance;
122 AlbumListPresentationModel::Construct(void)
124 AppLogDebug("ENTER");
125 __pPresentationModelListener = new (std::nothrow) ArrayList();
126 __pPresentationModelListener->Construct();
128 IThumbnailEventListener* pThumbnailEventListener = static_cast<IThumbnailEventListener*>(this);
129 __pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
130 __pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
132 __pThumbnailProvider = ThumbnailProvider::GetInstance();
133 AppLogDebug("ENTER1");
134 GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
135 const IMap* pArguments = pApp->GetAppControlArguments();
136 String operationId = pApp->GetAppControlOperationId();
138 if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
140 __appControlMode = APP_CONTROL_MODE_MAIN;
142 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
144 __appControlMode = APP_CONTROL_MODE_PICK;
146 String mimeType = pApp->GetMimeType();
147 if (mimeType.IsEmpty() != true)
149 if (mimeType.StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
151 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
154 if (pArguments != null)
156 const String* selectionMode =
157 static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
158 const String* mediaType =
159 static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_MEDIA_TYPE)));
161 if (mediaType != null && mediaType->CompareTo(APPCONTROL_DATA_VIDEO) == 0)
163 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
166 if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
168 __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
172 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
174 __appControlMode = APP_CONTROL_MODE_SETTING;
177 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
183 AlbumListPresentationModel::CreateInstance(void)
185 AppLogDebug("ENTER");
186 __pPresentationModelInstance = new (std::nothrow) AlbumListPresentationModel;
187 result r = __pPresentationModelInstance->Construct();
189 if (IsFailed(r) == true)
191 delete __pPresentationModelInstance;
192 __pPresentationModelInstance = null;
193 AppLogDebug("EXIT false");
197 std::atexit(DestroyInstance);
198 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
202 AlbumListPresentationModel::DestroyInstance(void)
204 AppLogDebug("ENTER");
206 delete __pThumbnailEvent;
207 __pThumbnailEvent = null;
209 if (__pAlbumInfoList != null)
211 delete __pAlbumInfoList;
212 __pAlbumInfoList = null;
215 if (__pPresentationModelListener != null)
217 delete __pPresentationModelListener;
218 __pPresentationModelListener = null;
221 delete __pPresentationModelInstance;
222 __pPresentationModelInstance = null;
224 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
228 AlbumListPresentationModel::AddPresentationModelListener(IAlbumEventListener* listener)
230 AppLogDebug("ENTER");
231 result r = __pPresentationModelListener->Add(listener);
232 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
238 AlbumListPresentationModel::RemovePresentationModelListener(IAlbumEventListener& listner)
240 AppLogDebug("ENTER");
241 result r = __pPresentationModelListener->Remove(listner);
242 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
248 AlbumListPresentationModel::CallAlbumChangedEvent(void)
250 AppLogDebug("ENTER");
251 if (__pPresentationModelListener->GetCount() > 0)
253 IEnumerator* pEnum = __pPresentationModelListener->GetEnumeratorN();
255 while (pEnum->MoveNext() == E_SUCCESS)
257 IAlbumEventListener* pListener = null;
258 pListener = static_cast<IAlbumEventListener*>(pEnum->GetCurrent());
259 pListener->OnFileInfoChanged(CONTENT_TYPE_ALL);
265 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
269 AlbumListPresentationModel::DrawPartialImage(Canvas& canvas, AlbumInfo* pAlbumInfo, const Rectangle& rectNew)
271 AppLogDebug("ENTER");
272 if (&canvas == null || __pFolderBackgroundBitmap == null || pAlbumInfo == null)
274 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
279 canvas.DrawBitmap(rectNew, *__pFolderBackgroundBitmap);
281 Bitmap* pBitmap = pAlbumInfo->GetFolderThumnailBitmap();
285 Rectangle rectFirst(ICON_CAP+FOLDER_CAP, ICON_CAP,
286 ICON_CAP * DOUBLE_NUMBER + ICON_SIZE * TRIPLE_NUMBER,
287 ICON_CAP * DOUBLE_NUMBER + ICON_SIZE * TRIPLE_NUMBER);
288 canvas.DrawBitmap(rectFirst, *pBitmap);
291 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
295 AlbumListPresentationModel::DrawFontImage(Canvas& canvas, AlbumInfo* pAlbumInfo, int index)
297 AppLogDebug("ENTER");
301 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
308 Bitmap* pBitmap = null;
309 Font ftFolderName, ftDate, ftCnt,ftCntSmall;
311 EnrichedText enTextCount;
312 TextElement textElement;
313 TextElement textElementCount;
315 int allContentCount = pAlbumInfo->GetContentIdCount();
316 strCnt.Format(FORMAT_BUFFER_SIZE, L"%d", allContentCount);
318 String strFolderName = pAlbumInfo->GetAlbumName();
320 Rectangle rectCanvas(ICON_CAP + FOLDER_CAP, Y_POS_CANVAS, CANVAS_WIDTH, CANVAS_HEIGHT);
321 Color bgColor(COLOR_CANVAS_BG);
322 bgColor.SetAlpha(ALPHA_BG);
323 canvas.FillRectangle(bgColor, rectCanvas);
325 if ( strFolderName == ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS"))
327 pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_DOWNLOAD);
329 else if ( strFolderName == ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB") )
331 pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_CAMERA);
335 pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_FOLDER);
338 if ( pBitmap != null)
340 canvas.DrawBitmap(Rectangle(ICON_CAP + FOLDER_CAP, rectCanvas.y + HEIGHT_OFFSET, CANVAS_IMAGE_FOLDER_WIDTH,
341 CANVAS_IMAGE_FOLDER_HEIGHT), *pBitmap);
345 ftFolderName.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_NAME);
346 ftDate.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_DATE);
347 ftCnt.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_COUNT);
348 ftCntSmall.Construct(FONT_STYLE_PLAIN, FONT_SIZE_FOLDER_COUNT_SMALL);
350 enText.Construct(Dimension(FOLDER_NAME_WIDTH, FOLDER_NAME_HEIGHT));
351 enText.SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
353 textElement.Construct(strFolderName);
354 textElement.SetFont(ftFolderName);
355 textElement.SetTextColor(Color::GetColor(COLOR_ID_WHITE));
356 enText.SetTextAbbreviationEnabled(true);
357 enText.Add(textElement);
359 enTextCount.Construct(Dimension(IMAGE_COUNT_WIDTH, IMAGE_COUNT_HEIGHT));
360 enTextCount.SetHorizontalAlignment(TEXT_ALIGNMENT_RIGHT);
362 textElementCount.Construct(strCnt);
364 if (strCnt.GetLength() > 3) // if the count in Album is greater than 3 digit number, use small font
366 textElementCount.SetFont(ftCntSmall);
370 textElementCount.SetFont(ftCnt);
372 textElementCount.SetTextColor(Color::GetColor(COLOR_ID_WHITE));
373 enTextCount.SetTextAbbreviationEnabled(true);
374 enTextCount.Add(textElementCount);
376 pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH , rectCanvas.y + HEIGHT_OFFSET);
377 canvas.SetFont(ftCnt);
378 canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
379 canvas.DrawText(pointText, enTextCount);
381 pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP , rectCanvas.y + GAP + HEIGHT_OFFSET);
382 canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
383 canvas.DrawText(pointText, enText);
385 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
389 AlbumListPresentationModel::CreateMergeBitmapN(int index)
391 AppLogDebug("ENTER index(%d)", index);
393 if (__pAlbumInfoList == null)
395 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
400 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(index));
402 Bitmap* pBitmapNew = new (std::nothrow) Bitmap();
403 BufferInfo bufferinfo;
405 Rectangle rectNew(0, 0, FOLDER_SIZE_WIDTH, FOLDER_SIZE_HEIGHT);
406 Dimension size(FOLDER_SIZE_WIDTH, FOLDER_SIZE_HEIGHT);
408 result r = pBitmapNew->Construct(size, BITMAP_PIXEL_FORMAT_ARGB8888);
412 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
417 pBitmapNew->Lock(bufferinfo);
418 r = canvas.Construct(bufferinfo);
422 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
427 DrawPartialImage(canvas, pAlbumInfo, rectNew);
428 DrawFontImage(canvas, pAlbumInfo, index);
431 pBitmapNew->Unlock();
432 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
438 AlbumListPresentationModel::StartAppControl( const String& providerId, const String& operationId,
439 const IMap* pDataList, IAppControlResponseListener* pListener)
441 AppLogDebug("ENTER");
442 AppLogDebug("FindAppControlN(%ls, %ls)", providerId.GetPointer(), operationId.GetPointer());
443 if (pDataList != null)
445 IList* pKeyList = pDataList->GetKeysN();
446 if (pKeyList != null)
448 int keyCount = pKeyList->GetCount();
449 for (int i = 0; i < keyCount; ++i)
451 String* pKey = const_cast<String*>(static_cast<const String*>(pKeyList->GetAt(i)));
452 String* pValue = const_cast<String*>(static_cast<const String*>(pDataList->GetValue(*pKey)));
454 AppLogDebug("(%ls:%ls)", pKey == null ? L"(null)" : pKey->GetPointer(), pValue == null ? L"(null)" : pValue->GetPointer());
459 AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
462 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
466 result r = pAc->Start(null, null, pDataList, pListener);
470 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
471 pGalleryApp->SetFrameEnabled(false);
476 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
482 AlbumListPresentationModel::GetDirectoryName(String& directoryPath)
484 AppLogDebug("ENTER");
485 String directoryName;
488 directoryPath.LastIndexOf(DIRECTORY_SEPARATOR, directoryPath.GetLength() - 1, lastIndex);
489 directoryPath.SubString(lastIndex + 1, directoryName);
490 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
492 return directoryName;
496 AlbumListPresentationModel::GetFolderCount(void)
498 AppLogDebug("ENTER");
499 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
501 return __pAlbumInfoList->GetCount();
505 AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentType)
507 AppLogDebug("ENTER");
509 if (__pFolderBackgroundBitmap == null)
511 __pFolderBackgroundBitmap = ResourceManager::GetBitmapN(IDB_MAIN_FOLDER_BACKGROUND);
514 if (__pAlbumInfoList != null)
516 delete __pAlbumInfoList;
518 __pAlbumInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
520 ContentDirectory directory;
522 if (contentType == CONTENT_TYPE_ALL)
524 IListT< ContentType >* pListT = new (std::nothrow) ArrayListT<ContentType>();
525 TryReturnVoid(pListT != null, "Unable to Create ArrayListT");
526 pListT->Add(CONTENT_TYPE_IMAGE);
527 pListT->Add(CONTENT_TYPE_VIDEO);
529 result r = directory.Construct(*pListT);
532 delete __pAlbumInfoList;
533 __pAlbumInfoList = null;
535 AppLogDebug("EXIT 1(%s)", GetErrorMessage(r));
541 result r = directory.Construct(contentType);
544 delete __pAlbumInfoList;
545 __pAlbumInfoList = null;
546 AppLogDebug("EXIT 2(%s)", GetErrorMessage(r));
551 IList* pContentDirectoryPathList = directory.GetContentDirectoryPathListN(SORT_ORDER_ASCENDING);
552 String* pDirPath = null;
553 AlbumInfo* pAlbumInfo = null;
554 AlbumInfo* pAllAlbumInfo = new (std::nothrow) AlbumInfo();
555 result r = pAllAlbumInfo->Construct();
558 delete pContentDirectoryPathList;
559 delete pAllAlbumInfo;
560 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
565 pAllAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS"));
566 AlbumInfo* pCameraAlbumInfo = new (std::nothrow) AlbumInfo();
567 r = pCameraAlbumInfo->Construct();
570 delete pContentDirectoryPathList;
571 delete pAllAlbumInfo;
572 delete pCameraAlbumInfo;
573 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
578 pCameraAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB"));
579 AlbumInfo* pDownloadAlbumInfo = new (std::nothrow) AlbumInfo();
580 r = pDownloadAlbumInfo->Construct();
583 delete pContentDirectoryPathList;
584 delete pAllAlbumInfo;
585 delete pCameraAlbumInfo;
586 delete pDownloadAlbumInfo;
587 AppLogDebug("EXIT 5(%s)", GetErrorMessage(GetLastResult()));
592 pDownloadAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS"));
593 AlbumInfo* pNoNameAlbumInfo = new (std::nothrow) AlbumInfo();
594 r = pNoNameAlbumInfo->Construct();
597 delete pContentDirectoryPathList;
598 delete pAllAlbumInfo;
599 delete pCameraAlbumInfo;
600 delete pDownloadAlbumInfo;
601 delete pNoNameAlbumInfo;
602 AppLogDebug("EXIT 6(%s)", GetErrorMessage(GetLastResult()));
607 pNoNameAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME"));
608 if ((pContentDirectoryPathList != null) && (pContentDirectoryPathList->GetCount() > 0))
610 IEnumerator* pEnum = pContentDirectoryPathList->GetEnumeratorN();
611 while (pEnum->MoveNext() == E_SUCCESS)
613 pDirPath = static_cast<String*>(pEnum->GetCurrent());
614 if (pDirPath == null)
619 if ((*pDirPath == RESERVED_CAMERA_PATH)
620 ||(*pDirPath == RESERVED_CAMERA_PATH_EXT))
622 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
624 if (pContentIdList != null)
626 pCameraAlbumInfo->AppendDirectory(*pDirPath);
627 pCameraAlbumInfo->AppendContentIdList(*pContentIdList);
629 pAllAlbumInfo->AppendDirectory(*pDirPath);
630 pAllAlbumInfo->AppendContentIdList(*pContentIdList);
631 delete pContentIdList;
634 else if (*pDirPath == RESERVED_DOWNLOAD_PATH)
636 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
638 if (pContentIdList != null)
640 pDownloadAlbumInfo->AppendDirectory(*pDirPath);
641 pDownloadAlbumInfo->AppendContentIdList(*pContentIdList);
643 pAllAlbumInfo->AppendDirectory(*pDirPath);
644 pAllAlbumInfo->AppendContentIdList(*pContentIdList);
645 delete pContentIdList;
648 else if (*pDirPath == RESERVED_MEDIA_PATH)
650 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
652 if (pContentIdList != null)
654 pNoNameAlbumInfo->AppendDirectory(*pDirPath);
655 pNoNameAlbumInfo->AppendContentIdList(*pContentIdList);
657 pAllAlbumInfo->AppendDirectory(*pDirPath);
658 pAllAlbumInfo->AppendContentIdList(*pContentIdList);
659 delete pContentIdList;
664 IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
666 if (pContentIdList != null)
668 if (pContentIdList->GetCount() > 0)
670 pAlbumInfo = new (std::nothrow) AlbumInfo();
671 IList* pSubDirList = new (std::nothrow) ArrayList(SingleObjectDeleter);
673 pSubDirList->Add(new (std::nothrow) String(*pDirPath));
675 pAlbumInfo->Construct(GetDirectoryNameFromFullPath(*pDirPath), contentType, *pSubDirList,
678 pAllAlbumInfo->AppendDirectory(*pDirPath);
679 pAllAlbumInfo->AppendContentIdList(*pContentIdList);
682 delete pContentIdList;
686 if (pAlbumInfo != null && pAlbumInfo->GetContentIdCount() > 0)
688 __pAlbumInfoList->Add(pAlbumInfo);
697 if (pAllAlbumInfo->GetContentIdCount() > 0)
699 __pAlbumInfoList->InsertAt((Object&)*pAllAlbumInfo, insertIndex++);
703 delete pAllAlbumInfo;
706 if (pCameraAlbumInfo->GetContentIdCount() > 0)
708 __pAlbumInfoList->InsertAt((Object&)*pCameraAlbumInfo, insertIndex++);
712 delete pCameraAlbumInfo;
715 if (pDownloadAlbumInfo->GetContentIdCount() > 0)
717 __pAlbumInfoList->InsertAt((Object&)*pDownloadAlbumInfo, insertIndex++);
721 delete pDownloadAlbumInfo;
724 if (pNoNameAlbumInfo->GetContentIdCount() > 0)
726 __pAlbumInfoList->InsertAt((Object&)*pNoNameAlbumInfo, insertIndex++);
730 delete pNoNameAlbumInfo;
737 delete pAllAlbumInfo;
738 delete pCameraAlbumInfo;
739 delete pDownloadAlbumInfo;
740 delete pNoNameAlbumInfo;
743 if (pContentDirectoryPathList != null)
745 delete pContentDirectoryPathList;
748 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
752 AlbumListPresentationModel::GetDirectoryNameFromFullPath(const String& fullPath)const
754 AppLogDebug("ENTER");
755 if (fullPath == null)
757 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
761 String delim(DIRECTORY_SEPARATOR);
762 StringTokenizer st(fullPath,delim);
764 while (st.HasMoreTokens())
766 st.GetNextToken(token);
768 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
774 AlbumListPresentationModel::GetContentIdListInDirectoryN(const String& directoryPath, ContentType contentType)const
776 AppLogDebug("ENTER");
778 if (&directoryPath == null)
780 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
784 ContentDirectory directory;
785 const String contentDirectoryPath = directoryPath;
786 if (contentType == CONTENT_TYPE_ALL)
788 IListT< ContentType >* pListT = new (std::nothrow) ArrayListT<ContentType>();
789 pListT->Add(CONTENT_TYPE_IMAGE);
790 pListT->Add(CONTENT_TYPE_VIDEO);
791 result r = directory.Construct(*pListT);
795 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
801 result r = directory.Construct(contentType);
804 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
810 int countPerPage = directory.GetContentDirectoryItemCount(contentDirectoryPath);
811 IList* pContentInfoList = directory.GetContentDirectoryItemListN(contentDirectoryPath, pageNo, countPerPage,
812 CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
813 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
815 if ((pContentInfoList != null) && (pContentInfoList->GetCount() > 0))
817 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
819 while (pEnum->MoveNext() == E_SUCCESS)
821 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
822 pItem = new (std::nothrow) ContentId(pContentInfo->GetContentId());
823 pContentIdList->Add(pItem);
827 delete pContentInfoList;
828 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
830 return pContentIdList;
834 AlbumListPresentationModel::DeleteContentInfoInDirectory(int index, ContentType contentType)
836 AppLogDebug("ENTER");
837 result r = E_SUCCESS;
838 if (__pAlbumInfoList == null)
840 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
845 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(index));
847 int loopCount = pAlbumInfo->GetDirectoryCount();
848 for (int i = 0; i < loopCount; ++i)
850 ContentDirectory directory;
851 const String contentDirectoryPath = pAlbumInfo->GetDirectory(i);
853 if (contentType == CONTENT_TYPE_ALL)
855 IListT< ContentType >* pListT = new (std::nothrow) ArrayListT<ContentType>();
856 pListT->Add(CONTENT_TYPE_IMAGE);
857 pListT->Add(CONTENT_TYPE_VIDEO);
858 r = directory.Construct(*pListT);
864 r = directory.Construct(contentType);
872 int countPerPage = directory.GetContentDirectoryItemCount(contentDirectoryPath);
873 IList* pContentInfoList = directory.GetContentDirectoryItemListN(contentDirectoryPath, pageNo,
874 countPerPage, CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
875 ContentManager contentManager;
876 r = contentManager.Construct();
879 delete pContentInfoList;
883 if ((pContentInfoList != null) && (pContentInfoList->GetCount() > 0))
885 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
886 while (pEnum->MoveNext() == E_SUCCESS || r == E_SUCCESS)
888 ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
889 ContentId contentId = pContentInfo->GetContentId();
890 r = contentManager.DeleteContent(contentId);
896 delete pContentInfoList;
898 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
904 AlbumListPresentationModel::GetAppControlMode(void) const
906 AppLogDebug("Enter");
908 return __appControlMode;
912 AlbumListPresentationModel::GetAppControlMediaType(void) const
914 AppLogDebug("Enter");
916 return __appControlMediaType;
919 AppControlSelectionMode
920 AlbumListPresentationModel::GetAppControlSelectionMode(void) const
922 AppLogDebug("Enter");
924 return __appControlSelectionMode;
928 AlbumListPresentationModel::GetAlbumInfoList(void)
930 AppLogDebug("ENTER");
931 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
933 return __pAlbumInfoList;
937 AlbumListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
939 AppLogDebug("ENTER");
940 if (&eventArg != null)
942 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
943 if (pThumbnailEventArg == null)
945 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
949 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
950 if (pThumbnailInfo == null)
952 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
957 ContentId contentId = pThumbnailInfo->GetContentId();
958 ArrayList* pUpdateFolderIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
960 if (__pAlbumInfoList != null)
962 int outterLoopCount = __pAlbumInfoList->GetCount();
963 for (int x = 0; x < outterLoopCount; ++x)
965 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(x));
966 int innerLoopCount = pAlbumInfo->GetContentIdCount();
967 for (int i = 0; i < innerLoopCount; ++i)
969 if (i >= FOLDER_BITMAP_MAX)
974 if (contentId == pAlbumInfo->GetContentId(i))
976 if (pAlbumInfo->GetFolderThumnailBitmap() == null)
978 pAlbumInfo->SetFolderThumnailBitmap(pThumbnailInfo->GetBitmapN());
979 pUpdateFolderIndex->Add(new (std::nothrow) Integer(x));
986 if (__pPresentationModelListener->GetCount() > 0)
988 IEnumerator* pEnum = __pPresentationModelListener->GetEnumeratorN();
989 while (pEnum->MoveNext() == E_SUCCESS)
991 IAlbumEventListener* pListener = null;
992 pListener = static_cast<IAlbumEventListener*>(pEnum->GetCurrent());
994 int loopCount = pUpdateFolderIndex->GetCount();
995 for (int k = 0; k < loopCount; ++k)
997 Integer *index = (Integer*)pUpdateFolderIndex->GetAt(k);
998 int folderIndex = index->ToInt();
999 pListener->OnThumbnailDecoded(folderIndex);
1005 delete pUpdateFolderIndex;
1007 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1011 AlbumListPresentationModel::RequestThumbnail(const int folderIndex, int pathIndex)
1013 AppLogDebug("ENTER : folderIndex(%d), pathIndex(%d)", folderIndex, pathIndex);
1015 ContentId contentId;
1016 if (__pAlbumInfoList != null)
1018 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(folderIndex));
1019 contentId = pAlbumInfo->GetContentId(pathIndex);
1022 __pThumbnailProvider->RequestThumbnail(contentId, __pThumbnailEvent);
1023 AppLogDebug("EXIT");
1027 AlbumListPresentationModel::CancelThumbnailRequest(const int folderIndex)
1029 AppLogDebug("ENTER : folderIndex(%d)", folderIndex);
1030 if (__pAlbumInfoList != null)
1032 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(folderIndex));
1033 if (pAlbumInfo != null)
1036 for (int i = 0; i < loopCount ; ++i)
1038 contentId = pAlbumInfo->GetContentId(i);
1039 __pThumbnailProvider->CancelThumbnailRequest(contentId, __pThumbnailEvent);
1044 AppLogDebug("EXIT");
1048 AlbumListPresentationModel::ClearThumbnailRequests(bool appTerminating)
1050 AppLogDebug("ENTER");
1051 if (__pThumbnailProvider != null)
1053 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
1055 AppLogDebug("EXIT");