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 delete __pIconListViewCache;
136 __pIconListViewCache = new (std::nothrow) ArrayList(SingleObjectDeleter);
137 __pIconListViewCache->Construct(SIZE_ICON_LIST_CACHE);
139 if (__pDirectoryList != null)
141 delete __pDirectoryList;
143 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
145 if (__pContentInfoList != null)
147 delete __pContentInfoList;
149 __pContentInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
151 __pPresentationModelListener = new (std::nothrow) ArrayList();
152 __pPresentationModelListener->Construct();
154 __pContentEventListener = new (std::nothrow) ArrayList();
155 __pContentEventListener->Construct();
157 __pThumbnailProvider = ThumbnailProvider::GetInstance();
159 GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
160 const IMap* pArguments = pApp->GetAppControlArguments();
161 String operationId = pApp->GetAppControlOperationId();
163 if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
165 __appControlMode = APPCONTROL_MODE_MAIN;
167 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
169 __appControlMode = APPCONTROL_MODE_PICK;
171 String mimeType = pApp->GetMimeType();
172 if (mimeType.IsEmpty() != true)
174 if (mimeType.StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
176 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
179 if (pArguments != null)
181 const String* selectionMode = static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
183 if (pApp->GetMimeType().StartsWith(APPCONTROL_DATA_VIDEO, 0) == true)
185 __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
188 if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
190 __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
194 else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
196 __appControlMode = APPCONTROL_MODE_SETTING;
199 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
205 FileListPresentationModel::CreateInstance(void)
207 AppLogDebug("ENTER");
208 __pPresentationModelInstance = new (std::nothrow) FileListPresentationModel();
209 result r = __pPresentationModelInstance->Construct();
210 if (IsFailed(r) == true)
212 delete __pPresentationModelInstance;
213 __pPresentationModelInstance = null;
214 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
219 std::atexit(DestroyInstance);
220 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
224 FileListPresentationModel::DestroyInstance(void)
226 AppLogDebug("ENTER");
228 delete __pThumbnailEvent;
229 __pIconListViewCache = null;
231 if (__pIconListViewCache != null)
233 delete __pIconListViewCache;
234 __pIconListViewCache = null;
237 if (__pDirectoryList != null)
239 delete __pDirectoryList;
240 __pDirectoryList = null;
243 if (__pContentInfoList != null)
245 delete __pContentInfoList;
246 __pContentInfoList = null;
249 if (__pPresentationModelListener != null)
251 delete __pPresentationModelListener;
252 __pPresentationModelListener = null;
255 if (__pContentEventListener != null)
257 delete __pContentEventListener;
258 __pContentEventListener = null;
261 delete __pPresentationModelInstance;
262 __pPresentationModelInstance = null;
264 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
268 FileListPresentationModel::GetFileNameFromFullPath(const String& fullPath, const bool withExt) const
270 AppLogDebug("ENTER");
271 if (fullPath.CompareTo(EMPTY_SPACE) == 0)
273 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
278 String delim(DIRECTORY_SEPARATOR);
279 StringTokenizer st(fullPath,delim);
281 while (st.HasMoreTokens())
283 st.GetNextToken(token);
288 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
294 String subDelim(FILE_EXT_SEPARATOR);
295 StringTokenizer subSt(token, subDelim);
297 subSt.GetNextToken(subToken);
298 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
305 FileListPresentationModel::GetDirecotyNameFromFullPath(const String& fullPath)const
307 AppLogDebug("ENTER");
308 if (fullPath == null)
310 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
314 String delim(DIRECTORY_SEPARATOR);
315 StringTokenizer st(fullPath,delim);
317 while (st.HasMoreTokens())
319 st.GetNextToken(token);
321 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
327 FileListPresentationModel::IsContainContentInDirectory(const String& directoryPath, ContentType contentType) const
329 AppLogDebug("ENTER");
330 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
331 if (&directoryPath == null || pContentTypeList == null)
333 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
338 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
340 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
342 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
344 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
347 ContentDirectory contentDirectory;
348 result r = contentDirectory.Construct(*pContentTypeList);
349 if (pContentTypeList != null)
351 delete pContentTypeList;
353 TryReturn(r == E_SUCCESS, false, "[%s] Unable to construct ContentDirectory", GetErrorMessage(r));
355 bool returnValue = false;
356 int pageNo = SIZE_PAGE_NO;
357 int countPerPage = SIZE_CONUNT_PER_PAGE;
359 IList* pContentList = contentDirectory.GetContentDirectoryItemListN(directoryPath, pageNo, countPerPage,
360 CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
362 if (pContentList == null || pContentList->GetCount() <= 0)
371 if (pContentList != null)
375 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
381 FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pName, Bitmap*& pThumbnail)
383 AppLogDebug("ENTER : index(%d)", index);
384 Bitmap* pOriginalBitmap = null;
385 Bitmap* pDestinationBitmap = null;
386 ContentInfo* pContentInfo = null;
388 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
390 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
391 if (pContentInfo == null)
393 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
400 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
404 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
405 if (pThumbnailInfo != null)
407 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
408 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
411 if ((pThumbnailInfo != null)&&(pThumbnailInfo->GetContentType() == CONTENT_TYPE_VIDEO))
413 if (pOriginalBitmap != null)
415 pDestinationBitmap = CoverVideoOverlayedImageOnThumbnailN(*pOriginalBitmap, *pThumbnailInfo);
416 delete pOriginalBitmap;
421 pDestinationBitmap = pOriginalBitmap;
424 if (pDestinationBitmap != null)
426 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
427 Rectangle thumbnailRect(RECTANGLE_THUMBNAIL_OFFSET_POSION);
428 pDestinationBitmap->Scale(Dimension(RECTANGLE_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_THUMBNAIL_OFFSET_POSION.x
429 , RECTANGLE_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_THUMBNAIL_OFFSET_POSION.y));
430 if (pThumbnailBgBitmap != null)
432 pThumbnailBgBitmap->Scale(DIMENSION_REAL_ICON);
433 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pDestinationBitmap, thumbnailRect);
434 delete pThumbnailBgBitmap;
435 delete pDestinationBitmap;
439 pThumbnail = pDestinationBitmap;
447 if (pThumbnailInfo != null)
449 delete pThumbnailInfo;
451 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
457 FileListPresentationModel::GetThumbnailVideoInSyncCacheN(const int index,
458 String*& pName, Bitmap*& pThumbnail, String*& pDuration) const
460 AppLogDebug("ENTER : index(%d)", index);
461 ContentInfo* pContentInfo = null;
462 Bitmap* pOriginalBitmap = null;
464 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
466 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
467 if (pContentInfo == null)
469 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
475 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
479 ThumbnailInfo* pThumbnailInfo = GetThumbnailInfoFromInternalBufferN(pContentInfo->GetContentId());
480 if (pThumbnailInfo != null)
482 pName = new (std::nothrow) String(pThumbnailInfo->GetFilePath());
483 pOriginalBitmap = pThumbnailInfo->GetBitmapN();
484 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(pThumbnailInfo->GetDuration()));
488 pName = new (std::nothrow) String(EMPTY_SPACE);
489 pDuration = new (std::nothrow) String(CommonUtil::DurationToTimeString(0));
492 if (pOriginalBitmap != null)
494 Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
495 Rectangle thumbnailRect(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION);
496 pOriginalBitmap->Scale(Dimension(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.x
497 , RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.y));
498 if (pThumbnailBgBitmap != null)
500 pThumbnailBgBitmap->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
501 pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pOriginalBitmap, thumbnailRect);
502 delete pThumbnailBgBitmap;
504 delete pOriginalBitmap;
511 if (pThumbnail != null)
513 pThumbnail->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
516 if (pThumbnailInfo != null)
518 delete pThumbnailInfo;
520 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
526 FileListPresentationModel::RequestThumbnail(const int index)
528 AppLogDebug("ENTER : index(%d)", index);
529 ContentInfo* pContentInfo = null;
531 if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
533 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
534 if (pContentInfo == null)
536 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
542 AppLogDebug("EXIT 2 __pContentInfoList(%x) index(%d)", __pContentInfoList, index);
547 __pThumbnailProvider->RequestThumbnail(pContentInfo->GetContentId(), __pThumbnailEvent);
552 FileListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
554 AppLogDebug("ENTER");
556 if (__pThumbnailProvider != null)
558 __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
565 FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
567 AppLogDebug("ENTER");
569 if (&eventArg != null)
571 ThumbnailEventArg* pThumbnailEventArg = static_cast<ThumbnailEventArg*>(&eventArg);
572 if (pThumbnailEventArg == null)
574 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
578 ThumbnailInfo* pThumbnailInfo = pThumbnailEventArg->GetThumbnailInfoN();
579 if (pThumbnailInfo == null)
581 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
586 bool isMatch = false;
587 ContentId contentId = pThumbnailInfo->GetContentId();
589 if (__pIconListViewCache != null)
591 IEnumerator* pEnum = __pIconListViewCache->GetEnumeratorN();
592 Bitmap* pBitmap = null;
593 while (pEnum->MoveNext() == E_SUCCESS)
595 ThumbnailInfo* pTempThumbnailInfo = static_cast<ThumbnailInfo*>(pEnum->GetCurrent());
597 if (contentId == pTempThumbnailInfo->GetContentId())
599 AppLogDebug("[CHASEFIRE] PM receive (%ls)", pThumbnailInfo->GetFilePath().GetPointer());
600 pBitmap = pThumbnailInfo->GetBitmapN();
601 pTempThumbnailInfo->SetBitmap(*pBitmap);
604 pTempThumbnailInfo->SetContentType(pThumbnailInfo->GetContentType());
605 pTempThumbnailInfo->SetDuration(pThumbnailInfo->GetDuration());
606 delete pThumbnailInfo;
612 if (isMatch == false)
614 if (SIZE_ICON_LIST_CACHE <= __pIconListViewCache->GetCount())
616 __pIconListViewCache->RemoveAt(0, true);
618 AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)", __pIconListViewCache->GetCount(),
619 pThumbnailInfo->GetFilePath().GetPointer());
620 __pIconListViewCache->Add(pThumbnailInfo);
625 int loopCount = __pContentInfoList->GetCount();
626 for (int i = 0; i < loopCount; ++i)
628 if (contentId == (static_cast<ContentInfo*>(__pContentInfoList->GetAt(i)))->GetContentId())
635 IAlbumEventListener* pInterface = null;
636 IEnumerator* pEventEnum = __pPresentationModelListener->GetEnumeratorN();
637 while (pEventEnum->MoveNext() == E_SUCCESS)
639 pInterface = static_cast<IAlbumEventListener*>(pEventEnum->GetCurrent());
640 pInterface->OnThumbnailDecoded(index);
644 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
648 FileListPresentationModel::OnContentCreated(void)
650 AppLogDebug("ENTER");
651 if (__updateProgressStatus == true)
653 AppLogDebug("EXIT update in application");
656 IFormContentUpdateEventListener* pInterface = null;
657 if (__pContentEventListener == null)
662 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
663 while (pEventEnum->MoveNext() == E_SUCCESS)
665 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
666 if (pInterface != null)
668 pInterface->OnContentUpdated();
676 FileListPresentationModel::OnContentUpdated(void)
678 AppLogDebug("ENTER");
679 if (__updateProgressStatus == true)
681 AppLogDebug("EXIT update in application");
684 //Clear the ImageCaches when content is updated like rotate.
687 IFormContentUpdateEventListener* pInterface = null;
688 if (__pContentEventListener == null)
693 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
694 while (pEventEnum->MoveNext() == E_SUCCESS)
696 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
697 pInterface->OnContentUpdated();
704 FileListPresentationModel::OnContentDeleted(void)
706 AppLogDebug("ENTER");
707 if (__updateProgressStatus == true)
709 AppLogDebug("EXIT update in application");
712 IFormContentUpdateEventListener* pInterface = null;
713 if (__pContentEventListener == null)
718 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
719 while (pEventEnum->MoveNext() == E_SUCCESS)
721 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
722 pInterface->OnContentUpdated();
729 FileListPresentationModel::AddPresentationModelListener(const IAlbumEventListener* listener)
731 AppLogDebug("ENTER");
732 __pPresentationModelListener->Add((Object*)listener);
733 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
737 FileListPresentationModel::RemovePresentationModelListener(const IAlbumEventListener& listener)
739 AppLogDebug("ENTER");
740 __pPresentationModelListener->Remove(listener);
741 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
745 FileListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
747 AppLogDebug("ENTER");
748 if (__pContentEventListener != null)
750 __pContentEventListener->RemoveAll();
751 __pContentEventListener->Add((Object*)listener);
752 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
757 FileListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener* listener)
759 AppLogDebug("ENTER");
760 __pContentEventListener->Remove(*listener);
761 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
765 FileListPresentationModel::GetThumbnailInfoFromInternalBufferN(const ContentId& contentId) const
767 AppLogDebug("ENTER");
768 ThumbnailInfo* pThumbnailInfo = null;
769 ThumbnailInfo* pTempThumbnailInfo = null;
770 if (__pIconListViewCache != null)
772 int loopCount = __pIconListViewCache->GetCount();
773 for (int i = 0; i < loopCount; ++i)
775 pTempThumbnailInfo = static_cast<ThumbnailInfo*>(__pIconListViewCache->GetAt(i));
776 if (contentId == pTempThumbnailInfo->GetContentId())
779 pThumbnailInfo = new (std::nothrow) ThumbnailInfo();
780 Bitmap* pBitmap = pTempThumbnailInfo->GetBitmapN();
781 pThumbnailInfo->Construct(pTempThumbnailInfo->GetContentId(), pTempThumbnailInfo->GetFilePath(),
782 *pBitmap, pTempThumbnailInfo->GetContentType(), pTempThumbnailInfo->GetDuration());
788 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
790 return pThumbnailInfo;
794 FileListPresentationModel::DeleteContentFileList(const IList& contentIndexList)
796 AppLogDebug("ENTER");
797 if (&contentIndexList == null || contentIndexList.GetCount() <= 0)
799 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
804 IList * pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
805 int loopCount = contentIndexList.GetCount();
806 for (int i = 0; i < loopCount; ++i)
808 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
810 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
812 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>
813 (__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
817 loopCount = pContentIdList->GetCount();
818 for (int i = 0; i < loopCount; ++i)
820 ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(i));
821 if (pContentId != null)
823 DeleteContentFile(*pContentId);
826 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
832 FileListPresentationModel::GetCollisionIndexListN(const IList& contentIndexList, const String& destDirectory)
834 AppLogDebug("ENTER");
835 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null
836 || destDirectory.IsEmpty() == true)
838 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
843 if (File::IsFileExist(destDirectory) == false)
845 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
850 IList * pCollisionInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
851 ContentInfo* pContentInfo = null;
852 int loopCount = contentIndexList.GetCount();
853 for (int i = 0; i < loopCount; ++i)
855 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
857 if ((pIndex != null) && (pIndex->ToInt()) >= 0 && __pContentInfoList->GetCount() > pIndex->ToInt())
859 pContentInfo = const_cast<ContentInfo*>(static_cast<const ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())));
860 String filePath = pContentInfo->GetContentPath();
861 String fileName = GetFileNameFromFullPath(filePath, true);
864 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
866 destPath.Append(destDirectory);
867 destPath.Append(fileName);
871 destPath.Append(destDirectory);
872 destPath.Append(DIRECTORY_SEPARATOR);
873 destPath.Append(fileName);
876 if (File::IsFileExist(destPath) == true)
878 pCollisionInfoList->Add(*(new (std::nothrow) String(pIndex->ToString() + MULTI_ITEM_SEPARATOR + fileName)));
882 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
884 return pCollisionInfoList;
888 FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList, const String& destDirectory)
890 AppLogDebug("ENTER");
891 result r = E_SUCCESS;
892 if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null || destDirectory.IsEmpty() == true)
894 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
899 if (File::IsFileExist(destDirectory) == false)
901 Directory::Create(destDirectory, true);
904 delete __pContentIdList;
905 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
906 int loopCount = contentIndexList.GetCount();
907 for (int i = 0; i < loopCount; ++i)
909 const Integer* pIndex = static_cast<const Integer*>(contentIndexList.GetAt(i));
911 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
913 __pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
918 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
924 FileListPresentationModel::DeleteContentFile(const ContentId& contentId)
926 AppLogDebug("ENTER");
927 if (&contentId == null)
929 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
933 result r = __pContentManager->DeleteContent(contentId);
935 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
941 FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const String& destDirectory, const bool isCopyOperation)
943 AppLogDebug("ENTER");
944 if (contentId.ToString().IsEmpty() == true || destDirectory.IsEmpty() == true)
946 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
949 result r = E_SUCCESS;
950 ContentInfo* pContentInfo = __pContentManager->GetContentInfoN(contentId);
951 if (pContentInfo == null)
953 AppLogDebug("Santhosh %s", destDirectory.GetPointer());
954 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
958 String filePath = pContentInfo->GetContentPath();
959 if (filePath.GetLength() < 4)
961 AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
966 if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
968 destPath.Append(destDirectory);
969 destPath.Append(GetFileNameFromFullPath(filePath, true));
973 destPath.Append(destDirectory);
974 destPath.Append(DIRECTORY_SEPARATOR);
975 destPath.Append(GetFileNameFromFullPath(filePath, true));
978 if (destPath.CompareTo(filePath) == 0)
980 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
984 if (File::IsFileExist(destPath) == true)
986 File::Remove(destPath);
989 r = File::Copy(filePath, destPath, false);
991 if ( r == E_STORAGE_FULL)
993 File::Remove(destPath);
995 ContentManager::ScanFile(destPath);
997 if ( r == E_SUCCESS )
999 if ( isCopyOperation == false)
1001 File::Remove(filePath); // if Move Op remove original file
1002 ContentManager::ScanFile(filePath);
1006 delete pContentInfo;
1008 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1014 FileListPresentationModel::ClearProviderId(void)
1016 __providerId.Clear();
1020 FileListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
1021 const String* pUriData, const Tizen::Base::String* pMimeType, const HashMap* pDataList,
1022 IAppControlResponseListener* pListener)
1024 AppLogDebug("ENTER");
1025 AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
1028 __providerId.Append(providerId);
1032 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1035 result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
1039 GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
1040 pGalleryApp->SetFrameEnabled(false);
1045 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1051 FileListPresentationModel::SetCurrentAlbumInfo(const String& albumName, const IList& directoryList)
1053 AppLogDebug("ENTER");
1055 if (&directoryList != null)
1057 if (__pDirectoryList != null && __pDirectoryList->GetCount() > 0)
1059 bool isMatched = false;
1060 int outterLoopCount = __pDirectoryList->GetCount();
1061 int innerLoopCount = 0;
1062 for (int i = 0; i < outterLoopCount ; ++i)
1065 innerLoopCount = directoryList.GetCount();
1066 for (int j = 0; j < innerLoopCount; ++j)
1068 if (static_cast<String*>(__pDirectoryList->GetAt(i))->CompareTo(
1069 *(const_cast<String*>(static_cast<const String*>(directoryList.GetAt(j))))) == 0)
1077 outterLoopCount = directoryList.GetCount();
1078 for (int i = 0; i < outterLoopCount; ++i)
1081 innerLoopCount = __pDirectoryList->GetCount();
1082 for (int j = 0; j < innerLoopCount; ++j)
1084 if (const_cast<String*>(static_cast<const String*>(directoryList.GetAt(i)))->CompareTo(
1085 *(static_cast<String*>(__pDirectoryList->GetAt(j)))) == 0)
1095 __albumName = albumName;
1096 __providerId.Clear();
1098 if (__pDirectoryList != null)
1100 delete __pDirectoryList;
1102 __pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1104 int loopCount = directoryList.GetCount();
1105 for (int i = 0; i < loopCount; ++i)
1107 __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>
1108 (static_cast<const String*>(directoryList.GetAt(i))))));
1111 if (__pContentInfoList != null)
1113 delete __pContentInfoList;
1114 __pContentInfoList = null;
1117 if (GetAppControlMode() == APPCONTROL_MODE_PICK)
1119 AppControlMediaType appControlMediaType = GetAppControlMediaType();
1120 if (appControlMediaType == APPCONTROL_MEDIA_TYPE_IMAGE)
1122 __albumContentType = CONTENT_TYPE_IMAGE;
1124 else if (appControlMediaType == APPCONTROL_MEDIA_TYPE_VIDEO)
1126 __albumContentType = CONTENT_TYPE_VIDEO;
1129 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1130 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1136 FileListPresentationModel::RefreshCurrentAlbumContentInfoList(const ContentType contentType)
1138 AppLogDebug("ENTER");
1139 result r = RefreshContentInfoList(contentType);
1140 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1146 FileListPresentationModel::RefreshContentInfoList(const ContentType contentType)
1148 AppLogDebug("ENTER");
1149 if ((contentType != CONTENT_TYPE_ALL) && (contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO))
1151 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1156 if ((__pDirectoryList == null) || (__pDirectoryList->GetCount() <= 0))
1158 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1163 __albumContentType = contentType;
1165 if (__pContentInfoList != null)
1167 delete __pContentInfoList;
1168 __pContentInfoList = null;
1170 __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
1171 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1177 FileListPresentationModel::GetCurrentAlbumName(void) const
1179 AppLogDebug("ENTER");
1180 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1186 FileListPresentationModel::SetCurrentAlbumName(const String& albumName)
1188 AppLogDebug("ENTER");
1189 if (&albumName == null)
1191 __albumName = EMPTY_SPACE;
1195 __albumName = albumName;
1197 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1201 FileListPresentationModel::GetCurrentAlbumContentType(void) const
1203 AppLogDebug("ENTER");
1204 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1206 return __albumContentType;
1210 FileListPresentationModel::SetCurrentAlbumContentType(const ContentType contentType)
1212 AppLogDebug("ENTER");
1213 __albumContentType = contentType;
1214 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1218 FileListPresentationModel::GetAlbumDirectoryListN(void) const
1220 AppLogDebug("ENTER");
1221 IList* pAlbumDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1222 if (__pDirectoryList == null)
1224 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1226 return pAlbumDirectoryList;
1229 String* pDirectory = null;
1230 int loopCount = __pDirectoryList->GetCount();
1231 for (int i = 0; i < loopCount; ++i)
1233 pDirectory = static_cast<String*>(__pDirectoryList->GetAt(i));
1234 pAlbumDirectoryList->Add(new (std::nothrow) String(*pDirectory));
1236 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1238 return pAlbumDirectoryList;
1242 FileListPresentationModel::GetAlbumContentInfoList(void) const
1244 AppLogDebug("ENTER");
1245 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1246 if (__pContentInfoList == null)
1248 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1250 return pContentList;
1253 ContentInfo* pContentInfo = null;
1254 int loopCount = __pContentInfoList->GetCount();
1255 for (int i = 0; i < loopCount; ++i)
1257 pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(i));
1258 pContentList->Add(pContentInfo);
1260 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1262 return pContentList;
1266 FileListPresentationModel::GetContentInfo(const int index) const
1268 AppLogDebug("ENTER");
1269 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1271 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1276 if (index < 0 || index >= __pContentInfoList->GetCount())
1278 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1282 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1283 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1285 return pContentInfo;
1288 IList* FileListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
1290 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1291 int loopCount = indexList.GetCount();
1292 for (int i = 0; i < loopCount; ++i)
1294 const Integer* pIndex = static_cast<const Integer*>(indexList.GetAt(i));
1296 if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
1298 pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
1302 return pContentIdList;
1306 FileListPresentationModel::GetCurrentAlbumContentInfoCount(void) const
1308 AppLogDebug("ENTER");
1309 if (__pContentInfoList == null)
1311 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1315 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1317 return __pContentInfoList->GetCount();
1321 FileListPresentationModel::GetContentInfoIndex(const int index) const
1323 AppLogDebug("ENTER");
1324 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1326 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1331 if (index < 0 || index >= __pContentInfoList->GetCount())
1333 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1337 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1338 ContentId contentId = pContentInfo->GetContentId();
1339 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1345 FileListPresentationModel::GetContentFilePath(const int index) const
1347 AppLogDebug("ENTER index(%d)", index);
1348 if (__pContentInfoList == null || __pContentInfoList->GetCount() == 0)
1350 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1355 if (index < 0 || index >= __pContentInfoList->GetCount())
1357 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1362 ContentInfo* pContentInfo = static_cast<ContentInfo*>(__pContentInfoList->GetAt(index));
1363 String contentPath = pContentInfo->GetContentPath();
1364 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1370 FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnail,
1371 const ThumbnailInfo& thumbmailInfo)
1373 AppLogDebug("ENTER");
1374 Bitmap* pOverlayedImage = null;
1376 if (&thumbmailInfo != null)
1378 long duration = thumbmailInfo.GetDuration();
1381 if (&thumbnail != null)
1383 BufferInfo bufferInfo;
1384 thumbnail.Lock(bufferInfo, INFINITE);
1386 mainCanvas.Construct(bufferInfo);
1390 Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
1391 mainCanvas.Construct(mainRect);
1392 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), mainRect);
1395 Rectangle playRect(GAP_W_PLAY_FG, GAP_H_PLAY_FG, W_PLAY_FG, H_PLAY_FG);
1396 Bitmap* playBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_PLAY);
1397 if (playBitmap != null)
1399 mainCanvas.DrawBitmap(playRect, *playBitmap);
1404 Rectangle durSize(0, 0, W_DURATION, H_DURATION);
1405 Rectangle durRect(0, GAP_H_DURATION, W_DURATION, H_DURATION);
1406 Color durColor(COLOR_DURATION_BG);
1407 durColor.SetAlpha(ALPHA_DURATION);
1408 durCanvas.Construct(durSize);
1409 durCanvas.FillRectangle(durColor, durSize);
1411 durFont.Construct(FONT_STYLE_PLAIN, FONT_SIZE_DURATION);
1412 durCanvas.SetFont(durFont);
1413 durCanvas.DrawText(Point(W_DURATION_TEXT, H_DURATION_TEXT),
1414 CommonUtil::DurationToTimeString(duration), COLOR_TEXT_OUTLINE);
1416 durBitmap.Construct(durCanvas, durCanvas.GetBounds());
1417 mainCanvas.DrawBitmap(durRect, durBitmap);
1419 pOverlayedImage = new (std::nothrow) Bitmap();
1420 pOverlayedImage->Construct(mainCanvas, mainCanvas.GetBounds());
1422 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1424 return pOverlayedImage;
1428 FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
1429 const Bitmap& originalBitmap, const Rectangle& originalBitmapPosition) const
1431 AppLogDebug("ENTER");
1432 if (&originalBitmap == null || &originalBitmap == null)
1434 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1439 BufferInfo bufferInfo;
1440 bgBitmap.Lock(bufferInfo, INFINITE);
1443 mainCanvas.Construct(bufferInfo);
1445 mainCanvas.DrawBitmap(originalBitmapPosition, originalBitmap);
1447 Bitmap* pMainImage = new (std::nothrow) Bitmap();
1448 pMainImage->Construct(mainCanvas,mainCanvas.GetBounds());
1449 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1455 FileListPresentationModel::GetContentInfoListInDirectoryListN(const IList& contentDirectoryList,
1456 ContentType contentType)const
1458 AppLogDebug("ENTER");
1459 IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1461 if ((&contentDirectoryList == null) || (contentDirectoryList.GetCount() == 0)
1462 || ((contentType != CONTENT_TYPE_IMAGE) && (contentType != CONTENT_TYPE_VIDEO) && (contentType != CONTENT_TYPE_ALL)))
1464 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1465 return pContentList;
1468 ContentDirectory contentDirectory;
1469 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1470 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_ALL)
1472 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1474 if (contentType == CONTENT_TYPE_VIDEO || contentType == CONTENT_TYPE_ALL)
1476 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1478 result r = contentDirectory.Construct(*pContentTypeList);
1479 delete pContentTypeList;
1483 int pageNo = SIZE_PAGE_NO;
1484 int countPerPage = SIZE_CONUNT_PER_PAGE;
1485 String* pContentDirectory = null;
1487 int loopCount = contentDirectoryList.GetCount();
1488 for (int i = 0; i < loopCount; ++i)
1490 IList* pIList = null;
1491 pContentDirectory = const_cast<String*>(static_cast<const String*>(contentDirectoryList.GetAt(i)));
1492 if (pContentDirectory != null)
1494 pIList = contentDirectory.GetContentDirectoryItemListN(*pContentDirectory, pageNo, countPerPage,
1495 CONTENT_INFO_ORDER, SORT_ORDER_NONE);
1499 pContentList->AddItems(*pIList);
1504 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1506 return pContentList;
1510 FileListPresentationModel::ConvertToAlbumName(const String& targetPath)const
1512 AppLogDebug("ENTER");
1514 if (&targetPath == null || targetPath.GetLength() == 0)
1519 if (targetPath == RESERVED_CAMERA_PATH || targetPath == RESERVED_CAMERA_PATH_EXT)
1521 albumName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
1523 else if (targetPath == RESERVED_DOWNLOAD_PATH)
1525 albumName = ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS");
1529 String directoryName = GetDirecotyNameFromFullPath(targetPath);
1530 albumName = directoryName;
1537 FileListPresentationModel::GetAppControlMode(void) const
1539 AppLogDebug("Enter");
1540 AppLogDebug("Exit");
1542 return __appControlMode;
1546 FileListPresentationModel::GetAppControlMediaType(void) const
1548 AppLogDebug("Enter");
1549 AppLogDebug("Exit");
1551 return __appControlMediaType;
1554 AppControlSelectionMode
1555 FileListPresentationModel::GetAppControlSelectionMode(void) const
1557 AppLogDebug("Enter");
1558 AppLogDebug("Exit");
1560 return __appControlSelectionMode;
1564 FileListPresentationModel::SetUpdateProgressStatus(const bool status)
1566 AppLogDebug("ENTER status = %d",status);
1567 __updateProgressStatus = status;
1568 AppLogDebug("EXIT");
1572 FileListPresentationModel::RotateImage(int index, RotateMode rotateMode)
1574 result r = E_SUCCESS;
1575 ImageBuffer rotateBuffer;
1576 ImageBuffer* pRotatedBuffer = null;
1577 ImageFormat imageFormat;
1579 String filePath = GetContentFilePath(index);
1580 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1581 if (contentType == CONTENT_TYPE_VIDEO)
1586 r = img.Construct();
1590 imageFormat = img.GetImageFormat(filePath);
1592 r = rotateBuffer.Construct(filePath);
1595 if (rotateMode == ROTATE_MODE_RIGHT)
1597 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1601 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1605 if (pRotatedBuffer != null)
1607 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1608 delete pRotatedBuffer;
1609 ContentManager::ScanFile(filePath);
1617 FileListPresentationModel::ClearImageCache(void)
1619 AppLogDebug("ENTER");
1621 if(__pIconListViewCache != null)
1623 bool clearThumbnailReq = true;
1624 while(__pIconListViewCache->GetCount() != 0)
1626 //This is to Clear the Thumbnail Reuqests only Once
1627 if(clearThumbnailReq == true)
1629 ClearThumbnailRequests();
1630 clearThumbnailReq = false;
1632 __pIconListViewCache->RemoveAt(0, true);
1635 AppLogDebug("EXIT");
1639 FileListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
1641 AppLogDebug("ENTER");
1642 if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
1644 IFormContentUpdateEventListener* pInterface = null;
1645 IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
1646 while (pEventEnum->MoveNext() == E_SUCCESS)
1648 pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
1649 pInterface->OnContentUpdated();
1653 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));