2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file GlFileListPresentationModel.cpp
19 * @brief This is the implementation file for FileListPresentationModel class.
25 #include "GlCommonUtil.h"
26 #include "GlFileListPresentationModel.h"
27 #include "GlContentUpdateEventListener.h"
28 #include "GlGalleryApp.h"
29 #include "GlThumbnailEvent.h"
30 #include "GlThumbnailEventArg.h"
31 #include "GlThumbnailProvider.h"
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Base::Utility;
39 using namespace Tizen::Content;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Io;
42 using namespace Tizen::Media;
43 using namespace Tizen::System;
45 static const String CONTENT_INFO_ORDER = L"ContentFileName";
47 static const int SIZE_PAGE_NO = 1;
48 static const int SIZE_CONUNT_PER_PAGE = 3000;
49 static const int SIZE_ICON_LIST_CACHE = 50;
50 static const int W_DURATION_TEXT = 44;
51 static const int H_DURATION_TEXT = 4;
52 static const int W_DURATION = 171;
53 static const int H_DURATION = 32;
54 static const int W_DEFAULT_THUMBNAIL = 171;
55 static const int H_DEFAULT_THUMBNAIL = 127;
56 static const int W_WIDE_THUMBNAIL = 171;
57 static const int H_WIDE_THUMBNAIL = 127;
58 static const int W_PLAY_FG = 64;
59 static const int H_PLAY_FG = 64;
60 static const int GAP_W_PLAY_FG = (W_DEFAULT_THUMBNAIL -W_PLAY_FG)/2 ;
61 static const int GAP_H_PLAY_FG = (H_DEFAULT_THUMBNAIL - H_PLAY_FG)/2;
62 static const int GAP_H_DURATION = H_DEFAULT_THUMBNAIL - H_DURATION;
63 static const int ALPHA_DURATION = 70;
64 static const int FONT_SIZE_DURATION = 24;
65 static const Dimension DIMENSION_REAL_ICON (171,127);
66 static const Rectangle RECTANGLE_THUMBNAIL_OFFSET_POSION (1, 1, 171, 127);
67 static const Rectangle RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION (1, 1, 171, 127);
68 static const Color COLOR_DURATION_BG (Color::GetColor(COLOR_ID_BLACK));
69 static const Color COLOR_TEXT_OUTLINE (Color::GetColor(COLOR_ID_WHITE));
71 static const String RESERVED_CAMERA_PATH = Environment::GetMediaPath() + L"Camera";
72 static const String RESERVED_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera";
73 static const String RESERVED_DOWNLOAD_PATH = Environment::GetMediaPath() + L"Downloads";
75 FileListPresentationModel* FileListPresentationModel::__pPresentationModelInstance = null;
76 ThumbnailProvider* FileListPresentationModel::__pThumbnailProvider = null;
77 ThumbnailEvent* FileListPresentationModel::__pThumbnailEvent = null;
78 ArrayList* FileListPresentationModel::__pPresentationModelListener = null;
79 ArrayList* FileListPresentationModel::__pContentEventListener = null;
80 ArrayList* FileListPresentationModel::__pIconListViewCache = null;
81 IList* FileListPresentationModel::__pDirectoryList = null;
82 IList* FileListPresentationModel::__pContentInfoList = null;
84 FileListPresentationModel::FileListPresentationModel(void)
85 : __pContentManager(null)
86 , __albumContentType(CONTENT_TYPE_ALL)
87 , __appControlMode(APPCONTROL_MODE_MAIN)
88 , __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
89 , __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
90 , __pContentIdList(null)
91 , __updateProgressStatus(false)
94 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
97 FileListPresentationModel::~FileListPresentationModel(void)
100 DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
101 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
104 FileListPresentationModel*
105 FileListPresentationModel::GetInstance(void)
107 AppLogDebug("ENTER");
108 if (__pPresentationModelInstance == null)
112 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
114 return __pPresentationModelInstance;
118 FileListPresentationModel::Construct(void)
120 AppLogDebug("ENTER");
122 IThumbnailEventListener* pThumbnailEventListener = static_cast<IThumbnailEventListener*>(this);
123 __pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
124 __pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
126 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
128 ContentUpdateEventListener::GetInstance();
129 __pContentManager = new (std::nothrow) ContentManager();
130 __pContentManager->Construct();
132 if (__pIconListViewCache != null)
134 __pIconListViewCache->RemoveAll(true);
135 delete __pIconListViewCache;
136 __pIconListViewCache = null;
138 __pIconListViewCache = new (std::nothrow) ArrayList(SingleObjectDeleter);
139 __pIconListViewCache->Construct(SIZE_ICON_LIST_CACHE);
141 if (__pDirectoryList != null)
143 delete __pDirectoryList;
145 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
147 if (__pContentInfoList != null)
149 delete __pContentInfoList;
151 __pContentInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
153 __pPresentationModelListener = new (std::nothrow) ArrayList();
154 __pPresentationModelListener->Construct();
156 __pContentEventListener = new (std::nothrow) ArrayList();
157 __pContentEventListener->Construct();
159 __pThumbnailProvider = ThumbnailProvider::GetInstance();
161 GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
162 const IMap* pArguments = pApp->GetAppControlArguments();
163 String operationId = pApp->GetAppControlOperationId();
165 if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
167 __appControlMode = APPCONTROL_MODE_MAIN;
169 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
171 __appControlMode = APPCONTROL_MODE_PICK;
173 String mimeType = pApp->GetMimeType();
174 if (mimeType.IsEmpty() != true)
176 if (mimeType.StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
178 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
181 if (pArguments != null)
183 const String* selectionMode = static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
185 if (pApp->GetMimeType().StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
187 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
190 if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
192 __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
196 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
198 __appControlMode = APPCONTROL_MODE_SETTING;
201 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
207 FileListPresentationModel::CreateInstance(void)
209 AppLogDebug("ENTER");
210 __pPresentationModelInstance = new (std::nothrow) FileListPresentationModel();
211 result r = __pPresentationModelInstance->Construct();
212 if (IsFailed(r) == true)
214 delete __pPresentationModelInstance;
215 __pPresentationModelInstance = null;
216 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
221 std::atexit(DestroyInstance);
222 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
226 FileListPresentationModel::DestroyInstance(void)
228 AppLogDebug("ENTER");
230 delete __pThumbnailEvent;
231 __pIconListViewCache = null;
233 if (__pIconListViewCache != null)
235 __pIconListViewCache->RemoveAll(true);
236 delete __pIconListViewCache;
237 __pIconListViewCache = null;
240 if (__pDirectoryList != null)
242 delete __pDirectoryList;
243 __pDirectoryList = null;
246 if (__pContentInfoList != null)
248 delete __pContentInfoList;
249 __pContentInfoList = null;
252 if (__pPresentationModelListener != null)
254 delete __pPresentationModelListener;
255 __pPresentationModelListener = null;
258 if (__pContentEventListener != null)
260 delete __pContentEventListener;
261 __pContentEventListener = null;
264 delete __pPresentationModelInstance;
265 __pPresentationModelInstance = null;
267 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
271 FileListPresentationModel::GetFileNameFromFullPath(const String& fullPath, const bool withExt) const
273 AppLogDebug("ENTER");
274 if (fullPath.CompareTo(EMPTY_SPACE) == 0)
276 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
281 String delim(DIRECTORY_SEPARATOR);
282 StringTokenizer st(fullPath,delim);
284 while (st.HasMoreTokens())
286 st.GetNextToken(token);
291 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
297 String subDelim(FILE_EXT_SEPARATOR);
298 StringTokenizer subSt(token, subDelim);
300 subSt.GetNextToken(subToken);
301 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
308 FileListPresentationModel::GetDirecotyNameFromFullPath(const String& fullPath)const
310 AppLogDebug("ENTER");
311 if (fullPath == null)
313 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
317 String delim(DIRECTORY_SEPARATOR);
318 StringTokenizer st(fullPath,delim);
320 while (st.HasMoreTokens())
322 st.GetNextToken(token);
324 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
330 FileListPresentationModel::IsContainContentInDirectory(const String& directoryPath, ContentType contentType) const
332 AppLogDebug("ENTER");
333 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
334 if (&directoryPath == null || pContentTypeList == null)
336 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
341 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
343 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
345 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
347 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
350 ContentDirectory contentDirectory;
351 result r = contentDirectory.Construct(*pContentTypeList);
352 if (pContentTypeList != null)
354 delete pContentTypeList;
356 TryReturn(r == E_SUCCESS, false, "[%s] Unable to construct ContentDirectory", GetErrorMessage(r));
358 bool returnValue = false;
359 int pageNo = SIZE_PAGE_NO;
360 int countPerPage = SIZE_CONUNT_PER_PAGE;
362 IList* pContentList = contentDirectory.GetContentDirectoryItemListN(directoryPath, pageNo, countPerPage,
363 CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
365 if (pContentList == null || pContentList->GetCount() <= 0)
374 if (pContentList != null)
378 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
384 FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pName, Bitmap*& pThumbnail)
386 AppLogDebug("ENTER : index(%d)", index);
387 Bitmap* pOriginalBitmap = null;
388 Bitmap* pDestinationBitmap = null;
389 ContentInfo* pContentInfo = null;
391 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
393 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
394 if (pContentInfo == null)
396 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
403 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
407 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
408 if (pThumbnailInfo != null)
410 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
411 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
414 if ((pThumbnailInfo != null)&&(pThumbnailInfo->GetContentType() == CONTENT_TYPE_VIDEO))
416 if (pOriginalBitmap != null)
418 pDestinationBitmap = CoverVideoOverlayedImageOnThumbnailN(*pOriginalBitmap, *pThumbnailInfo);
419 delete pOriginalBitmap;
424 pDestinationBitmap = pOriginalBitmap;
427 if (pDestinationBitmap != null)
429 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
430 Rectangle thumbnailRect(RECTANGLE_THUMBNAIL_OFFSET_POSION);
431 pDestinationBitmap->Scale(Dimension(RECTANGLE_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_THUMBNAIL_OFFSET_POSION.x
432 , RECTANGLE_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_THUMBNAIL_OFFSET_POSION.y));
433 if (pThumbnailBgBitmap != null)
435 pThumbnailBgBitmap->Scale(DIMENSION_REAL_ICON);
436 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pDestinationBitmap, thumbnailRect);
437 delete pThumbnailBgBitmap;
438 delete pDestinationBitmap;
442 pThumbnail = pDestinationBitmap;
450 if (pThumbnailInfo != null)
452 delete pThumbnailInfo;
454 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
460 FileListPresentationModel::GetThumbnailVideoInSyncCacheN(const int index,
461 String*& pName, Bitmap*& pThumbnail, String*& pDuration) const
463 AppLogDebug("ENTER : index(%d)", index);
464 ContentInfo* pContentInfo = null;
465 Bitmap* pOriginalBitmap = null;
467 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
469 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
470 if (pContentInfo == null)
472 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
478 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
482 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
483 if (pThumbnailInfo != null)
485 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
486 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
487 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(pThumbnailInfo->GetDuration()));
491 pName = new (std::nothrow) String(EMPTY_SPACE);
492 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(0));
495 if (pOriginalBitmap != null)
497 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
498 Rectangle thumbnailRect(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION);
499 pOriginalBitmap->Scale(Dimension(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.x
500 , RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.y));
501 if (pThumbnailBgBitmap != null)
503 pThumbnailBgBitmap->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
504 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pOriginalBitmap, thumbnailRect);
505 delete pThumbnailBgBitmap;
507 delete pOriginalBitmap;
514 if (pThumbnail != null)
516 pThumbnail->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
519 if (pThumbnailInfo != null)
521 delete pThumbnailInfo;
523 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
529 FileListPresentationModel::RequestThumbnail(const int index)
531 AppLogDebug("ENTER : index(%d)", index);
532 ContentInfo* pContentInfo = null;
534 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
536 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
537 if (pContentInfo == null)
539 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
545 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
550 __pThumbnailProvider->RequestThumbnail(pContentInfo->GetContentId(), __pThumbnailEvent);
555 FileListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
557 AppLogDebug("ENTER");
559 if (__pThumbnailProvider != null)
561 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
568 FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
570 AppLogDebug("ENTER");
572 if (&eventArg != null)
574 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
575 if (pThumbnailEventArg == null)
577 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
581 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
582 if (pThumbnailInfo == null)
584 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
589 bool isMatch = false;
590 ContentId contentId = pThumbnailInfo->GetContentId();
592 if (__pIconListViewCache != null)
594 IEnumerator* pEnum = __pIconListViewCache->GetEnumeratorN();
595 Bitmap* pBitmap = null;
596 while (pEnum->MoveNext() == E_SUCCESS)
598 ThumbnailInfo* pTempThumbnailInfo = static_cast<ThumbnailInfo*>(pEnum->GetCurrent());
600 if (contentId == pTempThumbnailInfo->GetContentId())
602 AppLogDebug("[CHASEFIRE] PM receive (%ls)", pThumbnailInfo->GetFilePath().GetPointer());
603 pBitmap = pThumbnailInfo->GetBitmapN();
604 pTempThumbnailInfo->SetBitmap(*pBitmap);
607 pTempThumbnailInfo->SetContentType(pThumbnailInfo->GetContentType());
608 pTempThumbnailInfo->SetDuration(pThumbnailInfo->GetDuration());
609 delete pThumbnailInfo;
617 if (isMatch == false)
619 if (SIZE_ICON_LIST_CACHE <= __pIconListViewCache->GetCount())
621 __pIconListViewCache->RemoveAt(0, true);
623 AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)", __pIconListViewCache->GetCount(),
624 pThumbnailInfo->GetFilePath().GetPointer());
625 __pIconListViewCache->Add(pThumbnailInfo);
630 int loopCount = __pContentInfoList->GetCount();
631 for (int i = 0; i < loopCount; ++i)
633 if (contentId == (static_cast<ContentInfo*>(__pContentInfoList->GetAt(i)))->GetContentId())
640 IAlbumEventListener* pInterface = null;
641 IEnumerator* pEventEnum = __pPresentationModelListener->GetEnumeratorN();
642 while (pEventEnum->MoveNext() == E_SUCCESS)
644 pInterface = static_cast<IAlbumEventListener*>(pEventEnum->GetCurrent());
645 pInterface->OnThumbnailDecoded(index);
649 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
653 FileListPresentationModel::OnContentCreated(void)
655 AppLogDebug("ENTER");
656 if (__updateProgressStatus == true)
658 AppLogDebug("EXIT update in application");
661 IFormContentUpdateEventListener* pInterface = null;
662 if (__pContentEventListener == null)
667 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
668 while (pEventEnum->MoveNext() == E_SUCCESS)
670 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
671 if (pInterface != null)
673 pInterface->OnContentUpdated();
681 FileListPresentationModel::OnContentUpdated(void)
683 AppLogDebug("ENTER");
684 if (__updateProgressStatus == true)
686 AppLogDebug("EXIT update in application");
689 //Clear the ImageCaches when content is updated like rotate.
692 IFormContentUpdateEventListener* pInterface = null;
693 if (__pContentEventListener == null)
698 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
699 while (pEventEnum->MoveNext() == E_SUCCESS)
701 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
702 pInterface->OnContentUpdated();
709 FileListPresentationModel::OnContentDeleted(void)
711 AppLogDebug("ENTER");
712 if (__updateProgressStatus == true)
714 AppLogDebug("EXIT update in application");
717 IFormContentUpdateEventListener* pInterface = null;
718 if (__pContentEventListener == null)
723 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
724 while (pEventEnum->MoveNext() == E_SUCCESS)
726 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
727 pInterface->OnContentUpdated();
734 FileListPresentationModel::AddPresentationModelListener(const IAlbumEventListener* listener)
736 AppLogDebug("ENTER");
737 __pPresentationModelListener->Add((Object*)listener);
738 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
742 FileListPresentationModel::RemovePresentationModelListener(const IAlbumEventListener& listener)
744 AppLogDebug("ENTER");
745 __pPresentationModelListener->Remove(listener);
746 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
750 FileListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
752 AppLogDebug("ENTER");
753 if (__pContentEventListener != null)
755 __pContentEventListener->RemoveAll();
756 __pContentEventListener->Add((Object*)listener);
757 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
762 FileListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener* listener)
764 AppLogDebug("ENTER");
765 __pContentEventListener->Remove(*listener);
766 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
770 FileListPresentationModel::GetThumbnailInfoFromInternalBufferN(const ContentId& contentId) const
772 AppLogDebug("ENTER");
773 ThumbnailInfo* pThumbnailInfo = null;
774 ThumbnailInfo* pTempThumbnailInfo = null;
775 if (__pIconListViewCache != null)
777 int loopCount = __pIconListViewCache->GetCount();
778 for (int i = 0; i < loopCount; ++i)
780 pTempThumbnailInfo = static_cast<ThumbnailInfo*>(__pIconListViewCache->GetAt(i));
781 if (contentId == pTempThumbnailInfo->GetContentId())
784 pThumbnailInfo = new (std::nothrow) ThumbnailInfo();
785 Bitmap* pBitmap = pTempThumbnailInfo->GetBitmapN();
786 pThumbnailInfo->Construct(pTempThumbnailInfo->GetContentId(), pTempThumbnailInfo->GetFilePath(),
787 *pBitmap, pTempThumbnailInfo->GetContentType(), pTempThumbnailInfo->GetDuration());
793 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
795 return pThumbnailInfo;
799 FileListPresentationModel::DeleteContentFileList(const IList& contentIndexList)
801 AppLogDebug("ENTER");
802 if (&contentIndexList == null || contentIndexList.GetCount() <= 0)
804 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
809 IList * pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
810 int loopCount = contentIndexList.GetCount();
811 for (int i = 0; i < loopCount; ++i)
813 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
815 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
817 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>
818 (__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
822 loopCount = pContentIdList->GetCount();
823 for (int i = 0; i < loopCount; ++i)
825 ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(i));
826 if (pContentId != null)
828 DeleteContentFile(*pContentId);
831 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
837 FileListPresentationModel::GetCollisionIndexListN(const IList& contentIndexList, const String& destDirectory)
839 AppLogDebug("ENTER");
840 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null
841 || destDirectory.IsEmpty() == true)
843 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
848 if (File::IsFileExist(destDirectory) == false)
850 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
855 IList * pCollisionInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
856 ContentInfo* pContentInfo = null;
857 int loopCount = contentIndexList.GetCount();
858 for (int i = 0; i < loopCount; ++i)
860 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
862 if ((pIndex != null) && (pIndex->ToInt()) >= 0 && __pContentInfoList->GetCount() > pIndex->ToInt())
864 pContentInfo = const_cast<ContentInfo*>(static_cast<const ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())));
865 String filePath = pContentInfo->GetContentPath();
866 String fileName = GetFileNameFromFullPath(filePath, true);
869 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
871 destPath.Append(destDirectory);
872 destPath.Append(fileName);
876 destPath.Append(destDirectory);
877 destPath.Append(DIRECTORY_SEPARATOR);
878 destPath.Append(fileName);
881 if (File::IsFileExist(destPath) == true)
883 pCollisionInfoList->Add(*(new (std::nothrow) String(pIndex->ToString() + MULTI_ITEM_SEPARATOR + fileName)));
887 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
889 return pCollisionInfoList;
893 FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList, const String& destDirectory)
895 AppLogDebug("ENTER");
896 result r = E_SUCCESS;
897 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null || destDirectory.IsEmpty() == true)
899 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
904 if (File::IsFileExist(destDirectory) == false)
906 Directory::Create(destDirectory, true);
909 delete __pContentIdList;
910 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
911 int loopCount = contentIndexList.GetCount();
912 for (int i = 0; i < loopCount; ++i)
914 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
916 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
918 __pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
923 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
929 FileListPresentationModel::DeleteContentFile(const ContentId& contentId)
931 AppLogDebug("ENTER");
932 if (&contentId == null)
934 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
938 result r = __pContentManager->DeleteContent(contentId);
940 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
946 FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const String& destDirectory, const bool isCopyOperation)
948 AppLogDebug("ENTER");
949 if (contentId.ToString().IsEmpty() == true || destDirectory.IsEmpty() == true)
951 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
954 result r = E_SUCCESS;
955 ContentInfo* pContentInfo = __pContentManager->GetContentInfoN(contentId);
956 if (pContentInfo == null)
958 AppLogDebug("Santhosh %s", destDirectory.GetPointer());
959 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
963 String filePath = pContentInfo->GetContentPath();
964 if (filePath.GetLength() < 4)
966 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
971 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
973 destPath.Append(destDirectory);
974 destPath.Append(GetFileNameFromFullPath(filePath, true));
978 destPath.Append(destDirectory);
979 destPath.Append(DIRECTORY_SEPARATOR);
980 destPath.Append(GetFileNameFromFullPath(filePath, true));
983 if (destPath.CompareTo(filePath) == 0)
985 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
989 if (File::IsFileExist(destPath) == true)
991 File::Remove(destPath);
994 r = File::Copy(filePath, destPath, false);
996 if ( r == E_STORAGE_FULL)
998 File::Remove(destPath);
1000 ContentManager::ScanFile(destPath);
1002 if ( r == E_SUCCESS )
1004 if ( isCopyOperation == false)
1006 File::Remove(filePath); // if Move Op remove original file
1007 ContentManager::ScanFile(filePath);
1011 delete pContentInfo;
1013 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1019 FileListPresentationModel::ClearProviderId(void)
1021 __providerId.Clear();
1025 FileListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
1026 const String* pUriData, const Tizen::Base::String* pMimeType, const HashMap* pDataList,
1027 IAppControlResponseListener* pListener)
1029 AppLogDebug("ENTER");
1030 AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
1033 __providerId.Append(providerId);
1037 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1040 result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
1044 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
1045 pGalleryApp->SetFrameEnabled(false);
1050 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1056 FileListPresentationModel::SetCurrentAlbumInfo(const String& albumName, const IList& directoryList)
1058 AppLogDebug("ENTER");
1060 if (&directoryList != null)
1062 if (__pDirectoryList != null && __pDirectoryList->GetCount() > 0)
1064 bool isMatched = false;
1065 int outterLoopCount = __pDirectoryList->GetCount();
1066 int innerLoopCount = 0;
1067 for (int i = 0; i < outterLoopCount ; ++i)
1070 innerLoopCount = directoryList.GetCount();
1071 for (int j = 0; j < innerLoopCount; ++j)
1073 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(
1074 *(const_cast<String*>(static_cast<const String*>(directoryList.GetAt(j))))) == 0)
1082 outterLoopCount = directoryList.GetCount();
1083 for (int i = 0; i < outterLoopCount; ++i)
1086 innerLoopCount = __pDirectoryList->GetCount();
1087 for (int j = 0; j < innerLoopCount; ++j)
1089 if (const_cast<String*>(static_cast<const String*>(directoryList.GetAt(i)))->CompareTo(
1090 *(static_cast<String*>(__pDirectoryList->GetAt(j)))) == 0)
1100 __albumName = albumName;
1101 __providerId.Clear();
1103 if (__pDirectoryList != null)
1105 delete __pDirectoryList;
1107 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1109 int loopCount = directoryList.GetCount();
1110 for (int i = 0; i < loopCount; ++i)
1112 __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>
1113 (static_cast<const String*>(directoryList.GetAt(i))))));
1116 if (__pContentInfoList != null)
1118 delete __pContentInfoList;
1119 __pContentInfoList = null;
1122 if (GetAppControlMode() == APPCONTROL_MODE_PICK)
1124 AppControlMediaType appControlMediaType = GetAppControlMediaType();
1125 if (appControlMediaType == APPCONTROL_MEDIA_TYPE_IMAGE)
1127 __albumContentType = CONTENT_TYPE_IMAGE;
1129 else if (appControlMediaType == APPCONTROL_MEDIA_TYPE_VIDEO)
1131 __albumContentType = CONTENT_TYPE_VIDEO;
1134 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1135 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1141 FileListPresentationModel::RefreshCurrentAlbumContentInfoList(const ContentType contentType)
1143 AppLogDebug("ENTER");
1144 result r = RefreshContentInfoList(contentType);
1145 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1151 FileListPresentationModel::RefreshContentInfoList(const ContentType contentType)
1153 AppLogDebug("ENTER");
1154 if ((contentType != CONTENT_TYPE_ALL) && (contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO))
1156 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1161 if ((__pDirectoryList == null) || (__pDirectoryList->GetCount() <= 0))
1163 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1168 __albumContentType = contentType;
1170 if (__pContentInfoList != null)
1172 delete __pContentInfoList;
1173 __pContentInfoList = null;
1175 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1176 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1182 FileListPresentationModel::GetCurrentAlbumName(void) const
1184 AppLogDebug("ENTER");
1185 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1191 FileListPresentationModel::SetCurrentAlbumName(const String& albumName)
1193 AppLogDebug("ENTER");
1194 if (&albumName == null)
1196 __albumName = EMPTY_SPACE;
1200 __albumName = albumName;
1202 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1206 FileListPresentationModel::GetCurrentAlbumContentType(void) const
1208 AppLogDebug("ENTER");
1209 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1211 return __albumContentType;
1215 FileListPresentationModel::SetCurrentAlbumContentType(const ContentType contentType)
1217 AppLogDebug("ENTER");
1218 __albumContentType = contentType;
1219 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1223 FileListPresentationModel::GetAlbumDirectoryListN(void) const
1225 AppLogDebug("ENTER");
1226 IList* pAlbumDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1227 if (__pDirectoryList == null)
1229 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1231 return pAlbumDirectoryList;
1234 String* pDirectory = null;
1235 int loopCount = __pDirectoryList->GetCount();
1236 for (int i = 0; i < loopCount; ++i)
1238 pDirectory = static_cast<String*>(__pDirectoryList->GetAt(i));
1239 pAlbumDirectoryList->Add(new (std::nothrow) String(*pDirectory));
1241 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1243 return pAlbumDirectoryList;
1247 FileListPresentationModel::GetAlbumContentInfoList(void) const
1249 AppLogDebug("ENTER");
1250 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1251 if (__pContentInfoList == null)
1253 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1255 return pContentList;
1258 ContentInfo* pContentInfo = null;
1259 int loopCount = __pContentInfoList->GetCount();
1260 for (int i = 0; i < loopCount; ++i)
1262 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(i));
1263 pContentList->Add(pContentInfo);
1265 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1267 return pContentList;
1271 FileListPresentationModel::GetContentInfo(const int index) const
1273 AppLogDebug("ENTER");
1274 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1276 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1281 if (index < 0 || index >= __pContentInfoList->GetCount())
1283 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1287 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1288 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1290 return pContentInfo;
1293 IList* FileListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
1295 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1296 int loopCount = indexList.GetCount();
1297 for (int i = 0; i < loopCount; ++i)
1299 const Integer* pIndex = static_cast<const Integer*>(indexList.GetAt(i));
1301 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
1303 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
1307 return pContentIdList;
1311 FileListPresentationModel::GetCurrentAlbumContentInfoCount(void) const
1313 AppLogDebug("ENTER");
1314 if (__pContentInfoList == null)
1316 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1320 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1322 return __pContentInfoList->GetCount();
1326 FileListPresentationModel::GetContentInfoIndex(const int index) const
1328 AppLogDebug("ENTER");
1329 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1331 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1336 if (index < 0 || index >= __pContentInfoList->GetCount())
1338 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1342 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1343 ContentId contentId = pContentInfo->GetContentId();
1344 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1350 FileListPresentationModel::GetContentFilePath(const int index) const
1352 AppLogDebug("ENTER index(%d)", index);
1353 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1355 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1360 if (index < 0 || index >= __pContentInfoList->GetCount())
1362 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1367 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1368 String contentPath = pContentInfo->GetContentPath();
1369 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1375 FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnail,
1376 const ThumbnailInfo& thumbmailInfo)
1378 AppLogDebug("ENTER");
1379 Bitmap* pOverlayedImage = null;
1381 if (&thumbmailInfo != null)
1383 long duration = thumbmailInfo.GetDuration();
1386 if (&thumbnail != null)
1388 BufferInfo bufferInfo;
1389 thumbnail.Lock(bufferInfo, INFINITE);
1391 mainCanvas.Construct(bufferInfo);
1395 Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
1396 mainCanvas.Construct(mainRect);
1397 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), mainRect);
1400 Rectangle playRect(GAP_W_PLAY_FG, GAP_H_PLAY_FG, W_PLAY_FG, H_PLAY_FG);
1401 Bitmap* playBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_PLAY);
1402 if (playBitmap != null)
1404 mainCanvas.DrawBitmap(playRect, *playBitmap);
1409 Rectangle durSize(0, 0, W_DURATION, H_DURATION);
1410 Rectangle durRect(0, GAP_H_DURATION, W_DURATION, H_DURATION);
1411 Color durColor(COLOR_DURATION_BG);
1412 durColor.SetAlpha(ALPHA_DURATION);
1413 durCanvas.Construct(durSize);
1414 durCanvas.FillRectangle(durColor, durSize);
1416 durFont.Construct(FONT_STYLE_PLAIN, FONT_SIZE_DURATION);
1417 durCanvas.SetFont(durFont);
1418 durCanvas.DrawText(Point(W_DURATION_TEXT, H_DURATION_TEXT),
1419 CommonUtil::DurationToTimeString(duration), COLOR_TEXT_OUTLINE);
1421 durBitmap.Construct(durCanvas, durCanvas.GetBounds());
1422 mainCanvas.DrawBitmap(durRect, durBitmap);
1424 pOverlayedImage = new (std::nothrow) Bitmap();
1425 pOverlayedImage->Construct(mainCanvas, mainCanvas.GetBounds());
1427 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1429 return pOverlayedImage;
1433 FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
1434 const Bitmap& originalBitmap, const Rectangle& originalBitmapPosition) const
1436 AppLogDebug("ENTER");
1437 if (&originalBitmap == null || &originalBitmap == null)
1439 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1444 BufferInfo bufferInfo;
1445 bgBitmap.Lock(bufferInfo, INFINITE);
1448 mainCanvas.Construct(bufferInfo);
1450 mainCanvas.DrawBitmap(originalBitmapPosition, originalBitmap);
1452 Bitmap* pMainImage = new (std::nothrow) Bitmap();
1453 pMainImage->Construct(mainCanvas,mainCanvas.GetBounds());
1454 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1460 FileListPresentationModel::GetContentInfoListInDirectoryListN(const IList& contentDirectoryList,
1461 ContentType contentType)const
1463 AppLogDebug("ENTER");
1464 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1466 if ((&contentDirectoryList == null) || (contentDirectoryList.GetCount() == 0)
1467 || ((contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO) && (contentType != CONTENT_TYPE_ALL)))
1469 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1470 return pContentList;
1473 ContentDirectory contentDirectory;
1474 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1475 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
1477 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1479 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
1481 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1483 result r = contentDirectory.Construct(*pContentTypeList);
1484 delete pContentTypeList;
1488 int pageNo = SIZE_PAGE_NO;
1489 int countPerPage = SIZE_CONUNT_PER_PAGE;
1490 String* pContentDirectory = null;
1492 int loopCount = contentDirectoryList.GetCount();
1493 for (int i = 0; i < loopCount; ++i)
1495 IList* pIList = null;
1496 pContentDirectory = const_cast<String*>(static_cast<const String*>(contentDirectoryList.GetAt(i)));
1497 if (pContentDirectory != null)
1499 pIList = contentDirectory.GetContentDirectoryItemListN(*pContentDirectory, pageNo, countPerPage,
1500 CONTENT_INFO_ORDER, SORT_ORDER_NONE);
1504 pContentList->AddItems(*pIList);
1509 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1511 return pContentList;
1515 FileListPresentationModel::ConvertToAlbumName(const String& targetPath)const
1517 AppLogDebug("ENTER");
1519 if (&targetPath == null || targetPath.GetLength() == 0)
1524 if (targetPath == RESERVED_CAMERA_PATH || targetPath == RESERVED_CAMERA_PATH_EXT)
1526 albumName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
1528 else if (targetPath == RESERVED_DOWNLOAD_PATH)
1530 albumName = ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS");
1534 String directoryName = GetDirecotyNameFromFullPath(targetPath);
1535 albumName = directoryName;
1542 FileListPresentationModel::GetAppControlMode(void) const
1544 AppLogDebug("Enter");
1545 AppLogDebug("Exit");
1547 return __appControlMode;
1551 FileListPresentationModel::GetAppControlMediaType(void) const
1553 AppLogDebug("Enter");
1554 AppLogDebug("Exit");
1556 return __appControlMediaType;
1559 AppControlSelectionMode
1560 FileListPresentationModel::GetAppControlSelectionMode(void) const
1562 AppLogDebug("Enter");
1563 AppLogDebug("Exit");
1565 return __appControlSelectionMode;
1569 FileListPresentationModel::SetUpdateProgressStatus(const bool status)
1571 AppLogDebug("ENTER status = %d",status);
1572 __updateProgressStatus = status;
1573 AppLogDebug("EXIT");
1577 FileListPresentationModel::RotateImage(int index, RotateMode rotateMode)
1579 result r = E_SUCCESS;
1580 ImageBuffer rotateBuffer;
1581 ImageBuffer* pRotatedBuffer = null;
1582 ImageFormat imageFormat;
1584 String filePath = GetContentFilePath(index);
1585 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1586 if (contentType == CONTENT_TYPE_VIDEO)
1591 r = img.Construct();
1595 imageFormat = img.GetImageFormat(filePath);
1597 r = rotateBuffer.Construct(filePath);
1600 if (rotateMode == ROTATE_MODE_RIGHT)
1602 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1606 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1610 if (pRotatedBuffer != null)
1612 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1613 delete pRotatedBuffer;
1614 ContentManager::ScanFile(filePath);
1622 FileListPresentationModel::ClearImageCache(void)
1624 AppLogDebug("ENTER");
1626 if(__pIconListViewCache != null)
1628 bool clearThumbnailReq = true;
1629 while(__pIconListViewCache->GetCount() != 0)
1631 //This is to Clear the Thumbnail Reuqests only Once
1632 if(clearThumbnailReq == true)
1634 ClearThumbnailRequests();
1635 clearThumbnailReq = false;
1637 __pIconListViewCache->RemoveAt(0, true);
1640 AppLogDebug("EXIT");
1644 FileListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
1646 AppLogDebug("ENTER");
1647 if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
1649 IFormContentUpdateEventListener* pInterface = null;
1650 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1651 while (pEventEnum->MoveNext() == E_SUCCESS)
1653 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1654 pInterface->OnContentUpdated();
1658 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));