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_MEDIA_PATH = Environment::GetMediaPath();
72 static const String RESERVED_CAMERA_PATH = Environment::GetMediaPath() + L"Camera";
73 static const String RESERVED_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera";
74 static const String RESERVED_DOWNLOAD_PATH = Environment::GetMediaPath() + L"Downloads";
76 FileListPresentationModel* FileListPresentationModel::__pPresentationModelInstance = null;
77 ThumbnailProvider* FileListPresentationModel::__pThumbnailProvider = null;
78 ThumbnailEvent* FileListPresentationModel::__pThumbnailEvent = null;
79 ArrayList* FileListPresentationModel::__pPresentationModelListener = null;
80 ArrayList* FileListPresentationModel::__pContentEventListener = null;
81 ArrayList* FileListPresentationModel::__pIconListViewCache = null;
82 IList* FileListPresentationModel::__pDirectoryList = null;
83 IList* FileListPresentationModel::__pContentInfoList = null;
85 FileListPresentationModel::FileListPresentationModel(void)
86 : __pContentManager(null)
87 , __albumContentType(CONTENT_TYPE_ALL)
88 , __appControlMode(APPCONTROL_MODE_MAIN)
89 , __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
90 , __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
91 , __pContentIdList(null)
92 , __updateProgressStatus(false)
95 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
98 FileListPresentationModel::~FileListPresentationModel(void)
100 AppLogDebug("ENTER");
101 DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
102 if (__pContentIdList)
104 __pContentIdList->RemoveAll(true);
105 delete __pContentIdList;
106 __pContentIdList = null;
108 delete __pContentManager;
109 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
112 FileListPresentationModel*
113 FileListPresentationModel::GetInstance(void)
115 AppLogDebug("ENTER");
116 if (__pPresentationModelInstance == null)
120 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
122 return __pPresentationModelInstance;
126 FileListPresentationModel::Construct(void)
128 AppLogDebug("ENTER");
130 IThumbnailEventListener* pThumbnailEventListener = static_cast<IThumbnailEventListener*>(this);
131 __pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
132 __pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
134 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
136 ContentUpdateEventListener::GetInstance();
137 __pContentManager = new (std::nothrow) ContentManager();
138 __pContentManager->Construct();
140 if (__pIconListViewCache != null)
142 __pIconListViewCache->RemoveAll(true);
143 delete __pIconListViewCache;
144 __pIconListViewCache = null;
146 __pIconListViewCache = new (std::nothrow) ArrayList(SingleObjectDeleter);
147 __pIconListViewCache->Construct(SIZE_ICON_LIST_CACHE);
149 if (__pDirectoryList != null)
151 delete __pDirectoryList;
153 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
155 if (__pContentInfoList != null)
157 delete __pContentInfoList;
159 __pContentInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
161 __pPresentationModelListener = new (std::nothrow) ArrayList();
162 __pPresentationModelListener->Construct();
164 __pContentEventListener = new (std::nothrow) ArrayList();
165 __pContentEventListener->Construct();
167 __pThumbnailProvider = ThumbnailProvider::GetInstance();
169 GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
170 const IMap* pArguments = pApp->GetAppControlArguments();
171 String operationId = pApp->GetAppControlOperationId();
173 if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
175 __appControlMode = APPCONTROL_MODE_MAIN;
177 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
179 __appControlMode = APPCONTROL_MODE_PICK;
181 String mimeType = pApp->GetMimeType();
182 if (mimeType.IsEmpty() != true)
184 if (mimeType.StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
186 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
189 if (pArguments != null)
191 const String* selectionMode = static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
193 if (pApp->GetMimeType().StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
195 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
198 if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
200 __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
204 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
206 __appControlMode = APPCONTROL_MODE_SETTING;
209 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
215 FileListPresentationModel::CreateInstance(void)
217 AppLogDebug("ENTER");
218 __pPresentationModelInstance = new (std::nothrow) FileListPresentationModel();
219 result r = __pPresentationModelInstance->Construct();
220 if (IsFailed(r) == true)
222 delete __pPresentationModelInstance;
223 __pPresentationModelInstance = null;
224 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
229 std::atexit(DestroyInstance);
230 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
234 FileListPresentationModel::DestroyInstance(void)
236 AppLogDebug("ENTER");
238 delete __pThumbnailEvent;
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::RequestThumbnail(const ContentId& contentId)
565 __pThumbnailProvider->RequestThumbnail(contentId, __pThumbnailEvent);
569 FileListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
571 AppLogDebug("ENTER");
573 if (__pThumbnailProvider != null)
575 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
582 FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
584 AppLogDebug("ENTER");
586 if (&eventArg != null)
588 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
589 if (pThumbnailEventArg == null)
591 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
595 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
596 if (pThumbnailInfo == null)
598 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
603 bool isMatch = false;
604 ContentId contentId = pThumbnailInfo->GetContentId();
606 if (__pIconListViewCache != null)
608 IEnumerator* pEnum = __pIconListViewCache->GetEnumeratorN();
609 Bitmap* pBitmap = null;
610 while (pEnum->MoveNext() == E_SUCCESS)
612 ThumbnailInfo* pTempThumbnailInfo = static_cast<ThumbnailInfo*>(pEnum->GetCurrent());
614 if (contentId == pTempThumbnailInfo->GetContentId())
616 AppLogDebug("[CHASEFIRE] PM receive (%ls)", pThumbnailInfo->GetFilePath().GetPointer());
617 pBitmap = pThumbnailInfo->GetBitmapN();
618 pTempThumbnailInfo->SetBitmap(*pBitmap);
621 pTempThumbnailInfo->SetContentType(pThumbnailInfo->GetContentType());
622 pTempThumbnailInfo->SetDuration(pThumbnailInfo->GetDuration());
623 delete pThumbnailInfo;
631 if (isMatch == false)
633 if (SIZE_ICON_LIST_CACHE <= __pIconListViewCache->GetCount())
635 __pIconListViewCache->RemoveAt(0, true);
637 AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)", __pIconListViewCache->GetCount(),
638 pThumbnailInfo->GetFilePath().GetPointer());
639 __pIconListViewCache->Add(pThumbnailInfo);
644 int loopCount = __pContentInfoList->GetCount();
645 for (int i = 0; i < loopCount; ++i)
647 if (contentId == (static_cast<ContentInfo*>(__pContentInfoList->GetAt(i)))->GetContentId())
654 IAlbumEventListener* pInterface = null;
655 IEnumerator* pEventEnum = __pPresentationModelListener->GetEnumeratorN();
656 while (pEventEnum->MoveNext() == E_SUCCESS)
658 pInterface = static_cast<IAlbumEventListener*>(pEventEnum->GetCurrent());
659 pInterface->OnThumbnailDecoded(index);
663 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
667 FileListPresentationModel::OnContentCreated(void)
669 AppLogDebug("ENTER");
670 if (__updateProgressStatus == true)
672 AppLogDebug("EXIT update in application");
675 IFormContentUpdateEventListener* pInterface = null;
676 if (__pContentEventListener == null)
681 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
682 while (pEventEnum->MoveNext() == E_SUCCESS)
684 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
685 if (pInterface != null)
687 pInterface->OnContentUpdated();
695 FileListPresentationModel::OnContentUpdated(const ContentId& contentId)
697 AppLogDebug("ENTER");
698 RequestThumbnail(contentId);
703 FileListPresentationModel::OnContentUpdated(void)
705 AppLogDebug("ENTER");
706 if (__updateProgressStatus == true)
708 AppLogDebug("EXIT update in application");
711 //Clear the ImageCaches when content is updated like rotate.
712 if (__pContentEventListener->GetCount())
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::OnContentDeleted(void)
736 AppLogDebug("ENTER");
737 if (__updateProgressStatus == true)
739 AppLogDebug("EXIT update in application");
742 IFormContentUpdateEventListener* pInterface = null;
743 if (__pContentEventListener == null)
748 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
749 while (pEventEnum->MoveNext() == E_SUCCESS)
751 ClearThumbnailRequests();
752 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
753 pInterface->OnContentUpdated();
760 FileListPresentationModel::AddPresentationModelListener(const IAlbumEventListener* listener)
762 AppLogDebug("ENTER");
763 __pPresentationModelListener->Add((Object*)listener);
764 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
768 FileListPresentationModel::RemovePresentationModelListener(const IAlbumEventListener& listener)
770 AppLogDebug("ENTER");
771 __pPresentationModelListener->Remove(listener);
772 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
776 FileListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
778 AppLogDebug("ENTER");
779 if (__pContentEventListener != null)
781 __pContentEventListener->RemoveAll();
782 __pContentEventListener->Add((Object*)listener);
783 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
788 FileListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener* listener)
790 AppLogDebug("ENTER");
791 __pContentEventListener->Remove(*listener);
792 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
796 FileListPresentationModel::GetThumbnailInfoFromInternalBufferN(const ContentId& contentId) const
798 AppLogDebug("ENTER");
799 ThumbnailInfo* pThumbnailInfo = null;
800 ThumbnailInfo* pTempThumbnailInfo = null;
801 if (__pIconListViewCache != null)
803 int loopCount = __pIconListViewCache->GetCount();
804 for (int i = 0; i < loopCount; ++i)
806 pTempThumbnailInfo = static_cast<ThumbnailInfo*>(__pIconListViewCache->GetAt(i));
807 if (contentId == pTempThumbnailInfo->GetContentId())
810 pThumbnailInfo = new (std::nothrow) ThumbnailInfo();
811 Bitmap* pBitmap = pTempThumbnailInfo->GetBitmapN();
812 pThumbnailInfo->Construct(pTempThumbnailInfo->GetContentId(), pTempThumbnailInfo->GetFilePath(),
813 *pBitmap, pTempThumbnailInfo->GetContentType(), pTempThumbnailInfo->GetDuration());
819 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
821 return pThumbnailInfo;
825 FileListPresentationModel::ShowAnimation(void)
827 IFormContentUpdateEventListener* pInterface = null;
828 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
829 while (pEventEnum->MoveNext() == E_SUCCESS)
831 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
832 pInterface->ShowAnimation();
838 FileListPresentationModel::StopAnimation(void)
840 IFormContentUpdateEventListener* pInterface = null;
841 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
842 while (pEventEnum->MoveNext() == E_SUCCESS)
844 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
845 pInterface->StopAnimation();
850 FileListPresentationModel::DeleteContentFileList(const IList& contentIndexList)
852 AppLogDebug("ENTER");
853 if (&contentIndexList == null || contentIndexList.GetCount() <= 0)
855 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
860 IList * pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
861 int loopCount = contentIndexList.GetCount();
862 for (int i = 0; i < loopCount; ++i)
864 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
866 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
868 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>
869 (__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
873 loopCount = pContentIdList->GetCount();
874 for (int i = 0; i < loopCount; ++i)
876 ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(i));
877 if (pContentId != null)
879 ContentInfo* cntInfo = __pContentManager->GetContentInfoN(*pContentId);
882 String filePath = cntInfo->GetContentPath();
884 DeleteContentFile(filePath);
888 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
894 FileListPresentationModel::GetCollisionIndexListN(const IList& contentIndexList, const String& destDirectory)
896 AppLogDebug("ENTER");
897 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null
898 || destDirectory.IsEmpty() == true)
900 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
905 if (File::IsFileExist(destDirectory) == false)
907 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
912 IList * pCollisionInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
913 ContentInfo* pContentInfo = null;
914 int loopCount = contentIndexList.GetCount();
915 for (int i = 0; i < loopCount; ++i)
917 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
919 if ((pIndex != null) && (pIndex->ToInt()) >= 0 && __pContentInfoList->GetCount() > pIndex->ToInt())
921 pContentInfo = const_cast<ContentInfo*>(static_cast<const ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())));
922 String filePath = pContentInfo->GetContentPath();
923 String fileName = GetFileNameFromFullPath(filePath, true);
926 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
928 destPath.Append(destDirectory);
929 destPath.Append(fileName);
933 destPath.Append(destDirectory);
934 destPath.Append(DIRECTORY_SEPARATOR);
935 destPath.Append(fileName);
938 if (File::IsFileExist(destPath) == true)
940 pCollisionInfoList->Add(*(new (std::nothrow) String(pIndex->ToString() + MULTI_ITEM_SEPARATOR + fileName)));
944 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
946 return pCollisionInfoList;
950 FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList, const String& destDirectory)
952 AppLogDebug("ENTER");
953 result r = E_SUCCESS;
954 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null || destDirectory.IsEmpty() == true)
956 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
961 if (File::IsFileExist(destDirectory) == false)
963 Directory::Create(destDirectory, true);
966 delete __pContentIdList;
967 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
968 int loopCount = contentIndexList.GetCount();
969 for (int i = 0; i < loopCount; ++i)
971 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
973 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
975 __pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
980 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
986 FileListPresentationModel::DeleteContentFile(const String& filePath)
988 AppLogDebug("ENTER");
989 result r = E_SUCCESS;
990 r = File::Remove(filePath);
991 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
997 FileListPresentationModel::MoveToContentFile(const String& filePath, const String& destDirectory, const bool isCopyOperation)
999 AppLogDebug("ENTER");
1000 if (destDirectory.IsEmpty() == true)
1002 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1005 result r = E_SUCCESS;
1007 if (filePath.GetLength() < 4)
1009 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
1014 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
1016 destPath.Append(destDirectory);
1017 destPath.Append(GetFileNameFromFullPath(filePath, true));
1021 destPath.Append(destDirectory);
1022 destPath.Append(DIRECTORY_SEPARATOR);
1023 destPath.Append(GetFileNameFromFullPath(filePath, true));
1026 if (destPath.CompareTo(filePath) == 0)
1028 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
1032 while (File::IsFileExist(destPath) == true)
1035 r = destPath.IndexOf(FILE_EXT_SEPARATOR, 0, index);
1044 destPath.Insert(Math::Rand()%10, index);
1053 r = File::Copy(filePath, destPath, false);
1055 if (r == E_STORAGE_FULL)
1057 File::Remove(destPath);
1062 if (isCopyOperation == false)
1064 File::Remove(filePath); // if Move Op remove original file
1067 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1073 FileListPresentationModel::ClearProviderId(void)
1075 __providerId.Clear();
1079 FileListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
1080 const String* pUriData, const Tizen::Base::String* pMimeType, const HashMap* pDataList,
1081 IAppControlResponseListener* pListener)
1083 AppLogDebug("ENTER");
1084 AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
1087 __providerId.Append(providerId);
1091 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1094 result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
1098 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
1099 pGalleryApp->SetFrameEnabled(false);
1104 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1110 FileListPresentationModel::SetCurrentAlbumInfo(const String& albumName, const IList& directoryList)
1112 AppLogDebug("ENTER");
1114 if (&directoryList != null)
1116 if (__pDirectoryList != null && __pDirectoryList->GetCount() > 0)
1118 bool isMatched = false;
1119 int outterLoopCount = __pDirectoryList->GetCount();
1120 int innerLoopCount = 0;
1121 for (int i = 0; i < outterLoopCount; ++i)
1124 innerLoopCount = directoryList.GetCount();
1125 for (int j = 0; j < innerLoopCount; ++j)
1127 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(
1128 *(const_cast<String*>(static_cast<const String*>(directoryList.GetAt(j))))) == 0)
1136 outterLoopCount = directoryList.GetCount();
1137 for (int i = 0; i < outterLoopCount; ++i)
1140 innerLoopCount = __pDirectoryList->GetCount();
1141 for (int j = 0; j < innerLoopCount; ++j)
1143 if (const_cast<String*>(static_cast<const String*>(directoryList.GetAt(i)))->CompareTo(
1144 *(static_cast<String*>(__pDirectoryList->GetAt(j)))) == 0)
1154 __albumName = albumName;
1155 __providerId.Clear();
1157 if (__pDirectoryList != null)
1159 delete __pDirectoryList;
1161 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1163 int loopCount = directoryList.GetCount();
1164 for (int i = 0; i < loopCount; ++i)
1166 __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>
1167 (static_cast<const String*>(directoryList.GetAt(i))))));
1170 if (__pContentInfoList != null)
1172 delete __pContentInfoList;
1173 __pContentInfoList = null;
1176 if (GetAppControlMode() == APPCONTROL_MODE_PICK)
1178 AppControlMediaType appControlMediaType = GetAppControlMediaType();
1179 if (appControlMediaType == APPCONTROL_MEDIA_TYPE_IMAGE)
1181 __albumContentType = CONTENT_TYPE_IMAGE;
1183 else if (appControlMediaType == APPCONTROL_MEDIA_TYPE_VIDEO)
1185 __albumContentType = CONTENT_TYPE_VIDEO;
1188 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1189 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1195 FileListPresentationModel::RefreshCurrentAlbumContentInfoList(const ContentType contentType)
1197 AppLogDebug("ENTER");
1198 result r = RefreshContentInfoList(contentType);
1199 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1205 FileListPresentationModel::AddDirectoryIfNew(const String& dirName)
1208 bool isMatched = false;
1209 int dirCount = __pDirectoryList->GetCount();
1211 fullDirName = Environment::GetMediaPath();
1212 fullDirName.Append(dirName);
1214 if (__albumName != ALL_ALBUMS_REAL_NAME) //we are not in All albums
1219 for (int i = 0; i < dirCount; ++i)
1221 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(fullDirName) == 0)
1230 __pDirectoryList->Add(new (std::nothrow) String(fullDirName));
1235 FileListPresentationModel::RefreshContentInfoList(const ContentType contentType)
1237 AppLogDebug("ENTER");
1238 if ((contentType != CONTENT_TYPE_ALL) && (contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO))
1240 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1245 if ((__pDirectoryList == null) || (__pDirectoryList->GetCount() <= 0))
1247 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1252 __albumContentType = contentType;
1254 if (__pContentInfoList != null)
1256 delete __pContentInfoList;
1257 __pContentInfoList = null;
1260 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1261 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1267 FileListPresentationModel::GetCurrentAlbumName(void) const
1269 AppLogDebug("ENTER");
1270 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1276 FileListPresentationModel::SetCurrentAlbumName(const String& albumName)
1278 AppLogDebug("ENTER");
1279 if (&albumName == null)
1281 __albumName = EMPTY_SPACE;
1285 __albumName = albumName;
1287 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1291 FileListPresentationModel::GetCurrentAlbumContentType(void) const
1293 AppLogDebug("ENTER");
1294 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1296 return __albumContentType;
1300 FileListPresentationModel::SetCurrentAlbumContentType(const ContentType contentType)
1302 AppLogDebug("ENTER");
1303 __albumContentType = contentType;
1304 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1308 FileListPresentationModel::GetAlbumDirectoryListN(void) const
1310 AppLogDebug("ENTER");
1311 IList* pAlbumDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1312 if (__pDirectoryList == null)
1314 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1316 return pAlbumDirectoryList;
1319 String* pDirectory = null;
1320 int loopCount = __pDirectoryList->GetCount();
1321 for (int i = 0; i < loopCount; ++i)
1323 pDirectory = static_cast<String*>(__pDirectoryList->GetAt(i));
1324 pAlbumDirectoryList->Add(new (std::nothrow) String(*pDirectory));
1326 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1328 return pAlbumDirectoryList;
1332 FileListPresentationModel::GetAlbumContentInfoList(void) const
1334 AppLogDebug("ENTER");
1335 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1336 if (__pContentInfoList == null)
1338 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1340 return pContentList;
1343 ContentInfo* pContentInfo = null;
1344 int loopCount = __pContentInfoList->GetCount();
1345 for (int i = 0; i < loopCount; ++i)
1347 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(i));
1348 pContentList->Add(pContentInfo);
1350 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1352 return pContentList;
1356 FileListPresentationModel::GetContentInfo(const int index) const
1358 AppLogDebug("ENTER");
1359 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1361 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1366 if (index < 0 || index >= __pContentInfoList->GetCount())
1368 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1372 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1373 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1375 return pContentInfo;
1378 IList* FileListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
1380 AppLogDebug("ENTER");
1381 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1382 int loopCount = indexList.GetCount();
1383 for (int i = 0; i < loopCount; ++i)
1385 const Integer* pIndex = static_cast<const Integer*>(indexList.GetAt(i));
1387 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
1389 ContentInfo* pContentInfo = const_cast<ContentInfo*>(static_cast<const ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())));
1390 pContentIdList->Add(new (std::nothrow) ContentId(pContentInfo->GetContentId()));
1393 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1394 return pContentIdList;
1398 FileListPresentationModel::GetCurrentAlbumContentInfoCount(void) const
1400 AppLogDebug("ENTER");
1401 if (__pContentInfoList == null)
1403 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1407 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1409 return __pContentInfoList->GetCount();
1413 FileListPresentationModel::GetContentInfoIndex(const int index) const
1415 AppLogDebug("ENTER");
1416 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1418 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1423 if (index < 0 || index >= __pContentInfoList->GetCount())
1425 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1429 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1430 ContentId contentId = pContentInfo->GetContentId();
1431 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1437 FileListPresentationModel::GetContentFilePath(const int index) const
1439 AppLogDebug("ENTER index(%d)", index);
1440 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1442 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1447 if (index < 0 || index >= __pContentInfoList->GetCount())
1449 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1454 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1455 String contentPath = pContentInfo->GetContentPath();
1456 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1462 FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnail,
1463 const ThumbnailInfo& thumbmailInfo)
1465 AppLogDebug("ENTER");
1466 Bitmap* pOverlayedImage = null;
1468 if (&thumbmailInfo != null)
1470 long duration = thumbmailInfo.GetDuration();
1473 if (&thumbnail != null)
1475 BufferInfo bufferInfo;
1476 thumbnail.Lock(bufferInfo, INFINITE);
1478 mainCanvas.Construct(bufferInfo);
1482 Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
1483 mainCanvas.Construct(mainRect);
1484 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), mainRect);
1487 Rectangle playRect(GAP_W_PLAY_FG, GAP_H_PLAY_FG, W_PLAY_FG, H_PLAY_FG);
1488 Bitmap* playBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_PLAY);
1489 if (playBitmap != null)
1491 mainCanvas.DrawBitmap(playRect, *playBitmap);
1496 Rectangle durSize(0, 0, W_DURATION, H_DURATION);
1497 Rectangle durRect(0, GAP_H_DURATION, W_DURATION, H_DURATION);
1498 Color durColor(COLOR_DURATION_BG);
1499 durColor.SetAlpha(ALPHA_DURATION);
1500 durCanvas.Construct(durSize);
1501 durCanvas.FillRectangle(durColor, durSize);
1503 durFont.Construct(FONT_STYLE_PLAIN, FONT_SIZE_DURATION);
1504 durCanvas.SetFont(durFont);
1505 durCanvas.DrawText(Point(W_DURATION_TEXT, H_DURATION_TEXT),
1506 CommonUtil::DurationToTimeString(duration), COLOR_TEXT_OUTLINE);
1508 durBitmap.Construct(durCanvas, durCanvas.GetBounds());
1509 mainCanvas.DrawBitmap(durRect, durBitmap);
1511 pOverlayedImage = new (std::nothrow) Bitmap();
1512 pOverlayedImage->Construct(mainCanvas, mainCanvas.GetBounds());
1514 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1516 return pOverlayedImage;
1520 FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
1521 const Bitmap& originalBitmap, const Rectangle& originalBitmapPosition) const
1523 AppLogDebug("ENTER");
1524 if (&originalBitmap == null || &originalBitmap == null)
1526 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1531 BufferInfo bufferInfo;
1532 bgBitmap.Lock(bufferInfo, INFINITE);
1535 mainCanvas.Construct(bufferInfo);
1537 mainCanvas.DrawBitmap(originalBitmapPosition, originalBitmap);
1539 Bitmap* pMainImage = new (std::nothrow) Bitmap();
1540 pMainImage->Construct(mainCanvas,mainCanvas.GetBounds());
1541 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1547 FileListPresentationModel::GetContentInfoListInDirectoryListN(const IList& contentDirectoryList,
1548 ContentType contentType)const
1550 AppLogDebug("ENTER");
1551 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1553 if ((&contentDirectoryList == null) || (contentDirectoryList.GetCount() == 0)
1554 || ((contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO) && (contentType != CONTENT_TYPE_ALL)))
1556 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1557 return pContentList;
1560 ContentDirectory contentDirectory;
1561 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1562 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
1564 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1566 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
1568 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1570 result r = contentDirectory.Construct(*pContentTypeList);
1571 delete pContentTypeList;
1575 int pageNo = SIZE_PAGE_NO;
1576 int countPerPage = SIZE_CONUNT_PER_PAGE;
1577 String* pContentDirectory = null;
1579 int loopCount = contentDirectoryList.GetCount();
1580 for (int i = 0; i < loopCount; ++i)
1582 IList* pIList = null;
1583 pContentDirectory = const_cast<String*>(static_cast<const String*>(contentDirectoryList.GetAt(i)));
1584 if (pContentDirectory != null)
1586 pIList = contentDirectory.GetContentDirectoryItemListN(*pContentDirectory, pageNo, countPerPage,
1587 CONTENT_INFO_ORDER, SORT_ORDER_NONE);
1591 pContentList->AddItems(*pIList);
1596 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1598 return pContentList;
1602 FileListPresentationModel::ConvertToAlbumName(const String& targetPath)const
1604 AppLogDebug("ENTER");
1606 if (&targetPath == null || targetPath.GetLength() == 0)
1611 String mediaPath = RESERVED_MEDIA_PATH;
1612 int length = mediaPath.GetLength();
1613 mediaPath.Remove(length-1,1);
1616 if (targetPath == RESERVED_CAMERA_PATH || targetPath == RESERVED_CAMERA_PATH_EXT)
1618 albumName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
1620 else if (targetPath == RESERVED_DOWNLOAD_PATH)
1622 albumName = ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS");
1624 else if (targetPath == mediaPath)
1627 albumName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
1631 String directoryName = GetDirecotyNameFromFullPath(targetPath);
1632 albumName = directoryName;
1639 FileListPresentationModel::GetAppControlMode(void) const
1641 AppLogDebug("Enter");
1642 AppLogDebug("Exit");
1644 return __appControlMode;
1648 FileListPresentationModel::GetAppControlMediaType(void) const
1650 AppLogDebug("Enter");
1651 AppLogDebug("Exit");
1653 return __appControlMediaType;
1656 AppControlSelectionMode
1657 FileListPresentationModel::GetAppControlSelectionMode(void) const
1659 AppLogDebug("Enter");
1660 AppLogDebug("Exit");
1662 return __appControlSelectionMode;
1666 FileListPresentationModel::SetUpdateProgressStatus(const bool status)
1668 AppLogDebug("ENTER status = %d",status);
1669 __updateProgressStatus = status;
1670 AppLogDebug("EXIT");
1674 FileListPresentationModel::RotateImage(const Tizen::Content::ContentId& contentId, RotateMode rotateMode)
1676 result r = E_SUCCESS;
1677 ImageBuffer rotateBuffer;
1678 ImageBuffer* pRotatedBuffer = null;
1679 ImageFormat imageFormat;
1681 ContentInfo* cntInfo = __pContentManager->GetContentInfoN(contentId);
1686 String filePath = cntInfo->GetContentPath();
1689 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1690 if (contentType == CONTENT_TYPE_VIDEO)
1695 r = img.Construct();
1699 imageFormat = img.GetImageFormat(filePath);
1701 r = rotateBuffer.Construct(filePath);
1704 if (rotateMode == ROTATE_MODE_RIGHT)
1706 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1710 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1714 if (pRotatedBuffer != null)
1716 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1717 delete pRotatedBuffer;
1718 ContentManager::ScanFile(filePath);
1726 FileListPresentationModel::ClearImageCache(void)
1728 AppLogDebug("ENTER");
1730 if(__pIconListViewCache != null)
1732 bool clearThumbnailReq = true;
1733 while(__pIconListViewCache->GetCount() != 0)
1735 //This is to Clear the Thumbnail Reuqests only Once
1736 if(clearThumbnailReq == true)
1738 ClearThumbnailRequests();
1739 clearThumbnailReq = false;
1741 __pIconListViewCache->RemoveAt(0, true);
1744 AppLogDebug("EXIT");
1748 FileListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
1750 AppLogDebug("ENTER");
1751 if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
1753 IFormContentUpdateEventListener* pInterface = null;
1754 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1755 while (pEventEnum->MoveNext() == E_SUCCESS)
1757 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1758 pInterface->OnContentUpdated();
1762 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));