2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
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 GlFileListPresentationModel.cpp
19 * @brief This is the implementation file for FileListPresentationModel class.
25 #include "GlCommonUtil.h"
26 #include "GlFileListPresentationModel.h"
27 #include "GlContentUpdateEventListener.h"
28 #include "GlGalleryApp.h"
29 #include "GlThumbnailEvent.h"
30 #include "GlThumbnailEventArg.h"
31 #include "GlThumbnailProvider.h"
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Base::Utility;
39 using namespace Tizen::Content;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Io;
42 using namespace Tizen::Media;
43 using namespace Tizen::System;
45 static const String CONTENT_INFO_ORDER = L"ContentFileName";
47 static const int SIZE_PAGE_NO = 1;
48 static const int SIZE_CONUNT_PER_PAGE = 3000;
49 static const int SIZE_ICON_LIST_CACHE = 50;
50 static const int W_DURATION_TEXT = 44;
51 static const int H_DURATION_TEXT = 4;
52 static const int W_DURATION = 171;
53 static const int H_DURATION = 32;
54 static const int W_DEFAULT_THUMBNAIL = 171;
55 static const int H_DEFAULT_THUMBNAIL = 127;
56 static const int W_WIDE_THUMBNAIL = 171;
57 static const int H_WIDE_THUMBNAIL = 127;
58 static const int W_PLAY_FG = 64;
59 static const int H_PLAY_FG = 64;
60 static const int GAP_W_PLAY_FG = (W_DEFAULT_THUMBNAIL -W_PLAY_FG)/2 ;
61 static const int GAP_H_PLAY_FG = (H_DEFAULT_THUMBNAIL - H_PLAY_FG)/2;
62 static const int GAP_H_DURATION = H_DEFAULT_THUMBNAIL - H_DURATION;
63 static const int ALPHA_DURATION = 70;
64 static const int FONT_SIZE_DURATION = 24;
65 static const Dimension DIMENSION_REAL_ICON (171,127);
66 static const Rectangle RECTANGLE_THUMBNAIL_OFFSET_POSION (1, 1, 171, 127);
67 static const Rectangle RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION (1, 1, 171, 127);
68 static const Color COLOR_DURATION_BG (Color::GetColor(COLOR_ID_BLACK));
69 static const Color COLOR_TEXT_OUTLINE (Color::GetColor(COLOR_ID_WHITE));
71 static const String RESERVED_CAMERA_PATH = Environment::GetMediaPath() + L"Camera";
72 static const String RESERVED_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera";
73 static const String RESERVED_DOWNLOAD_PATH = Environment::GetMediaPath() + L"Downloads";
75 FileListPresentationModel* FileListPresentationModel::__pPresentationModelInstance = null;
76 ThumbnailProvider* FileListPresentationModel::__pThumbnailProvider = null;
77 ThumbnailEvent* FileListPresentationModel::__pThumbnailEvent = null;
78 ArrayList* FileListPresentationModel::__pPresentationModelListener = null;
79 ArrayList* FileListPresentationModel::__pContentEventListener = null;
80 ArrayList* FileListPresentationModel::__pIconListViewCache = null;
81 IList* FileListPresentationModel::__pDirectoryList = null;
82 IList* FileListPresentationModel::__pContentInfoList = null;
84 FileListPresentationModel::FileListPresentationModel(void)
85 : __pContentManager(null)
86 , __albumContentType(CONTENT_TYPE_ALL)
87 , __appControlMode(APPCONTROL_MODE_MAIN)
88 , __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
89 , __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
90 , __pContentIdList(null)
91 , __updateProgressStatus(false)
94 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
97 FileListPresentationModel::~FileListPresentationModel(void)
100 DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
101 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
104 FileListPresentationModel*
105 FileListPresentationModel::GetInstance(void)
107 AppLogDebug("ENTER");
108 if (__pPresentationModelInstance == null)
112 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
114 return __pPresentationModelInstance;
118 FileListPresentationModel::Construct(void)
120 AppLogDebug("ENTER");
122 IThumbnailEventListener* pThumbnailEventListener = static_cast<IThumbnailEventListener*>(this);
123 __pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
124 __pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
126 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
128 ContentUpdateEventListener::GetInstance();
129 __pContentManager = new (std::nothrow) ContentManager();
130 __pContentManager->Construct();
132 if (__pIconListViewCache != null)
134 __pIconListViewCache->RemoveAll(true);
135 delete __pIconListViewCache;
136 __pIconListViewCache = null;
138 __pIconListViewCache = new (std::nothrow) ArrayList(SingleObjectDeleter);
139 __pIconListViewCache->Construct(SIZE_ICON_LIST_CACHE);
141 if (__pDirectoryList != null)
143 delete __pDirectoryList;
145 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
147 if (__pContentInfoList != null)
149 delete __pContentInfoList;
151 __pContentInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
153 __pPresentationModelListener = new (std::nothrow) ArrayList();
154 __pPresentationModelListener->Construct();
156 __pContentEventListener = new (std::nothrow) ArrayList();
157 __pContentEventListener->Construct();
159 __pThumbnailProvider = ThumbnailProvider::GetInstance();
161 GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
162 const IMap* pArguments = pApp->GetAppControlArguments();
163 String operationId = pApp->GetAppControlOperationId();
165 if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
167 __appControlMode = APPCONTROL_MODE_MAIN;
169 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
171 __appControlMode = APPCONTROL_MODE_PICK;
173 String mimeType = pApp->GetMimeType();
174 if (mimeType.IsEmpty() != true)
176 if (mimeType.StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
178 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
181 if (pArguments != null)
183 const String* selectionMode = static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
185 if (pApp->GetMimeType().StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
187 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
190 if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
192 __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
196 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
198 __appControlMode = APPCONTROL_MODE_SETTING;
201 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
207 FileListPresentationModel::CreateInstance(void)
209 AppLogDebug("ENTER");
210 __pPresentationModelInstance = new (std::nothrow) FileListPresentationModel();
211 result r = __pPresentationModelInstance->Construct();
212 if (IsFailed(r) == true)
214 delete __pPresentationModelInstance;
215 __pPresentationModelInstance = null;
216 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
221 std::atexit(DestroyInstance);
222 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
226 FileListPresentationModel::DestroyInstance(void)
228 AppLogDebug("ENTER");
230 delete __pThumbnailEvent;
231 __pIconListViewCache = null;
233 if (__pIconListViewCache != null)
235 __pIconListViewCache->RemoveAll(true);
236 delete __pIconListViewCache;
237 __pIconListViewCache = null;
240 if (__pDirectoryList != null)
242 delete __pDirectoryList;
243 __pDirectoryList = null;
246 if (__pContentInfoList != null)
248 delete __pContentInfoList;
249 __pContentInfoList = null;
252 if (__pPresentationModelListener != null)
254 delete __pPresentationModelListener;
255 __pPresentationModelListener = null;
258 if (__pContentEventListener != null)
260 delete __pContentEventListener;
261 __pContentEventListener = null;
264 delete __pPresentationModelInstance;
265 __pPresentationModelInstance = null;
267 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
271 FileListPresentationModel::GetFileNameFromFullPath(const String& fullPath, const bool withExt) const
273 AppLogDebug("ENTER");
274 if (fullPath.CompareTo(EMPTY_SPACE) == 0)
276 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
281 String delim(DIRECTORY_SEPARATOR);
282 StringTokenizer st(fullPath,delim);
284 while (st.HasMoreTokens())
286 st.GetNextToken(token);
291 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
297 String subDelim(FILE_EXT_SEPARATOR);
298 StringTokenizer subSt(token, subDelim);
300 subSt.GetNextToken(subToken);
301 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
308 FileListPresentationModel::GetDirecotyNameFromFullPath(const String& fullPath)const
310 AppLogDebug("ENTER");
311 if (fullPath == null)
313 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
317 String delim(DIRECTORY_SEPARATOR);
318 StringTokenizer st(fullPath,delim);
320 while (st.HasMoreTokens())
322 st.GetNextToken(token);
324 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
330 FileListPresentationModel::IsContainContentInDirectory(const String& directoryPath, ContentType contentType) const
332 AppLogDebug("ENTER");
333 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
334 if (&directoryPath == null || pContentTypeList == null)
336 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
341 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
343 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
345 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
347 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
350 ContentDirectory contentDirectory;
351 result r = contentDirectory.Construct(*pContentTypeList);
352 if (pContentTypeList != null)
354 delete pContentTypeList;
356 TryReturn(r == E_SUCCESS, false, "[%s] Unable to construct ContentDirectory", GetErrorMessage(r));
358 bool returnValue = false;
359 int pageNo = SIZE_PAGE_NO;
360 int countPerPage = SIZE_CONUNT_PER_PAGE;
362 IList* pContentList = contentDirectory.GetContentDirectoryItemListN(directoryPath, pageNo, countPerPage,
363 CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
365 if (pContentList == null || pContentList->GetCount() <= 0)
374 if (pContentList != null)
378 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
384 FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pName, Bitmap*& pThumbnail)
386 AppLogDebug("ENTER : index(%d)", index);
387 Bitmap* pOriginalBitmap = null;
388 Bitmap* pDestinationBitmap = null;
389 ContentInfo* pContentInfo = null;
391 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
393 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
394 if (pContentInfo == null)
396 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
403 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
407 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
408 if (pThumbnailInfo != null)
410 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
411 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
414 if ((pThumbnailInfo != null)&&(pThumbnailInfo->GetContentType() == CONTENT_TYPE_VIDEO))
416 if (pOriginalBitmap != null)
418 pDestinationBitmap = CoverVideoOverlayedImageOnThumbnailN(*pOriginalBitmap, *pThumbnailInfo);
419 delete pOriginalBitmap;
424 pDestinationBitmap = pOriginalBitmap;
427 if (pDestinationBitmap != null)
429 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
430 Rectangle thumbnailRect(RECTANGLE_THUMBNAIL_OFFSET_POSION);
431 pDestinationBitmap->Scale(Dimension(RECTANGLE_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_THUMBNAIL_OFFSET_POSION.x
432 , RECTANGLE_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_THUMBNAIL_OFFSET_POSION.y));
433 if (pThumbnailBgBitmap != null)
435 pThumbnailBgBitmap->Scale(DIMENSION_REAL_ICON);
436 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pDestinationBitmap, thumbnailRect);
437 delete pThumbnailBgBitmap;
438 delete pDestinationBitmap;
442 pThumbnail = pDestinationBitmap;
450 if (pThumbnailInfo != null)
452 delete pThumbnailInfo;
454 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
460 FileListPresentationModel::GetThumbnailVideoInSyncCacheN(const int index,
461 String*& pName, Bitmap*& pThumbnail, String*& pDuration) const
463 AppLogDebug("ENTER : index(%d)", index);
464 ContentInfo* pContentInfo = null;
465 Bitmap* pOriginalBitmap = null;
467 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
469 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
470 if (pContentInfo == null)
472 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
478 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
482 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
483 if (pThumbnailInfo != null)
485 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
486 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
487 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(pThumbnailInfo->GetDuration()));
491 pName = new (std::nothrow) String(EMPTY_SPACE);
492 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(0));
495 if (pOriginalBitmap != null)
497 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
498 Rectangle thumbnailRect(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION);
499 pOriginalBitmap->Scale(Dimension(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.x
500 , RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.y));
501 if (pThumbnailBgBitmap != null)
503 pThumbnailBgBitmap->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
504 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pOriginalBitmap, thumbnailRect);
505 delete pThumbnailBgBitmap;
507 delete pOriginalBitmap;
514 if (pThumbnail != null)
516 pThumbnail->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
519 if (pThumbnailInfo != null)
521 delete pThumbnailInfo;
523 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
529 FileListPresentationModel::RequestThumbnail(const int index)
531 AppLogDebug("ENTER : index(%d)", index);
532 ContentInfo* pContentInfo = null;
534 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
536 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
537 if (pContentInfo == null)
539 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
545 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
550 __pThumbnailProvider->RequestThumbnail(pContentInfo->GetContentId(), __pThumbnailEvent);
555 FileListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
557 AppLogDebug("ENTER");
559 if (__pThumbnailProvider != null)
561 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
568 FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
570 AppLogDebug("ENTER");
572 if (&eventArg != null)
574 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
575 if (pThumbnailEventArg == null)
577 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
581 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
582 if (pThumbnailInfo == null)
584 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
589 bool isMatch = false;
590 ContentId contentId = pThumbnailInfo->GetContentId();
592 if (__pIconListViewCache != null)
594 IEnumerator* pEnum = __pIconListViewCache->GetEnumeratorN();
595 Bitmap* pBitmap = null;
596 while (pEnum->MoveNext() == E_SUCCESS)
598 ThumbnailInfo* pTempThumbnailInfo = static_cast<ThumbnailInfo*>(pEnum->GetCurrent());
600 if (contentId == pTempThumbnailInfo->GetContentId())
602 AppLogDebug("[CHASEFIRE] PM receive (%ls)", pThumbnailInfo->GetFilePath().GetPointer());
603 pBitmap = pThumbnailInfo->GetBitmapN();
604 pTempThumbnailInfo->SetBitmap(*pBitmap);
607 pTempThumbnailInfo->SetContentType(pThumbnailInfo->GetContentType());
608 pTempThumbnailInfo->SetDuration(pThumbnailInfo->GetDuration());
609 delete pThumbnailInfo;
617 if (isMatch == false)
619 if (SIZE_ICON_LIST_CACHE <= __pIconListViewCache->GetCount())
621 __pIconListViewCache->RemoveAt(0, true);
623 AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)", __pIconListViewCache->GetCount(),
624 pThumbnailInfo->GetFilePath().GetPointer());
625 __pIconListViewCache->Add(pThumbnailInfo);
630 int loopCount = __pContentInfoList->GetCount();
631 for (int i = 0; i < loopCount; ++i)
633 if (contentId == (static_cast<ContentInfo*>(__pContentInfoList->GetAt(i)))->GetContentId())
640 IAlbumEventListener* pInterface = null;
641 IEnumerator* pEventEnum = __pPresentationModelListener->GetEnumeratorN();
642 while (pEventEnum->MoveNext() == E_SUCCESS)
644 pInterface = static_cast<IAlbumEventListener*>(pEventEnum->GetCurrent());
645 pInterface->OnThumbnailDecoded(index);
649 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
653 FileListPresentationModel::OnContentCreated(void)
655 AppLogDebug("ENTER");
656 if (__updateProgressStatus == true)
658 AppLogDebug("EXIT update in application");
661 IFormContentUpdateEventListener* pInterface = null;
662 if (__pContentEventListener == null)
667 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
668 while (pEventEnum->MoveNext() == E_SUCCESS)
670 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
671 if (pInterface != null)
673 pInterface->OnContentUpdated();
681 FileListPresentationModel::OnContentUpdated(void)
683 AppLogDebug("ENTER");
684 if (__updateProgressStatus == true)
686 AppLogDebug("EXIT update in application");
689 //Clear the ImageCaches when content is updated like rotate.
692 IFormContentUpdateEventListener* pInterface = null;
693 if (__pContentEventListener == null)
698 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
699 while (pEventEnum->MoveNext() == E_SUCCESS)
701 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
702 pInterface->OnContentUpdated();
709 FileListPresentationModel::OnContentDeleted(void)
711 AppLogDebug("ENTER");
712 if (__updateProgressStatus == true)
714 AppLogDebug("EXIT update in application");
717 IFormContentUpdateEventListener* pInterface = null;
718 if (__pContentEventListener == null)
723 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
724 while (pEventEnum->MoveNext() == E_SUCCESS)
726 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
727 pInterface->OnContentUpdated();
734 FileListPresentationModel::AddPresentationModelListener(const IAlbumEventListener* listener)
736 AppLogDebug("ENTER");
737 __pPresentationModelListener->Add((Object*)listener);
738 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
742 FileListPresentationModel::RemovePresentationModelListener(const IAlbumEventListener& listener)
744 AppLogDebug("ENTER");
745 __pPresentationModelListener->Remove(listener);
746 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
750 FileListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
752 AppLogDebug("ENTER");
753 if (__pContentEventListener != null)
755 __pContentEventListener->RemoveAll();
756 __pContentEventListener->Add((Object*)listener);
757 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
762 FileListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener* listener)
764 AppLogDebug("ENTER");
765 __pContentEventListener->Remove(*listener);
766 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
770 FileListPresentationModel::GetThumbnailInfoFromInternalBufferN(const ContentId& contentId) const
772 AppLogDebug("ENTER");
773 ThumbnailInfo* pThumbnailInfo = null;
774 ThumbnailInfo* pTempThumbnailInfo = null;
775 if (__pIconListViewCache != null)
777 int loopCount = __pIconListViewCache->GetCount();
778 for (int i = 0; i < loopCount; ++i)
780 pTempThumbnailInfo = static_cast<ThumbnailInfo*>(__pIconListViewCache->GetAt(i));
781 if (contentId == pTempThumbnailInfo->GetContentId())
784 pThumbnailInfo = new (std::nothrow) ThumbnailInfo();
785 Bitmap* pBitmap = pTempThumbnailInfo->GetBitmapN();
786 pThumbnailInfo->Construct(pTempThumbnailInfo->GetContentId(), pTempThumbnailInfo->GetFilePath(),
787 *pBitmap, pTempThumbnailInfo->GetContentType(), pTempThumbnailInfo->GetDuration());
793 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
795 return pThumbnailInfo;
799 FileListPresentationModel::DeleteContentFileList(const IList& contentIndexList)
801 AppLogDebug("ENTER");
802 if (&contentIndexList == null || contentIndexList.GetCount() <= 0)
804 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
809 IList * pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
810 int loopCount = contentIndexList.GetCount();
811 for (int i = 0; i < loopCount; ++i)
813 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
815 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
817 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>
818 (__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
822 loopCount = pContentIdList->GetCount();
823 for (int i = 0; i < loopCount; ++i)
825 ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(i));
826 if (pContentId != null)
828 DeleteContentFile(*pContentId);
831 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
837 FileListPresentationModel::GetCollisionIndexListN(const IList& contentIndexList, const String& destDirectory)
839 AppLogDebug("ENTER");
840 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null
841 || destDirectory.IsEmpty() == true)
843 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
848 if (File::IsFileExist(destDirectory) == false)
850 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
855 IList * pCollisionInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
856 ContentInfo* pContentInfo = null;
857 int loopCount = contentIndexList.GetCount();
858 for (int i = 0; i < loopCount; ++i)
860 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
862 if ((pIndex != null) && (pIndex->ToInt()) >= 0 && __pContentInfoList->GetCount() > pIndex->ToInt())
864 pContentInfo = const_cast<ContentInfo*>(static_cast<const ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())));
865 String filePath = pContentInfo->GetContentPath();
866 String fileName = GetFileNameFromFullPath(filePath, true);
869 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
871 destPath.Append(destDirectory);
872 destPath.Append(fileName);
876 destPath.Append(destDirectory);
877 destPath.Append(DIRECTORY_SEPARATOR);
878 destPath.Append(fileName);
881 if (File::IsFileExist(destPath) == true)
883 pCollisionInfoList->Add(*(new (std::nothrow) String(pIndex->ToString() + MULTI_ITEM_SEPARATOR + fileName)));
887 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
889 return pCollisionInfoList;
893 FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList, const String& destDirectory)
895 AppLogDebug("ENTER");
896 result r = E_SUCCESS;
897 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null || destDirectory.IsEmpty() == true)
899 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
904 if (File::IsFileExist(destDirectory) == false)
906 Directory::Create(destDirectory, true);
909 delete __pContentIdList;
910 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
911 int loopCount = contentIndexList.GetCount();
912 for (int i = 0; i < loopCount; ++i)
914 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
916 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
918 __pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
923 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
929 FileListPresentationModel::DeleteContentFile(const ContentId& contentId)
931 AppLogDebug("ENTER");
932 if (&contentId == null)
934 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
938 result r = __pContentManager->DeleteContent(contentId);
940 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
946 FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const String& destDirectory, const bool isCopyOperation)
948 AppLogDebug("ENTER");
949 if (contentId.ToString().IsEmpty() == true || destDirectory.IsEmpty() == true)
951 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
954 result r = E_SUCCESS;
955 ContentInfo* pContentInfo = __pContentManager->GetContentInfoN(contentId);
956 if (pContentInfo == null)
958 AppLogDebug("Santhosh %s", destDirectory.GetPointer());
959 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
963 String filePath = pContentInfo->GetContentPath();
964 if (filePath.GetLength() < 4)
966 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
971 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
973 destPath.Append(destDirectory);
974 destPath.Append(GetFileNameFromFullPath(filePath, true));
978 destPath.Append(destDirectory);
979 destPath.Append(DIRECTORY_SEPARATOR);
980 destPath.Append(GetFileNameFromFullPath(filePath, true));
983 if (destPath.CompareTo(filePath) == 0)
985 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
989 if (File::IsFileExist(destPath) == true)
991 File::Remove(destPath);
994 r = File::Copy(filePath, destPath, false);
996 if ( r == E_STORAGE_FULL)
998 File::Remove(destPath);
1000 ContentManager::ScanFile(destPath);
1002 if ( r == E_SUCCESS )
1004 if ( isCopyOperation == false)
1006 File::Remove(filePath); // if Move Op remove original file
1007 ContentManager::ScanFile(filePath);
1011 delete pContentInfo;
1013 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1019 FileListPresentationModel::ClearProviderId(void)
1021 __providerId.Clear();
1025 FileListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
1026 const String* pUriData, const Tizen::Base::String* pMimeType, const HashMap* pDataList,
1027 IAppControlResponseListener* pListener)
1029 AppLogDebug("ENTER");
1030 AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
1033 __providerId.Append(providerId);
1037 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1040 result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
1044 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
1045 pGalleryApp->SetFrameEnabled(false);
1050 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1056 FileListPresentationModel::SetCurrentAlbumInfo(const String& albumName, const IList& directoryList)
1058 AppLogDebug("ENTER");
1060 if (&directoryList != null)
1062 if (__pDirectoryList != null && __pDirectoryList->GetCount() > 0)
1064 bool isMatched = false;
1065 int outterLoopCount = __pDirectoryList->GetCount();
1066 int innerLoopCount = 0;
1067 for (int i = 0; i < outterLoopCount ; ++i)
1070 innerLoopCount = directoryList.GetCount();
1071 for (int j = 0; j < innerLoopCount; ++j)
1073 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(
1074 *(const_cast<String*>(static_cast<const String*>(directoryList.GetAt(j))))) == 0)
1082 outterLoopCount = directoryList.GetCount();
1083 for (int i = 0; i < outterLoopCount; ++i)
1086 innerLoopCount = __pDirectoryList->GetCount();
1087 for (int j = 0; j < innerLoopCount; ++j)
1089 if (const_cast<String*>(static_cast<const String*>(directoryList.GetAt(i)))->CompareTo(
1090 *(static_cast<String*>(__pDirectoryList->GetAt(j)))) == 0)
1100 __albumName = albumName;
1101 __providerId.Clear();
1103 if (__pDirectoryList != null)
1105 delete __pDirectoryList;
1107 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1109 int loopCount = directoryList.GetCount();
1110 for (int i = 0; i < loopCount; ++i)
1112 __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>
1113 (static_cast<const String*>(directoryList.GetAt(i))))));
1116 if (__pContentInfoList != null)
1118 delete __pContentInfoList;
1119 __pContentInfoList = null;
1122 if (GetAppControlMode() == APPCONTROL_MODE_PICK)
1124 AppControlMediaType appControlMediaType = GetAppControlMediaType();
1125 if (appControlMediaType == APPCONTROL_MEDIA_TYPE_IMAGE)
1127 __albumContentType = CONTENT_TYPE_IMAGE;
1129 else if (appControlMediaType == APPCONTROL_MEDIA_TYPE_VIDEO)
1131 __albumContentType = CONTENT_TYPE_VIDEO;
1134 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1135 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1141 FileListPresentationModel::RefreshCurrentAlbumContentInfoList(const ContentType contentType)
1143 AppLogDebug("ENTER");
1144 result r = RefreshContentInfoList(contentType);
1145 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1151 FileListPresentationModel::AddDirectoryIfNew(const String& dirName)
1153 bool isMatched = false;
1154 int dirCount = __pDirectoryList->GetCount();
1155 if (__albumName != ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS"))//we are not in All albums
1159 for (int i = 0; i < dirCount ; ++i)
1161 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(dirName) == 0)
1169 String fullPath = Environment::GetMediaPath();
1170 fullPath.Append(dirName);
1171 __pDirectoryList->Add(new (std::nothrow) String(fullPath));
1179 FileListPresentationModel::RefreshContentInfoList(const ContentType contentType)
1181 AppLogDebug("ENTER");
1182 if ((contentType != CONTENT_TYPE_ALL) && (contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO))
1184 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1189 if ((__pDirectoryList == null) || (__pDirectoryList->GetCount() <= 0))
1191 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1196 __albumContentType = contentType;
1198 if (__pContentInfoList != null)
1200 delete __pContentInfoList;
1201 __pContentInfoList = null;
1204 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1205 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1211 FileListPresentationModel::GetCurrentAlbumName(void) const
1213 AppLogDebug("ENTER");
1214 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1220 FileListPresentationModel::SetCurrentAlbumName(const String& albumName)
1222 AppLogDebug("ENTER");
1223 if (&albumName == null)
1225 __albumName = EMPTY_SPACE;
1229 __albumName = albumName;
1231 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1235 FileListPresentationModel::GetCurrentAlbumContentType(void) const
1237 AppLogDebug("ENTER");
1238 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1240 return __albumContentType;
1244 FileListPresentationModel::SetCurrentAlbumContentType(const ContentType contentType)
1246 AppLogDebug("ENTER");
1247 __albumContentType = contentType;
1248 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1252 FileListPresentationModel::GetAlbumDirectoryListN(void) const
1254 AppLogDebug("ENTER");
1255 IList* pAlbumDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1256 if (__pDirectoryList == null)
1258 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1260 return pAlbumDirectoryList;
1263 String* pDirectory = null;
1264 int loopCount = __pDirectoryList->GetCount();
1265 for (int i = 0; i < loopCount; ++i)
1267 pDirectory = static_cast<String*>(__pDirectoryList->GetAt(i));
1268 pAlbumDirectoryList->Add(new (std::nothrow) String(*pDirectory));
1270 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1272 return pAlbumDirectoryList;
1276 FileListPresentationModel::GetAlbumContentInfoList(void) const
1278 AppLogDebug("ENTER");
1279 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1280 if (__pContentInfoList == null)
1282 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1284 return pContentList;
1287 ContentInfo* pContentInfo = null;
1288 int loopCount = __pContentInfoList->GetCount();
1289 for (int i = 0; i < loopCount; ++i)
1291 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(i));
1292 pContentList->Add(pContentInfo);
1294 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1296 return pContentList;
1300 FileListPresentationModel::GetContentInfo(const int index) const
1302 AppLogDebug("ENTER");
1303 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1305 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1310 if (index < 0 || index >= __pContentInfoList->GetCount())
1312 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1316 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1317 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1319 return pContentInfo;
1322 IList* FileListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
1324 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1325 int loopCount = indexList.GetCount();
1326 for (int i = 0; i < loopCount; ++i)
1328 const Integer* pIndex = static_cast<const Integer*>(indexList.GetAt(i));
1330 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
1332 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
1336 return pContentIdList;
1340 FileListPresentationModel::GetCurrentAlbumContentInfoCount(void) const
1342 AppLogDebug("ENTER");
1343 if (__pContentInfoList == null)
1345 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1349 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1351 return __pContentInfoList->GetCount();
1355 FileListPresentationModel::GetContentInfoIndex(const int index) const
1357 AppLogDebug("ENTER");
1358 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1360 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1365 if (index < 0 || index >= __pContentInfoList->GetCount())
1367 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1371 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1372 ContentId contentId = pContentInfo->GetContentId();
1373 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1379 FileListPresentationModel::GetContentFilePath(const int index) const
1381 AppLogDebug("ENTER index(%d)", index);
1382 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1384 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1389 if (index < 0 || index >= __pContentInfoList->GetCount())
1391 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1396 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1397 String contentPath = pContentInfo->GetContentPath();
1398 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1404 FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnail,
1405 const ThumbnailInfo& thumbmailInfo)
1407 AppLogDebug("ENTER");
1408 Bitmap* pOverlayedImage = null;
1410 if (&thumbmailInfo != null)
1412 long duration = thumbmailInfo.GetDuration();
1415 if (&thumbnail != null)
1417 BufferInfo bufferInfo;
1418 thumbnail.Lock(bufferInfo, INFINITE);
1420 mainCanvas.Construct(bufferInfo);
1424 Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
1425 mainCanvas.Construct(mainRect);
1426 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), mainRect);
1429 Rectangle playRect(GAP_W_PLAY_FG, GAP_H_PLAY_FG, W_PLAY_FG, H_PLAY_FG);
1430 Bitmap* playBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_PLAY);
1431 if (playBitmap != null)
1433 mainCanvas.DrawBitmap(playRect, *playBitmap);
1438 Rectangle durSize(0, 0, W_DURATION, H_DURATION);
1439 Rectangle durRect(0, GAP_H_DURATION, W_DURATION, H_DURATION);
1440 Color durColor(COLOR_DURATION_BG);
1441 durColor.SetAlpha(ALPHA_DURATION);
1442 durCanvas.Construct(durSize);
1443 durCanvas.FillRectangle(durColor, durSize);
1445 durFont.Construct(FONT_STYLE_PLAIN, FONT_SIZE_DURATION);
1446 durCanvas.SetFont(durFont);
1447 durCanvas.DrawText(Point(W_DURATION_TEXT, H_DURATION_TEXT),
1448 CommonUtil::DurationToTimeString(duration), COLOR_TEXT_OUTLINE);
1450 durBitmap.Construct(durCanvas, durCanvas.GetBounds());
1451 mainCanvas.DrawBitmap(durRect, durBitmap);
1453 pOverlayedImage = new (std::nothrow) Bitmap();
1454 pOverlayedImage->Construct(mainCanvas, mainCanvas.GetBounds());
1456 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1458 return pOverlayedImage;
1462 FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
1463 const Bitmap& originalBitmap, const Rectangle& originalBitmapPosition) const
1465 AppLogDebug("ENTER");
1466 if (&originalBitmap == null || &originalBitmap == null)
1468 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1473 BufferInfo bufferInfo;
1474 bgBitmap.Lock(bufferInfo, INFINITE);
1477 mainCanvas.Construct(bufferInfo);
1479 mainCanvas.DrawBitmap(originalBitmapPosition, originalBitmap);
1481 Bitmap* pMainImage = new (std::nothrow) Bitmap();
1482 pMainImage->Construct(mainCanvas,mainCanvas.GetBounds());
1483 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1489 FileListPresentationModel::GetContentInfoListInDirectoryListN(const IList& contentDirectoryList,
1490 ContentType contentType)const
1492 AppLogDebug("ENTER");
1493 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1495 if ((&contentDirectoryList == null) || (contentDirectoryList.GetCount() == 0)
1496 || ((contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO) && (contentType != CONTENT_TYPE_ALL)))
1498 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1499 return pContentList;
1502 ContentDirectory contentDirectory;
1503 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1504 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
1506 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1508 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
1510 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1512 result r = contentDirectory.Construct(*pContentTypeList);
1513 delete pContentTypeList;
1517 int pageNo = SIZE_PAGE_NO;
1518 int countPerPage = SIZE_CONUNT_PER_PAGE;
1519 String* pContentDirectory = null;
1521 int loopCount = contentDirectoryList.GetCount();
1522 for (int i = 0; i < loopCount; ++i)
1524 IList* pIList = null;
1525 pContentDirectory = const_cast<String*>(static_cast<const String*>(contentDirectoryList.GetAt(i)));
1526 if (pContentDirectory != null)
1528 pIList = contentDirectory.GetContentDirectoryItemListN(*pContentDirectory, pageNo, countPerPage,
1529 CONTENT_INFO_ORDER, SORT_ORDER_NONE);
1533 pContentList->AddItems(*pIList);
1538 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1540 return pContentList;
1544 FileListPresentationModel::ConvertToAlbumName(const String& targetPath)const
1546 AppLogDebug("ENTER");
1548 if (&targetPath == null || targetPath.GetLength() == 0)
1553 if (targetPath == RESERVED_CAMERA_PATH || targetPath == RESERVED_CAMERA_PATH_EXT)
1555 albumName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
1557 else if (targetPath == RESERVED_DOWNLOAD_PATH)
1559 albumName = ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS");
1563 String directoryName = GetDirecotyNameFromFullPath(targetPath);
1564 albumName = directoryName;
1571 FileListPresentationModel::GetAppControlMode(void) const
1573 AppLogDebug("Enter");
1574 AppLogDebug("Exit");
1576 return __appControlMode;
1580 FileListPresentationModel::GetAppControlMediaType(void) const
1582 AppLogDebug("Enter");
1583 AppLogDebug("Exit");
1585 return __appControlMediaType;
1588 AppControlSelectionMode
1589 FileListPresentationModel::GetAppControlSelectionMode(void) const
1591 AppLogDebug("Enter");
1592 AppLogDebug("Exit");
1594 return __appControlSelectionMode;
1598 FileListPresentationModel::SetUpdateProgressStatus(const bool status)
1600 AppLogDebug("ENTER status = %d",status);
1601 __updateProgressStatus = status;
1602 AppLogDebug("EXIT");
1606 FileListPresentationModel::RotateImage(int index, RotateMode rotateMode)
1608 result r = E_SUCCESS;
1609 ImageBuffer rotateBuffer;
1610 ImageBuffer* pRotatedBuffer = null;
1611 ImageFormat imageFormat;
1613 String filePath = GetContentFilePath(index);
1614 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1615 if (contentType == CONTENT_TYPE_VIDEO)
1620 r = img.Construct();
1624 imageFormat = img.GetImageFormat(filePath);
1626 r = rotateBuffer.Construct(filePath);
1629 if (rotateMode == ROTATE_MODE_RIGHT)
1631 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1635 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1639 if (pRotatedBuffer != null)
1641 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1642 delete pRotatedBuffer;
1643 ContentManager::ScanFile(filePath);
1651 FileListPresentationModel::ClearImageCache(void)
1653 AppLogDebug("ENTER");
1655 if(__pIconListViewCache != null)
1657 bool clearThumbnailReq = true;
1658 while(__pIconListViewCache->GetCount() != 0)
1660 //This is to Clear the Thumbnail Reuqests only Once
1661 if(clearThumbnailReq == true)
1663 ClearThumbnailRequests();
1664 clearThumbnailReq = false;
1666 __pIconListViewCache->RemoveAt(0, true);
1669 AppLogDebug("EXIT");
1673 FileListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
1675 AppLogDebug("ENTER");
1676 if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
1678 IFormContentUpdateEventListener* pInterface = null;
1679 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1680 while (pEventEnum->MoveNext() == E_SUCCESS)
1682 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1683 pInterface->OnContentUpdated();
1687 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));