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 if (__pContentIdList)
103 __pContentIdList->RemoveAll(true);
104 delete __pContentIdList;
105 __pContentIdList = null;
107 delete __pContentManager;
108 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
111 FileListPresentationModel*
112 FileListPresentationModel::GetInstance(void)
114 AppLogDebug("ENTER");
115 if (__pPresentationModelInstance == null)
119 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
121 return __pPresentationModelInstance;
125 FileListPresentationModel::Construct(void)
127 AppLogDebug("ENTER");
129 IThumbnailEventListener* pThumbnailEventListener = static_cast<IThumbnailEventListener*>(this);
130 __pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
131 __pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
133 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
135 ContentUpdateEventListener::GetInstance();
136 __pContentManager = new (std::nothrow) ContentManager();
137 __pContentManager->Construct();
139 if (__pIconListViewCache != null)
141 __pIconListViewCache->RemoveAll(true);
142 delete __pIconListViewCache;
143 __pIconListViewCache = null;
145 __pIconListViewCache = new (std::nothrow) ArrayList(SingleObjectDeleter);
146 __pIconListViewCache->Construct(SIZE_ICON_LIST_CACHE);
148 if (__pDirectoryList != null)
150 delete __pDirectoryList;
152 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
154 if (__pContentInfoList != null)
156 delete __pContentInfoList;
158 __pContentInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
160 __pPresentationModelListener = new (std::nothrow) ArrayList();
161 __pPresentationModelListener->Construct();
163 __pContentEventListener = new (std::nothrow) ArrayList();
164 __pContentEventListener->Construct();
166 __pThumbnailProvider = ThumbnailProvider::GetInstance();
168 GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
169 const IMap* pArguments = pApp->GetAppControlArguments();
170 String operationId = pApp->GetAppControlOperationId();
172 if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
174 __appControlMode = APPCONTROL_MODE_MAIN;
176 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
178 __appControlMode = APPCONTROL_MODE_PICK;
180 String mimeType = pApp->GetMimeType();
181 if (mimeType.IsEmpty() != true)
183 if (mimeType.StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
185 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
188 if (pArguments != null)
190 const String* selectionMode = static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
192 if (pApp->GetMimeType().StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
194 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
197 if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
199 __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
203 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
205 __appControlMode = APPCONTROL_MODE_SETTING;
208 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
214 FileListPresentationModel::CreateInstance(void)
216 AppLogDebug("ENTER");
217 __pPresentationModelInstance = new (std::nothrow) FileListPresentationModel();
218 result r = __pPresentationModelInstance->Construct();
219 if (IsFailed(r) == true)
221 delete __pPresentationModelInstance;
222 __pPresentationModelInstance = null;
223 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
228 std::atexit(DestroyInstance);
229 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
233 FileListPresentationModel::DestroyInstance(void)
235 AppLogDebug("ENTER");
237 delete __pThumbnailEvent;
239 if (__pIconListViewCache != null)
241 __pIconListViewCache->RemoveAll(true);
242 delete __pIconListViewCache;
243 __pIconListViewCache = null;
246 if (__pDirectoryList != null)
248 delete __pDirectoryList;
249 __pDirectoryList = null;
252 if (__pContentInfoList != null)
254 delete __pContentInfoList;
255 __pContentInfoList = null;
258 if (__pPresentationModelListener != null)
260 delete __pPresentationModelListener;
261 __pPresentationModelListener = null;
264 if (__pContentEventListener != null)
266 delete __pContentEventListener;
267 __pContentEventListener = null;
270 delete __pPresentationModelInstance;
271 __pPresentationModelInstance = null;
273 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
277 FileListPresentationModel::GetFileNameFromFullPath(const String& fullPath, const bool withExt) const
279 AppLogDebug("ENTER");
280 if (fullPath.CompareTo(EMPTY_SPACE) == 0)
282 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
287 String delim(DIRECTORY_SEPARATOR);
288 StringTokenizer st(fullPath,delim);
290 while (st.HasMoreTokens())
292 st.GetNextToken(token);
297 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
303 String subDelim(FILE_EXT_SEPARATOR);
304 StringTokenizer subSt(token, subDelim);
306 subSt.GetNextToken(subToken);
307 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
314 FileListPresentationModel::GetDirecotyNameFromFullPath(const String& fullPath)const
316 AppLogDebug("ENTER");
317 if (fullPath == null)
319 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
323 String delim(DIRECTORY_SEPARATOR);
324 StringTokenizer st(fullPath,delim);
326 while (st.HasMoreTokens())
328 st.GetNextToken(token);
330 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
336 FileListPresentationModel::IsContainContentInDirectory(const String& directoryPath, ContentType contentType) const
338 AppLogDebug("ENTER");
339 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
340 if (&directoryPath == null || pContentTypeList == null)
342 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
347 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
349 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
351 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
353 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
356 ContentDirectory contentDirectory;
357 result r = contentDirectory.Construct(*pContentTypeList);
358 if (pContentTypeList != null)
360 delete pContentTypeList;
362 TryReturn(r == E_SUCCESS, false, "[%s] Unable to construct ContentDirectory", GetErrorMessage(r));
364 bool returnValue = false;
365 int pageNo = SIZE_PAGE_NO;
366 int countPerPage = SIZE_CONUNT_PER_PAGE;
368 IList* pContentList = contentDirectory.GetContentDirectoryItemListN(directoryPath, pageNo, countPerPage,
369 CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
371 if (pContentList == null || pContentList->GetCount() <= 0)
380 if (pContentList != null)
384 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
390 FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pName, Bitmap*& pThumbnail)
392 AppLogDebug("ENTER : index(%d)", index);
393 Bitmap* pOriginalBitmap = null;
394 Bitmap* pDestinationBitmap = null;
395 ContentInfo* pContentInfo = null;
397 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
399 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
400 if (pContentInfo == null)
402 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
409 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
413 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
414 if (pThumbnailInfo != null)
416 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
417 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
420 if ((pThumbnailInfo != null)&&(pThumbnailInfo->GetContentType() == CONTENT_TYPE_VIDEO))
422 if (pOriginalBitmap != null)
424 pDestinationBitmap = CoverVideoOverlayedImageOnThumbnailN(*pOriginalBitmap, *pThumbnailInfo);
425 delete pOriginalBitmap;
430 pDestinationBitmap = pOriginalBitmap;
433 if (pDestinationBitmap != null)
435 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
436 Rectangle thumbnailRect(RECTANGLE_THUMBNAIL_OFFSET_POSION);
437 pDestinationBitmap->Scale(Dimension(RECTANGLE_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_THUMBNAIL_OFFSET_POSION.x
438 , RECTANGLE_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_THUMBNAIL_OFFSET_POSION.y));
439 if (pThumbnailBgBitmap != null)
441 pThumbnailBgBitmap->Scale(DIMENSION_REAL_ICON);
442 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pDestinationBitmap, thumbnailRect);
443 delete pThumbnailBgBitmap;
444 delete pDestinationBitmap;
448 pThumbnail = pDestinationBitmap;
456 if (pThumbnailInfo != null)
458 delete pThumbnailInfo;
461 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
467 FileListPresentationModel::GetThumbnailVideoInSyncCacheN(const int index,
468 String*& pName, Bitmap*& pThumbnail, String*& pDuration) const
470 AppLogDebug("ENTER : index(%d)", index);
471 ContentInfo* pContentInfo = null;
472 Bitmap* pOriginalBitmap = null;
474 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
476 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
477 if (pContentInfo == null)
479 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
485 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
489 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
490 if (pThumbnailInfo != null)
492 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
493 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
494 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(pThumbnailInfo->GetDuration()));
498 pName = new (std::nothrow) String(EMPTY_SPACE);
499 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(0));
502 if (pOriginalBitmap != null)
504 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
505 Rectangle thumbnailRect(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION);
506 pOriginalBitmap->Scale(Dimension(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.x
507 , RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.y));
508 if (pThumbnailBgBitmap != null)
510 pThumbnailBgBitmap->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
511 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pOriginalBitmap, thumbnailRect);
512 delete pThumbnailBgBitmap;
514 delete pOriginalBitmap;
521 if (pThumbnail != null)
523 pThumbnail->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
526 if (pThumbnailInfo != null)
528 delete pThumbnailInfo;
530 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
536 FileListPresentationModel::RequestThumbnail(const int index)
538 AppLogDebug("ENTER : index(%d)", index);
539 ContentInfo* pContentInfo = null;
541 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
543 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
544 if (pContentInfo == null)
546 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
552 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
557 __pThumbnailProvider->RequestThumbnail(pContentInfo->GetContentId(), __pThumbnailEvent);
562 FileListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
564 AppLogDebug("ENTER");
566 if (__pThumbnailProvider != null)
568 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
575 FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
577 AppLogDebug("ENTER");
579 if (&eventArg != null)
581 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
582 if (pThumbnailEventArg == null)
584 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
588 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
589 if (pThumbnailInfo == null)
591 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
596 bool isMatch = false;
597 ContentId contentId = pThumbnailInfo->GetContentId();
599 if (__pIconListViewCache != null)
601 IEnumerator* pEnum = __pIconListViewCache->GetEnumeratorN();
602 Bitmap* pBitmap = null;
603 while (pEnum->MoveNext() == E_SUCCESS)
605 ThumbnailInfo* pTempThumbnailInfo = static_cast<ThumbnailInfo*>(pEnum->GetCurrent());
607 if (contentId == pTempThumbnailInfo->GetContentId())
609 AppLogDebug("[CHASEFIRE] PM receive (%ls)", pThumbnailInfo->GetFilePath().GetPointer());
610 pBitmap = pThumbnailInfo->GetBitmapN();
611 pTempThumbnailInfo->SetBitmap(*pBitmap);
614 pTempThumbnailInfo->SetContentType(pThumbnailInfo->GetContentType());
615 pTempThumbnailInfo->SetDuration(pThumbnailInfo->GetDuration());
616 delete pThumbnailInfo;
624 if (isMatch == false)
626 if (SIZE_ICON_LIST_CACHE <= __pIconListViewCache->GetCount())
628 __pIconListViewCache->RemoveAt(0, true);
630 AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)", __pIconListViewCache->GetCount(),
631 pThumbnailInfo->GetFilePath().GetPointer());
632 __pIconListViewCache->Add(pThumbnailInfo);
637 int loopCount = __pContentInfoList->GetCount();
638 for (int i = 0; i < loopCount; ++i)
640 if (contentId == (static_cast<ContentInfo*>(__pContentInfoList->GetAt(i)))->GetContentId())
647 IAlbumEventListener* pInterface = null;
648 IEnumerator* pEventEnum = __pPresentationModelListener->GetEnumeratorN();
649 while (pEventEnum->MoveNext() == E_SUCCESS)
651 pInterface = static_cast<IAlbumEventListener*>(pEventEnum->GetCurrent());
652 pInterface->OnThumbnailDecoded(index);
656 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
660 FileListPresentationModel::OnContentCreated(void)
662 AppLogDebug("ENTER");
663 if (__updateProgressStatus == true)
665 AppLogDebug("EXIT update in application");
668 IFormContentUpdateEventListener* pInterface = null;
669 if (__pContentEventListener == null)
674 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
675 while (pEventEnum->MoveNext() == E_SUCCESS)
677 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
678 if (pInterface != null)
680 pInterface->OnContentUpdated();
688 FileListPresentationModel::OnContentUpdated(void)
690 AppLogDebug("ENTER");
691 if (__updateProgressStatus == true)
693 AppLogDebug("EXIT update in application");
696 //Clear the ImageCaches when content is updated like rotate.
697 if (__pContentEventListener->GetCount())
702 IFormContentUpdateEventListener* pInterface = null;
703 if (__pContentEventListener == null)
708 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
709 while (pEventEnum->MoveNext() == E_SUCCESS)
711 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
712 pInterface->OnContentUpdated();
719 FileListPresentationModel::OnContentDeleted(void)
724 AppLogDebug("ENTER");
725 if (__updateProgressStatus == true)
727 AppLogDebug("EXIT update in application");
730 IFormContentUpdateEventListener* pInterface = null;
731 if (__pContentEventListener == null)
736 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
737 while (pEventEnum->MoveNext() == E_SUCCESS)
739 ClearThumbnailRequests();
740 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
741 pInterface->OnContentUpdated();
748 FileListPresentationModel::AddPresentationModelListener(const IAlbumEventListener* listener)
750 AppLogDebug("ENTER");
751 __pPresentationModelListener->Add((Object*)listener);
752 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
756 FileListPresentationModel::RemovePresentationModelListener(const IAlbumEventListener& listener)
758 AppLogDebug("ENTER");
759 __pPresentationModelListener->Remove(listener);
760 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
764 FileListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
766 AppLogDebug("ENTER");
767 if (__pContentEventListener != null)
769 __pContentEventListener->RemoveAll();
770 __pContentEventListener->Add((Object*)listener);
771 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
776 FileListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener* listener)
778 AppLogDebug("ENTER");
779 __pContentEventListener->Remove(*listener);
780 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
784 FileListPresentationModel::GetThumbnailInfoFromInternalBufferN(const ContentId& contentId) const
786 AppLogDebug("ENTER");
787 ThumbnailInfo* pThumbnailInfo = null;
788 ThumbnailInfo* pTempThumbnailInfo = null;
789 if (__pIconListViewCache != null)
791 int loopCount = __pIconListViewCache->GetCount();
792 for (int i = 0; i < loopCount; ++i)
794 pTempThumbnailInfo = static_cast<ThumbnailInfo*>(__pIconListViewCache->GetAt(i));
795 if (contentId == pTempThumbnailInfo->GetContentId())
798 pThumbnailInfo = new (std::nothrow) ThumbnailInfo();
799 Bitmap* pBitmap = pTempThumbnailInfo->GetBitmapN();
800 pThumbnailInfo->Construct(pTempThumbnailInfo->GetContentId(), pTempThumbnailInfo->GetFilePath(),
801 *pBitmap, pTempThumbnailInfo->GetContentType(), pTempThumbnailInfo->GetDuration());
807 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
809 return pThumbnailInfo;
813 FileListPresentationModel::DeleteContentFileList(const IList& contentIndexList)
815 AppLogDebug("ENTER");
816 if (&contentIndexList == null || contentIndexList.GetCount() <= 0)
818 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
823 IList * pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
824 int loopCount = contentIndexList.GetCount();
825 for (int i = 0; i < loopCount; ++i)
827 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
829 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
831 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>
832 (__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
836 loopCount = pContentIdList->GetCount();
837 for (int i = 0; i < loopCount; ++i)
839 ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(i));
840 if (pContentId != null)
842 DeleteContentFile(*pContentId);
845 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
851 FileListPresentationModel::GetCollisionIndexListN(const IList& contentIndexList, const String& destDirectory)
853 AppLogDebug("ENTER");
854 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null
855 || destDirectory.IsEmpty() == true)
857 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
862 if (File::IsFileExist(destDirectory) == false)
864 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
869 IList * pCollisionInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
870 ContentInfo* pContentInfo = null;
871 int loopCount = contentIndexList.GetCount();
872 for (int i = 0; i < loopCount; ++i)
874 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
876 if ((pIndex != null) && (pIndex->ToInt()) >= 0 && __pContentInfoList->GetCount() > pIndex->ToInt())
878 pContentInfo = const_cast<ContentInfo*>(static_cast<const ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())));
879 String filePath = pContentInfo->GetContentPath();
880 String fileName = GetFileNameFromFullPath(filePath, true);
883 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
885 destPath.Append(destDirectory);
886 destPath.Append(fileName);
890 destPath.Append(destDirectory);
891 destPath.Append(DIRECTORY_SEPARATOR);
892 destPath.Append(fileName);
895 if (File::IsFileExist(destPath) == true)
897 pCollisionInfoList->Add(*(new (std::nothrow) String(pIndex->ToString() + MULTI_ITEM_SEPARATOR + fileName)));
901 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
903 return pCollisionInfoList;
907 FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList, const String& destDirectory)
909 AppLogDebug("ENTER");
910 result r = E_SUCCESS;
911 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null || destDirectory.IsEmpty() == true)
913 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
918 if (File::IsFileExist(destDirectory) == false)
920 Directory::Create(destDirectory, true);
923 delete __pContentIdList;
924 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
925 int loopCount = contentIndexList.GetCount();
926 for (int i = 0; i < loopCount; ++i)
928 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
930 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
932 __pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
937 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
943 FileListPresentationModel::DeleteContentFile(const ContentId& contentId)
945 AppLogDebug("ENTER");
946 if (&contentId == null)
948 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
952 result r = __pContentManager->DeleteContent(contentId);
954 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
960 FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const String& destDirectory, const bool isCopyOperation)
962 AppLogDebug("ENTER");
963 if (contentId.ToString().IsEmpty() == true || destDirectory.IsEmpty() == true)
965 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
968 result r = E_SUCCESS;
969 ContentInfo* pContentInfo = __pContentManager->GetContentInfoN(contentId);
970 if (pContentInfo == null)
972 AppLogDebug("Santhosh %s", destDirectory.GetPointer());
973 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
977 String filePath = pContentInfo->GetContentPath();
978 if (filePath.GetLength() < 4)
980 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
985 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
987 destPath.Append(destDirectory);
988 destPath.Append(GetFileNameFromFullPath(filePath, true));
992 destPath.Append(destDirectory);
993 destPath.Append(DIRECTORY_SEPARATOR);
994 destPath.Append(GetFileNameFromFullPath(filePath, true));
997 if (destPath.CompareTo(filePath) == 0)
999 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
1003 if (File::IsFileExist(destPath) == true)
1005 File::Remove(destPath);
1008 r = File::Copy(filePath, destPath, false);
1010 if (r == E_STORAGE_FULL)
1012 File::Remove(destPath);
1014 ContentManager::ScanFile(destPath);
1018 if (isCopyOperation == false)
1020 File::Remove(filePath); // if Move Op remove original file
1021 ContentManager::ScanFile(filePath);
1025 delete pContentInfo;
1027 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1033 FileListPresentationModel::ClearProviderId(void)
1035 __providerId.Clear();
1039 FileListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
1040 const String* pUriData, const Tizen::Base::String* pMimeType, const HashMap* pDataList,
1041 IAppControlResponseListener* pListener)
1043 AppLogDebug("ENTER");
1044 AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
1047 __providerId.Append(providerId);
1051 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1054 result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
1058 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
1059 pGalleryApp->SetFrameEnabled(false);
1064 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1070 FileListPresentationModel::SetCurrentAlbumInfo(const String& albumName, const IList& directoryList)
1072 AppLogDebug("ENTER");
1074 if (&directoryList != null)
1076 if (__pDirectoryList != null && __pDirectoryList->GetCount() > 0)
1078 bool isMatched = false;
1079 int outterLoopCount = __pDirectoryList->GetCount();
1080 int innerLoopCount = 0;
1081 for (int i = 0; i < outterLoopCount; ++i)
1084 innerLoopCount = directoryList.GetCount();
1085 for (int j = 0; j < innerLoopCount; ++j)
1087 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(
1088 *(const_cast<String*>(static_cast<const String*>(directoryList.GetAt(j))))) == 0)
1096 outterLoopCount = directoryList.GetCount();
1097 for (int i = 0; i < outterLoopCount; ++i)
1100 innerLoopCount = __pDirectoryList->GetCount();
1101 for (int j = 0; j < innerLoopCount; ++j)
1103 if (const_cast<String*>(static_cast<const String*>(directoryList.GetAt(i)))->CompareTo(
1104 *(static_cast<String*>(__pDirectoryList->GetAt(j)))) == 0)
1114 __albumName = albumName;
1115 __providerId.Clear();
1117 if (__pDirectoryList != null)
1119 delete __pDirectoryList;
1121 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1123 int loopCount = directoryList.GetCount();
1124 for (int i = 0; i < loopCount; ++i)
1126 __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>
1127 (static_cast<const String*>(directoryList.GetAt(i))))));
1130 if (__pContentInfoList != null)
1132 delete __pContentInfoList;
1133 __pContentInfoList = null;
1136 if (GetAppControlMode() == APPCONTROL_MODE_PICK)
1138 AppControlMediaType appControlMediaType = GetAppControlMediaType();
1139 if (appControlMediaType == APPCONTROL_MEDIA_TYPE_IMAGE)
1141 __albumContentType = CONTENT_TYPE_IMAGE;
1143 else if (appControlMediaType == APPCONTROL_MEDIA_TYPE_VIDEO)
1145 __albumContentType = CONTENT_TYPE_VIDEO;
1148 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1149 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1155 FileListPresentationModel::RefreshCurrentAlbumContentInfoList(const ContentType contentType)
1157 AppLogDebug("ENTER");
1158 result r = RefreshContentInfoList(contentType);
1159 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1165 FileListPresentationModel::AddDirectoryIfNew(const String& dirName)
1168 bool isMatched = false;
1169 int dirCount = __pDirectoryList->GetCount();
1171 fullDirName = Environment::GetMediaPath();
1172 fullDirName.Append(dirName);
1174 if (__albumName != ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS"))//we are not in All albums
1179 for (int i = 0; i < dirCount; ++i)
1181 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(fullDirName) == 0)
1190 __pDirectoryList->Add(new (std::nothrow) String(fullDirName));
1195 FileListPresentationModel::RefreshContentInfoList(const ContentType contentType)
1197 AppLogDebug("ENTER");
1198 if ((contentType != CONTENT_TYPE_ALL) && (contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO))
1200 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1205 if ((__pDirectoryList == null) || (__pDirectoryList->GetCount() <= 0))
1207 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1212 __albumContentType = contentType;
1214 if (__pContentInfoList != null)
1216 delete __pContentInfoList;
1217 __pContentInfoList = null;
1220 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1221 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1227 FileListPresentationModel::GetCurrentAlbumName(void) const
1229 AppLogDebug("ENTER");
1230 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1236 FileListPresentationModel::SetCurrentAlbumName(const String& albumName)
1238 AppLogDebug("ENTER");
1239 if (&albumName == null)
1241 __albumName = EMPTY_SPACE;
1245 __albumName = albumName;
1247 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1251 FileListPresentationModel::GetCurrentAlbumContentType(void) const
1253 AppLogDebug("ENTER");
1254 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1256 return __albumContentType;
1260 FileListPresentationModel::SetCurrentAlbumContentType(const ContentType contentType)
1262 AppLogDebug("ENTER");
1263 __albumContentType = contentType;
1264 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1268 FileListPresentationModel::GetAlbumDirectoryListN(void) const
1270 AppLogDebug("ENTER");
1271 IList* pAlbumDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1272 if (__pDirectoryList == null)
1274 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1276 return pAlbumDirectoryList;
1279 String* pDirectory = null;
1280 int loopCount = __pDirectoryList->GetCount();
1281 for (int i = 0; i < loopCount; ++i)
1283 pDirectory = static_cast<String*>(__pDirectoryList->GetAt(i));
1284 pAlbumDirectoryList->Add(new (std::nothrow) String(*pDirectory));
1286 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1288 return pAlbumDirectoryList;
1292 FileListPresentationModel::GetAlbumContentInfoList(void) const
1294 AppLogDebug("ENTER");
1295 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1296 if (__pContentInfoList == null)
1298 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1300 return pContentList;
1303 ContentInfo* pContentInfo = null;
1304 int loopCount = __pContentInfoList->GetCount();
1305 for (int i = 0; i < loopCount; ++i)
1307 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(i));
1308 pContentList->Add(pContentInfo);
1310 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1312 return pContentList;
1316 FileListPresentationModel::GetContentInfo(const int index) const
1318 AppLogDebug("ENTER");
1319 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1321 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1326 if (index < 0 || index >= __pContentInfoList->GetCount())
1328 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1332 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1333 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1335 return pContentInfo;
1338 IList* FileListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
1340 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1341 int loopCount = indexList.GetCount();
1342 for (int i = 0; i < loopCount; ++i)
1344 const Integer* pIndex = static_cast<const Integer*>(indexList.GetAt(i));
1346 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
1348 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
1352 return pContentIdList;
1356 FileListPresentationModel::GetCurrentAlbumContentInfoCount(void) const
1358 AppLogDebug("ENTER");
1359 if (__pContentInfoList == null)
1361 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1365 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1367 return __pContentInfoList->GetCount();
1371 FileListPresentationModel::GetContentInfoIndex(const int index) const
1373 AppLogDebug("ENTER");
1374 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1376 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1381 if (index < 0 || index >= __pContentInfoList->GetCount())
1383 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1387 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1388 ContentId contentId = pContentInfo->GetContentId();
1389 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1395 FileListPresentationModel::GetContentFilePath(const int index) const
1397 AppLogDebug("ENTER index(%d)", index);
1398 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1400 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1405 if (index < 0 || index >= __pContentInfoList->GetCount())
1407 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1412 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1413 String contentPath = pContentInfo->GetContentPath();
1414 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1420 FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnail,
1421 const ThumbnailInfo& thumbmailInfo)
1423 AppLogDebug("ENTER");
1424 Bitmap* pOverlayedImage = null;
1426 if (&thumbmailInfo != null)
1428 long duration = thumbmailInfo.GetDuration();
1431 if (&thumbnail != null)
1433 BufferInfo bufferInfo;
1434 thumbnail.Lock(bufferInfo, INFINITE);
1436 mainCanvas.Construct(bufferInfo);
1440 Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
1441 mainCanvas.Construct(mainRect);
1442 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), mainRect);
1445 Rectangle playRect(GAP_W_PLAY_FG, GAP_H_PLAY_FG, W_PLAY_FG, H_PLAY_FG);
1446 Bitmap* playBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_PLAY);
1447 if (playBitmap != null)
1449 mainCanvas.DrawBitmap(playRect, *playBitmap);
1454 Rectangle durSize(0, 0, W_DURATION, H_DURATION);
1455 Rectangle durRect(0, GAP_H_DURATION, W_DURATION, H_DURATION);
1456 Color durColor(COLOR_DURATION_BG);
1457 durColor.SetAlpha(ALPHA_DURATION);
1458 durCanvas.Construct(durSize);
1459 durCanvas.FillRectangle(durColor, durSize);
1461 durFont.Construct(FONT_STYLE_PLAIN, FONT_SIZE_DURATION);
1462 durCanvas.SetFont(durFont);
1463 durCanvas.DrawText(Point(W_DURATION_TEXT, H_DURATION_TEXT),
1464 CommonUtil::DurationToTimeString(duration), COLOR_TEXT_OUTLINE);
1466 durBitmap.Construct(durCanvas, durCanvas.GetBounds());
1467 mainCanvas.DrawBitmap(durRect, durBitmap);
1469 pOverlayedImage = new (std::nothrow) Bitmap();
1470 pOverlayedImage->Construct(mainCanvas, mainCanvas.GetBounds());
1472 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1474 return pOverlayedImage;
1478 FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
1479 const Bitmap& originalBitmap, const Rectangle& originalBitmapPosition) const
1481 AppLogDebug("ENTER");
1482 if (&originalBitmap == null || &originalBitmap == null)
1484 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1489 BufferInfo bufferInfo;
1490 bgBitmap.Lock(bufferInfo, INFINITE);
1493 mainCanvas.Construct(bufferInfo);
1495 mainCanvas.DrawBitmap(originalBitmapPosition, originalBitmap);
1497 Bitmap* pMainImage = new (std::nothrow) Bitmap();
1498 pMainImage->Construct(mainCanvas,mainCanvas.GetBounds());
1499 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1505 FileListPresentationModel::GetContentInfoListInDirectoryListN(const IList& contentDirectoryList,
1506 ContentType contentType)const
1508 AppLogDebug("ENTER");
1509 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1511 if ((&contentDirectoryList == null) || (contentDirectoryList.GetCount() == 0)
1512 || ((contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO) && (contentType != CONTENT_TYPE_ALL)))
1514 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1515 return pContentList;
1518 ContentDirectory contentDirectory;
1519 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1520 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
1522 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1524 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
1526 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1528 result r = contentDirectory.Construct(*pContentTypeList);
1529 delete pContentTypeList;
1533 int pageNo = SIZE_PAGE_NO;
1534 int countPerPage = SIZE_CONUNT_PER_PAGE;
1535 String* pContentDirectory = null;
1537 int loopCount = contentDirectoryList.GetCount();
1538 for (int i = 0; i < loopCount; ++i)
1540 IList* pIList = null;
1541 pContentDirectory = const_cast<String*>(static_cast<const String*>(contentDirectoryList.GetAt(i)));
1542 if (pContentDirectory != null)
1544 pIList = contentDirectory.GetContentDirectoryItemListN(*pContentDirectory, pageNo, countPerPage,
1545 CONTENT_INFO_ORDER, SORT_ORDER_NONE);
1549 pContentList->AddItems(*pIList);
1554 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1556 return pContentList;
1560 FileListPresentationModel::ConvertToAlbumName(const String& targetPath)const
1562 AppLogDebug("ENTER");
1564 if (&targetPath == null || targetPath.GetLength() == 0)
1569 if (targetPath == RESERVED_CAMERA_PATH || targetPath == RESERVED_CAMERA_PATH_EXT)
1571 albumName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
1573 else if (targetPath == RESERVED_DOWNLOAD_PATH)
1575 albumName = ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS");
1579 String directoryName = GetDirecotyNameFromFullPath(targetPath);
1580 albumName = directoryName;
1587 FileListPresentationModel::GetAppControlMode(void) const
1589 AppLogDebug("Enter");
1590 AppLogDebug("Exit");
1592 return __appControlMode;
1596 FileListPresentationModel::GetAppControlMediaType(void) const
1598 AppLogDebug("Enter");
1599 AppLogDebug("Exit");
1601 return __appControlMediaType;
1604 AppControlSelectionMode
1605 FileListPresentationModel::GetAppControlSelectionMode(void) const
1607 AppLogDebug("Enter");
1608 AppLogDebug("Exit");
1610 return __appControlSelectionMode;
1614 FileListPresentationModel::SetUpdateProgressStatus(const bool status)
1616 AppLogDebug("ENTER status = %d",status);
1617 __updateProgressStatus = status;
1618 AppLogDebug("EXIT");
1622 FileListPresentationModel::RotateImage(int index, RotateMode rotateMode)
1624 result r = E_SUCCESS;
1625 ImageBuffer rotateBuffer;
1626 ImageBuffer* pRotatedBuffer = null;
1627 ImageFormat imageFormat;
1629 String filePath = GetContentFilePath(index);
1630 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1631 if (contentType == CONTENT_TYPE_VIDEO)
1636 r = img.Construct();
1640 imageFormat = img.GetImageFormat(filePath);
1642 r = rotateBuffer.Construct(filePath);
1645 if (rotateMode == ROTATE_MODE_RIGHT)
1647 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1651 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1655 if (pRotatedBuffer != null)
1657 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1658 delete pRotatedBuffer;
1659 ContentManager::ScanFile(filePath);
1667 FileListPresentationModel::ClearImageCache(void)
1669 AppLogDebug("ENTER");
1671 if(__pIconListViewCache != null)
1673 bool clearThumbnailReq = true;
1674 while(__pIconListViewCache->GetCount() != 0)
1676 //This is to Clear the Thumbnail Reuqests only Once
1677 if(clearThumbnailReq == true)
1679 ClearThumbnailRequests();
1680 clearThumbnailReq = false;
1682 __pIconListViewCache->RemoveAt(0, true);
1685 AppLogDebug("EXIT");
1689 FileListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
1691 AppLogDebug("ENTER");
1692 if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
1694 IFormContentUpdateEventListener* pInterface = null;
1695 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1696 while (pEventEnum->MoveNext() == E_SUCCESS)
1698 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1699 pInterface->OnContentUpdated();
1703 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));