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;
238 __pIconListViewCache = null;
240 if (__pIconListViewCache != null)
242 __pIconListViewCache->RemoveAll(true);
243 delete __pIconListViewCache;
244 __pIconListViewCache = null;
247 if (__pDirectoryList != null)
249 delete __pDirectoryList;
250 __pDirectoryList = null;
253 if (__pContentInfoList != null)
255 delete __pContentInfoList;
256 __pContentInfoList = null;
259 if (__pPresentationModelListener != null)
261 delete __pPresentationModelListener;
262 __pPresentationModelListener = null;
265 if (__pContentEventListener != null)
267 delete __pContentEventListener;
268 __pContentEventListener = null;
271 delete __pPresentationModelInstance;
272 __pPresentationModelInstance = null;
274 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
278 FileListPresentationModel::GetFileNameFromFullPath(const String& fullPath, const bool withExt) const
280 AppLogDebug("ENTER");
281 if (fullPath.CompareTo(EMPTY_SPACE) == 0)
283 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
288 String delim(DIRECTORY_SEPARATOR);
289 StringTokenizer st(fullPath,delim);
291 while (st.HasMoreTokens())
293 st.GetNextToken(token);
298 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
304 String subDelim(FILE_EXT_SEPARATOR);
305 StringTokenizer subSt(token, subDelim);
307 subSt.GetNextToken(subToken);
308 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
315 FileListPresentationModel::GetDirecotyNameFromFullPath(const String& fullPath)const
317 AppLogDebug("ENTER");
318 if (fullPath == null)
320 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
324 String delim(DIRECTORY_SEPARATOR);
325 StringTokenizer st(fullPath,delim);
327 while (st.HasMoreTokens())
329 st.GetNextToken(token);
331 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
337 FileListPresentationModel::IsContainContentInDirectory(const String& directoryPath, ContentType contentType) const
339 AppLogDebug("ENTER");
340 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
341 if (&directoryPath == null || pContentTypeList == null)
343 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
348 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
350 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
352 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
354 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
357 ContentDirectory contentDirectory;
358 result r = contentDirectory.Construct(*pContentTypeList);
359 if (pContentTypeList != null)
361 delete pContentTypeList;
363 TryReturn(r == E_SUCCESS, false, "[%s] Unable to construct ContentDirectory", GetErrorMessage(r));
365 bool returnValue = false;
366 int pageNo = SIZE_PAGE_NO;
367 int countPerPage = SIZE_CONUNT_PER_PAGE;
369 IList* pContentList = contentDirectory.GetContentDirectoryItemListN(directoryPath, pageNo, countPerPage,
370 CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
372 if (pContentList == null || pContentList->GetCount() <= 0)
381 if (pContentList != null)
385 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
391 FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pName, Bitmap*& pThumbnail)
393 AppLogDebug("ENTER : index(%d)", index);
394 Bitmap* pOriginalBitmap = null;
395 Bitmap* pDestinationBitmap = null;
396 ContentInfo* pContentInfo = null;
398 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
400 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
401 if (pContentInfo == null)
403 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
410 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
414 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
415 if (pThumbnailInfo != null)
417 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
418 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
421 if ((pThumbnailInfo != null)&&(pThumbnailInfo->GetContentType() == CONTENT_TYPE_VIDEO))
423 if (pOriginalBitmap != null)
425 pDestinationBitmap = CoverVideoOverlayedImageOnThumbnailN(*pOriginalBitmap, *pThumbnailInfo);
426 delete pOriginalBitmap;
431 pDestinationBitmap = pOriginalBitmap;
434 if (pDestinationBitmap != null)
436 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
437 Rectangle thumbnailRect(RECTANGLE_THUMBNAIL_OFFSET_POSION);
438 pDestinationBitmap->Scale(Dimension(RECTANGLE_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_THUMBNAIL_OFFSET_POSION.x
439 , RECTANGLE_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_THUMBNAIL_OFFSET_POSION.y));
440 if (pThumbnailBgBitmap != null)
442 pThumbnailBgBitmap->Scale(DIMENSION_REAL_ICON);
443 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pDestinationBitmap, thumbnailRect);
444 delete pThumbnailBgBitmap;
445 delete pDestinationBitmap;
449 pThumbnail = pDestinationBitmap;
457 if (pThumbnailInfo != null)
459 delete pThumbnailInfo;
462 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
468 FileListPresentationModel::GetThumbnailVideoInSyncCacheN(const int index,
469 String*& pName, Bitmap*& pThumbnail, String*& pDuration) const
471 AppLogDebug("ENTER : index(%d)", index);
472 ContentInfo* pContentInfo = null;
473 Bitmap* pOriginalBitmap = null;
475 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
477 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
478 if (pContentInfo == null)
480 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
486 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
490 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
491 if (pThumbnailInfo != null)
493 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
494 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
495 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(pThumbnailInfo->GetDuration()));
499 pName = new (std::nothrow) String(EMPTY_SPACE);
500 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(0));
503 if (pOriginalBitmap != null)
505 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
506 Rectangle thumbnailRect(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION);
507 pOriginalBitmap->Scale(Dimension(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.x
508 , RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.y));
509 if (pThumbnailBgBitmap != null)
511 pThumbnailBgBitmap->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
512 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pOriginalBitmap, thumbnailRect);
513 delete pThumbnailBgBitmap;
515 delete pOriginalBitmap;
522 if (pThumbnail != null)
524 pThumbnail->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
527 if (pThumbnailInfo != null)
529 delete pThumbnailInfo;
531 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
537 FileListPresentationModel::RequestThumbnail(const int index)
539 AppLogDebug("ENTER : index(%d)", index);
540 ContentInfo* pContentInfo = null;
542 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
544 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
545 if (pContentInfo == null)
547 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
553 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
558 __pThumbnailProvider->RequestThumbnail(pContentInfo->GetContentId(), __pThumbnailEvent);
563 FileListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
565 AppLogDebug("ENTER");
567 if (__pThumbnailProvider != null)
569 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
576 FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
578 AppLogDebug("ENTER");
580 if (&eventArg != null)
582 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
583 if (pThumbnailEventArg == null)
585 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
589 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
590 if (pThumbnailInfo == null)
592 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
597 bool isMatch = false;
598 ContentId contentId = pThumbnailInfo->GetContentId();
600 if (__pIconListViewCache != null)
602 IEnumerator* pEnum = __pIconListViewCache->GetEnumeratorN();
603 Bitmap* pBitmap = null;
604 while (pEnum->MoveNext() == E_SUCCESS)
606 ThumbnailInfo* pTempThumbnailInfo = static_cast<ThumbnailInfo*>(pEnum->GetCurrent());
608 if (contentId == pTempThumbnailInfo->GetContentId())
610 AppLogDebug("[CHASEFIRE] PM receive (%ls)", pThumbnailInfo->GetFilePath().GetPointer());
611 pBitmap = pThumbnailInfo->GetBitmapN();
612 pTempThumbnailInfo->SetBitmap(*pBitmap);
615 pTempThumbnailInfo->SetContentType(pThumbnailInfo->GetContentType());
616 pTempThumbnailInfo->SetDuration(pThumbnailInfo->GetDuration());
617 delete pThumbnailInfo;
625 if (isMatch == false)
627 if (SIZE_ICON_LIST_CACHE <= __pIconListViewCache->GetCount())
629 __pIconListViewCache->RemoveAt(0, true);
631 AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)", __pIconListViewCache->GetCount(),
632 pThumbnailInfo->GetFilePath().GetPointer());
633 __pIconListViewCache->Add(pThumbnailInfo);
638 int loopCount = __pContentInfoList->GetCount();
639 for (int i = 0; i < loopCount; ++i)
641 if (contentId == (static_cast<ContentInfo*>(__pContentInfoList->GetAt(i)))->GetContentId())
648 IAlbumEventListener* pInterface = null;
649 IEnumerator* pEventEnum = __pPresentationModelListener->GetEnumeratorN();
650 while (pEventEnum->MoveNext() == E_SUCCESS)
652 pInterface = static_cast<IAlbumEventListener*>(pEventEnum->GetCurrent());
653 pInterface->OnThumbnailDecoded(index);
657 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
661 FileListPresentationModel::OnContentCreated(void)
663 AppLogDebug("ENTER");
664 if (__updateProgressStatus == true)
666 AppLogDebug("EXIT update in application");
669 IFormContentUpdateEventListener* pInterface = null;
670 if (__pContentEventListener == null)
675 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
676 while (pEventEnum->MoveNext() == E_SUCCESS)
678 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
679 if (pInterface != null)
681 pInterface->OnContentUpdated();
689 FileListPresentationModel::OnContentUpdated(void)
691 AppLogDebug("ENTER");
692 if (__updateProgressStatus == true)
694 AppLogDebug("EXIT update in application");
697 //Clear the ImageCaches when content is updated like rotate.
698 if (__pContentEventListener->GetCount())
703 IFormContentUpdateEventListener* pInterface = null;
704 if (__pContentEventListener == null)
709 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
710 while (pEventEnum->MoveNext() == E_SUCCESS)
712 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
713 pInterface->OnContentUpdated();
720 FileListPresentationModel::OnContentDeleted(void)
722 AppLogDebug("ENTER");
723 if (__updateProgressStatus == true)
725 AppLogDebug("EXIT update in application");
728 IFormContentUpdateEventListener* pInterface = null;
729 if (__pContentEventListener == null)
734 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
735 while (pEventEnum->MoveNext() == E_SUCCESS)
737 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
738 pInterface->OnContentUpdated();
745 FileListPresentationModel::AddPresentationModelListener(const IAlbumEventListener* listener)
747 AppLogDebug("ENTER");
748 __pPresentationModelListener->Add((Object*)listener);
749 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
753 FileListPresentationModel::RemovePresentationModelListener(const IAlbumEventListener& listener)
755 AppLogDebug("ENTER");
756 __pPresentationModelListener->Remove(listener);
757 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
761 FileListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
763 AppLogDebug("ENTER");
764 if (__pContentEventListener != null)
766 __pContentEventListener->RemoveAll();
767 __pContentEventListener->Add((Object*)listener);
768 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
773 FileListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener* listener)
775 AppLogDebug("ENTER");
776 __pContentEventListener->Remove(*listener);
777 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
781 FileListPresentationModel::GetThumbnailInfoFromInternalBufferN(const ContentId& contentId) const
783 AppLogDebug("ENTER");
784 ThumbnailInfo* pThumbnailInfo = null;
785 ThumbnailInfo* pTempThumbnailInfo = null;
786 if (__pIconListViewCache != null)
788 int loopCount = __pIconListViewCache->GetCount();
789 for (int i = 0; i < loopCount; ++i)
791 pTempThumbnailInfo = static_cast<ThumbnailInfo*>(__pIconListViewCache->GetAt(i));
792 if (contentId == pTempThumbnailInfo->GetContentId())
795 pThumbnailInfo = new (std::nothrow) ThumbnailInfo();
796 Bitmap* pBitmap = pTempThumbnailInfo->GetBitmapN();
797 pThumbnailInfo->Construct(pTempThumbnailInfo->GetContentId(), pTempThumbnailInfo->GetFilePath(),
798 *pBitmap, pTempThumbnailInfo->GetContentType(), pTempThumbnailInfo->GetDuration());
804 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
806 return pThumbnailInfo;
810 FileListPresentationModel::DeleteContentFileList(const IList& contentIndexList)
812 AppLogDebug("ENTER");
813 if (&contentIndexList == null || contentIndexList.GetCount() <= 0)
815 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
820 IList * pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
821 int loopCount = contentIndexList.GetCount();
822 for (int i = 0; i < loopCount; ++i)
824 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
826 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
828 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>
829 (__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
833 loopCount = pContentIdList->GetCount();
834 for (int i = 0; i < loopCount; ++i)
836 ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(i));
837 if (pContentId != null)
839 DeleteContentFile(*pContentId);
842 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
848 FileListPresentationModel::GetCollisionIndexListN(const IList& contentIndexList, const String& destDirectory)
850 AppLogDebug("ENTER");
851 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null
852 || destDirectory.IsEmpty() == true)
854 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
859 if (File::IsFileExist(destDirectory) == false)
861 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
866 IList * pCollisionInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
867 ContentInfo* pContentInfo = null;
868 int loopCount = contentIndexList.GetCount();
869 for (int i = 0; i < loopCount; ++i)
871 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
873 if ((pIndex != null) && (pIndex->ToInt()) >= 0 && __pContentInfoList->GetCount() > pIndex->ToInt())
875 pContentInfo = const_cast<ContentInfo*>(static_cast<const ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())));
876 String filePath = pContentInfo->GetContentPath();
877 String fileName = GetFileNameFromFullPath(filePath, true);
880 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
882 destPath.Append(destDirectory);
883 destPath.Append(fileName);
887 destPath.Append(destDirectory);
888 destPath.Append(DIRECTORY_SEPARATOR);
889 destPath.Append(fileName);
892 if (File::IsFileExist(destPath) == true)
894 pCollisionInfoList->Add(*(new (std::nothrow) String(pIndex->ToString() + MULTI_ITEM_SEPARATOR + fileName)));
898 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
900 return pCollisionInfoList;
904 FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList, const String& destDirectory)
906 AppLogDebug("ENTER");
907 result r = E_SUCCESS;
908 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null || destDirectory.IsEmpty() == true)
910 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
915 if (File::IsFileExist(destDirectory) == false)
917 Directory::Create(destDirectory, true);
920 delete __pContentIdList;
921 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
922 int loopCount = contentIndexList.GetCount();
923 for (int i = 0; i < loopCount; ++i)
925 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
927 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
929 __pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
934 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
940 FileListPresentationModel::DeleteContentFile(const ContentId& contentId)
942 AppLogDebug("ENTER");
943 if (&contentId == null)
945 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
949 result r = __pContentManager->DeleteContent(contentId);
951 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
957 FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const String& destDirectory, const bool isCopyOperation)
959 AppLogDebug("ENTER");
960 if (contentId.ToString().IsEmpty() == true || destDirectory.IsEmpty() == true)
962 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
965 result r = E_SUCCESS;
966 ContentInfo* pContentInfo = __pContentManager->GetContentInfoN(contentId);
967 if (pContentInfo == null)
969 AppLogDebug("Santhosh %s", destDirectory.GetPointer());
970 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
974 String filePath = pContentInfo->GetContentPath();
975 if (filePath.GetLength() < 4)
977 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
982 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
984 destPath.Append(destDirectory);
985 destPath.Append(GetFileNameFromFullPath(filePath, true));
989 destPath.Append(destDirectory);
990 destPath.Append(DIRECTORY_SEPARATOR);
991 destPath.Append(GetFileNameFromFullPath(filePath, true));
994 if (destPath.CompareTo(filePath) == 0)
996 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
1000 if (File::IsFileExist(destPath) == true)
1002 File::Remove(destPath);
1005 r = File::Copy(filePath, destPath, false);
1007 if (r == E_STORAGE_FULL)
1009 File::Remove(destPath);
1011 ContentManager::ScanFile(destPath);
1015 if (isCopyOperation == false)
1017 File::Remove(filePath); // if Move Op remove original file
1018 ContentManager::ScanFile(filePath);
1022 delete pContentInfo;
1024 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1030 FileListPresentationModel::ClearProviderId(void)
1032 __providerId.Clear();
1036 FileListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
1037 const String* pUriData, const Tizen::Base::String* pMimeType, const HashMap* pDataList,
1038 IAppControlResponseListener* pListener)
1040 AppLogDebug("ENTER");
1041 AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
1044 __providerId.Append(providerId);
1048 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1051 result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
1055 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
1056 pGalleryApp->SetFrameEnabled(false);
1061 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1067 FileListPresentationModel::SetCurrentAlbumInfo(const String& albumName, const IList& directoryList)
1069 AppLogDebug("ENTER");
1071 if (&directoryList != null)
1073 if (__pDirectoryList != null && __pDirectoryList->GetCount() > 0)
1075 bool isMatched = false;
1076 int outterLoopCount = __pDirectoryList->GetCount();
1077 int innerLoopCount = 0;
1078 for (int i = 0; i < outterLoopCount; ++i)
1081 innerLoopCount = directoryList.GetCount();
1082 for (int j = 0; j < innerLoopCount; ++j)
1084 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(
1085 *(const_cast<String*>(static_cast<const String*>(directoryList.GetAt(j))))) == 0)
1093 outterLoopCount = directoryList.GetCount();
1094 for (int i = 0; i < outterLoopCount; ++i)
1097 innerLoopCount = __pDirectoryList->GetCount();
1098 for (int j = 0; j < innerLoopCount; ++j)
1100 if (const_cast<String*>(static_cast<const String*>(directoryList.GetAt(i)))->CompareTo(
1101 *(static_cast<String*>(__pDirectoryList->GetAt(j)))) == 0)
1111 __albumName = albumName;
1112 __providerId.Clear();
1114 if (__pDirectoryList != null)
1116 delete __pDirectoryList;
1118 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1120 int loopCount = directoryList.GetCount();
1121 for (int i = 0; i < loopCount; ++i)
1123 __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>
1124 (static_cast<const String*>(directoryList.GetAt(i))))));
1127 if (__pContentInfoList != null)
1129 delete __pContentInfoList;
1130 __pContentInfoList = null;
1133 if (GetAppControlMode() == APPCONTROL_MODE_PICK)
1135 AppControlMediaType appControlMediaType = GetAppControlMediaType();
1136 if (appControlMediaType == APPCONTROL_MEDIA_TYPE_IMAGE)
1138 __albumContentType = CONTENT_TYPE_IMAGE;
1140 else if (appControlMediaType == APPCONTROL_MEDIA_TYPE_VIDEO)
1142 __albumContentType = CONTENT_TYPE_VIDEO;
1145 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1146 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1152 FileListPresentationModel::RefreshCurrentAlbumContentInfoList(const ContentType contentType)
1154 AppLogDebug("ENTER");
1155 result r = RefreshContentInfoList(contentType);
1156 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1162 FileListPresentationModel::AddDirectoryIfNew(const String& dirName)
1165 bool isMatched = false;
1166 int dirCount = __pDirectoryList->GetCount();
1168 fullDirName = Environment::GetMediaPath();
1169 fullDirName.Append(dirName);
1171 if (__albumName != ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS"))//we are not in All albums
1176 for (int i = 0; i < dirCount; ++i)
1178 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(fullDirName) == 0)
1187 __pDirectoryList->Add(new (std::nothrow) String(fullDirName));
1192 FileListPresentationModel::RefreshContentInfoList(const ContentType contentType)
1194 AppLogDebug("ENTER");
1195 if ((contentType != CONTENT_TYPE_ALL) && (contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO))
1197 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1202 if ((__pDirectoryList == null) || (__pDirectoryList->GetCount() <= 0))
1204 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1209 __albumContentType = contentType;
1211 if (__pContentInfoList != null)
1213 delete __pContentInfoList;
1214 __pContentInfoList = null;
1217 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1218 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1224 FileListPresentationModel::GetCurrentAlbumName(void) const
1226 AppLogDebug("ENTER");
1227 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1233 FileListPresentationModel::SetCurrentAlbumName(const String& albumName)
1235 AppLogDebug("ENTER");
1236 if (&albumName == null)
1238 __albumName = EMPTY_SPACE;
1242 __albumName = albumName;
1244 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1248 FileListPresentationModel::GetCurrentAlbumContentType(void) const
1250 AppLogDebug("ENTER");
1251 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1253 return __albumContentType;
1257 FileListPresentationModel::SetCurrentAlbumContentType(const ContentType contentType)
1259 AppLogDebug("ENTER");
1260 __albumContentType = contentType;
1261 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1265 FileListPresentationModel::GetAlbumDirectoryListN(void) const
1267 AppLogDebug("ENTER");
1268 IList* pAlbumDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1269 if (__pDirectoryList == null)
1271 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1273 return pAlbumDirectoryList;
1276 String* pDirectory = null;
1277 int loopCount = __pDirectoryList->GetCount();
1278 for (int i = 0; i < loopCount; ++i)
1280 pDirectory = static_cast<String*>(__pDirectoryList->GetAt(i));
1281 pAlbumDirectoryList->Add(new (std::nothrow) String(*pDirectory));
1283 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1285 return pAlbumDirectoryList;
1289 FileListPresentationModel::GetAlbumContentInfoList(void) const
1291 AppLogDebug("ENTER");
1292 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1293 if (__pContentInfoList == null)
1295 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1297 return pContentList;
1300 ContentInfo* pContentInfo = null;
1301 int loopCount = __pContentInfoList->GetCount();
1302 for (int i = 0; i < loopCount; ++i)
1304 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(i));
1305 pContentList->Add(pContentInfo);
1307 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1309 return pContentList;
1313 FileListPresentationModel::GetContentInfo(const int index) const
1315 AppLogDebug("ENTER");
1316 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1318 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1323 if (index < 0 || index >= __pContentInfoList->GetCount())
1325 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1329 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1330 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1332 return pContentInfo;
1335 IList* FileListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
1337 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1338 int loopCount = indexList.GetCount();
1339 for (int i = 0; i < loopCount; ++i)
1341 const Integer* pIndex = static_cast<const Integer*>(indexList.GetAt(i));
1343 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
1345 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
1349 return pContentIdList;
1353 FileListPresentationModel::GetCurrentAlbumContentInfoCount(void) const
1355 AppLogDebug("ENTER");
1356 if (__pContentInfoList == null)
1358 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1362 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1364 return __pContentInfoList->GetCount();
1368 FileListPresentationModel::GetContentInfoIndex(const int index) const
1370 AppLogDebug("ENTER");
1371 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1373 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1378 if (index < 0 || index >= __pContentInfoList->GetCount())
1380 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1384 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1385 ContentId contentId = pContentInfo->GetContentId();
1386 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1392 FileListPresentationModel::GetContentFilePath(const int index) const
1394 AppLogDebug("ENTER index(%d)", index);
1395 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1397 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1402 if (index < 0 || index >= __pContentInfoList->GetCount())
1404 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1409 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1410 String contentPath = pContentInfo->GetContentPath();
1411 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1417 FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnail,
1418 const ThumbnailInfo& thumbmailInfo)
1420 AppLogDebug("ENTER");
1421 Bitmap* pOverlayedImage = null;
1423 if (&thumbmailInfo != null)
1425 long duration = thumbmailInfo.GetDuration();
1428 if (&thumbnail != null)
1430 BufferInfo bufferInfo;
1431 thumbnail.Lock(bufferInfo, INFINITE);
1433 mainCanvas.Construct(bufferInfo);
1437 Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
1438 mainCanvas.Construct(mainRect);
1439 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), mainRect);
1442 Rectangle playRect(GAP_W_PLAY_FG, GAP_H_PLAY_FG, W_PLAY_FG, H_PLAY_FG);
1443 Bitmap* playBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_PLAY);
1444 if (playBitmap != null)
1446 mainCanvas.DrawBitmap(playRect, *playBitmap);
1451 Rectangle durSize(0, 0, W_DURATION, H_DURATION);
1452 Rectangle durRect(0, GAP_H_DURATION, W_DURATION, H_DURATION);
1453 Color durColor(COLOR_DURATION_BG);
1454 durColor.SetAlpha(ALPHA_DURATION);
1455 durCanvas.Construct(durSize);
1456 durCanvas.FillRectangle(durColor, durSize);
1458 durFont.Construct(FONT_STYLE_PLAIN, FONT_SIZE_DURATION);
1459 durCanvas.SetFont(durFont);
1460 durCanvas.DrawText(Point(W_DURATION_TEXT, H_DURATION_TEXT),
1461 CommonUtil::DurationToTimeString(duration), COLOR_TEXT_OUTLINE);
1463 durBitmap.Construct(durCanvas, durCanvas.GetBounds());
1464 mainCanvas.DrawBitmap(durRect, durBitmap);
1466 pOverlayedImage = new (std::nothrow) Bitmap();
1467 pOverlayedImage->Construct(mainCanvas, mainCanvas.GetBounds());
1469 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1471 return pOverlayedImage;
1475 FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
1476 const Bitmap& originalBitmap, const Rectangle& originalBitmapPosition) const
1478 AppLogDebug("ENTER");
1479 if (&originalBitmap == null || &originalBitmap == null)
1481 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1486 BufferInfo bufferInfo;
1487 bgBitmap.Lock(bufferInfo, INFINITE);
1490 mainCanvas.Construct(bufferInfo);
1492 mainCanvas.DrawBitmap(originalBitmapPosition, originalBitmap);
1494 Bitmap* pMainImage = new (std::nothrow) Bitmap();
1495 pMainImage->Construct(mainCanvas,mainCanvas.GetBounds());
1496 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1502 FileListPresentationModel::GetContentInfoListInDirectoryListN(const IList& contentDirectoryList,
1503 ContentType contentType)const
1505 AppLogDebug("ENTER");
1506 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1508 if ((&contentDirectoryList == null) || (contentDirectoryList.GetCount() == 0)
1509 || ((contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO) && (contentType != CONTENT_TYPE_ALL)))
1511 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1512 return pContentList;
1515 ContentDirectory contentDirectory;
1516 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1517 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
1519 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1521 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
1523 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1525 result r = contentDirectory.Construct(*pContentTypeList);
1526 delete pContentTypeList;
1530 int pageNo = SIZE_PAGE_NO;
1531 int countPerPage = SIZE_CONUNT_PER_PAGE;
1532 String* pContentDirectory = null;
1534 int loopCount = contentDirectoryList.GetCount();
1535 for (int i = 0; i < loopCount; ++i)
1537 IList* pIList = null;
1538 pContentDirectory = const_cast<String*>(static_cast<const String*>(contentDirectoryList.GetAt(i)));
1539 if (pContentDirectory != null)
1541 pIList = contentDirectory.GetContentDirectoryItemListN(*pContentDirectory, pageNo, countPerPage,
1542 CONTENT_INFO_ORDER, SORT_ORDER_NONE);
1546 pContentList->AddItems(*pIList);
1551 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1553 return pContentList;
1557 FileListPresentationModel::ConvertToAlbumName(const String& targetPath)const
1559 AppLogDebug("ENTER");
1561 if (&targetPath == null || targetPath.GetLength() == 0)
1566 if (targetPath == RESERVED_CAMERA_PATH || targetPath == RESERVED_CAMERA_PATH_EXT)
1568 albumName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
1570 else if (targetPath == RESERVED_DOWNLOAD_PATH)
1572 albumName = ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS");
1576 String directoryName = GetDirecotyNameFromFullPath(targetPath);
1577 albumName = directoryName;
1584 FileListPresentationModel::GetAppControlMode(void) const
1586 AppLogDebug("Enter");
1587 AppLogDebug("Exit");
1589 return __appControlMode;
1593 FileListPresentationModel::GetAppControlMediaType(void) const
1595 AppLogDebug("Enter");
1596 AppLogDebug("Exit");
1598 return __appControlMediaType;
1601 AppControlSelectionMode
1602 FileListPresentationModel::GetAppControlSelectionMode(void) const
1604 AppLogDebug("Enter");
1605 AppLogDebug("Exit");
1607 return __appControlSelectionMode;
1611 FileListPresentationModel::SetUpdateProgressStatus(const bool status)
1613 AppLogDebug("ENTER status = %d",status);
1614 __updateProgressStatus = status;
1615 AppLogDebug("EXIT");
1619 FileListPresentationModel::RotateImage(int index, RotateMode rotateMode)
1621 result r = E_SUCCESS;
1622 ImageBuffer rotateBuffer;
1623 ImageBuffer* pRotatedBuffer = null;
1624 ImageFormat imageFormat;
1626 String filePath = GetContentFilePath(index);
1627 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1628 if (contentType == CONTENT_TYPE_VIDEO)
1633 r = img.Construct();
1637 imageFormat = img.GetImageFormat(filePath);
1639 r = rotateBuffer.Construct(filePath);
1642 if (rotateMode == ROTATE_MODE_RIGHT)
1644 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1648 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1652 if (pRotatedBuffer != null)
1654 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1655 delete pRotatedBuffer;
1656 ContentManager::ScanFile(filePath);
1664 FileListPresentationModel::ClearImageCache(void)
1666 AppLogDebug("ENTER");
1668 if(__pIconListViewCache != null)
1670 bool clearThumbnailReq = true;
1671 while(__pIconListViewCache->GetCount() != 0)
1673 //This is to Clear the Thumbnail Reuqests only Once
1674 if(clearThumbnailReq == true)
1676 ClearThumbnailRequests();
1677 clearThumbnailReq = false;
1679 __pIconListViewCache->RemoveAt(0, true);
1682 AppLogDebug("EXIT");
1686 FileListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
1688 AppLogDebug("ENTER");
1689 if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
1691 IFormContentUpdateEventListener* pInterface = null;
1692 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1693 while (pEventEnum->MoveNext() == E_SUCCESS)
1695 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1696 pInterface->OnContentUpdated();
1700 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));