//
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
#include "GlAlbumInfo.h"
#include "GlAlbumListPresentationModel.h"
+#include "GlAlbumRenameEventListener.h"
+#include "GlContentUpdateEventListener.h"
+#include "GlFileListPresentationModel.h"
#include "GlGalleryApp.h"
#include "GlThumbnailEvent.h"
#include "GlThumbnailEventArg.h"
static const int CANVAS_IMAGE_FOLDER_HEIGHT = 48;
static const int CANVAS_IMAGE_FOLDER_WIDTH = 48;
-static const int IMAGE_COUNT_WIDTH = 100;
+static const int IMAGE_COUNT_WIDTH = 100;
static const int IMAGE_COUNT_HEIGHT = 60;
static const int CANVAS_MARGIN_LEFT = 10;
static const int GAP = 10;
static const int HEIGHT_OFFSET = 5;
static const int Y_POS_CANVAS = 260;
static const int FOLDER_NAME_WIDTH = 165;
-static const int FOLDER_NAME_HEIGHT = 38 ;
+static const int FOLDER_NAME_HEIGHT = 38;
static const int ALPHA_BG = 110;
AlbumListPresentationModel* AlbumListPresentationModel::__pPresentationModelInstance = null;
ArrayList* AlbumListPresentationModel::__pPresentationModelListener = null;
+ArrayList* AlbumListPresentationModel::__pContentEventListener = null;
ThumbnailProvider* AlbumListPresentationModel::__pThumbnailProvider = null;
ThumbnailEvent* AlbumListPresentationModel::__pThumbnailEvent = null;
IList* AlbumListPresentationModel::__pAlbumInfoList = null;
AlbumListPresentationModel::AlbumListPresentationModel(void)
-: __pFolderBackgroundBitmap(null)
-, __appControlMode(APP_CONTROL_MODE_MAIN)
-, __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
-, __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
+ : __pFolderBackgroundBitmap(null)
+ , __pContentManager(null)
+ , __pAlbumListener(null)
+ , __appControlMode(APPCONTROL_MODE_MAIN)
+ , __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
+ , __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
+ , __updateProgressStatus(false)
{
AppLogDebug("ENTER");
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
AlbumListPresentationModel::~AlbumListPresentationModel(void)
{
AppLogDebug("ENTER");
+ DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+ delete __pFolderBackgroundBitmap;
+ delete __pContentManager;
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
__pPresentationModelListener = new (std::nothrow) ArrayList();
__pPresentationModelListener->Construct();
+ ContentUpdateEventListener::GetInstance();
+ __pContentEventListener = new (std::nothrow) ArrayList();
+ __pContentEventListener->Construct();
+
IThumbnailEventListener* pThumbnailEventListener = static_cast<IThumbnailEventListener*>(this);
__pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
__pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
+ __pContentManager = new (std::nothrow) ContentManager();
+ __pContentManager->Construct();
+
+ DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+
__pThumbnailProvider = ThumbnailProvider::GetInstance();
AppLogDebug("ENTER1");
GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
if (operationId.CompareTo(APPCONTROL_OPERATION_ID_MAIN) == 0)
{
- __appControlMode = APP_CONTROL_MODE_MAIN;
+ __appControlMode = APPCONTROL_MODE_MAIN;
}
else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_PICK) == 0)
{
- __appControlMode = APP_CONTROL_MODE_PICK;
+ __appControlMode = APPCONTROL_MODE_PICK;
String mimeType = pApp->GetMimeType();
if (mimeType.IsEmpty() != true)
{
const String* selectionMode =
static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_SELECTION_MODE)));
- const String* mediaType =
- static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_MEDIA_TYPE)));
-
- if (mediaType != null && mediaType->CompareTo(APPCONTROL_DATA_VIDEO) == 0)
- {
- __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
- }
-
if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
{
__appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
}
else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
{
- __appControlMode = APP_CONTROL_MODE_SETTING;
+ __appControlMode = APPCONTROL_MODE_SETTING;
}
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
AppLogDebug("EXIT false");
return;
}
-
std::atexit(DestroyInstance);
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
__pPresentationModelListener = null;
}
+ if (__pContentEventListener != null)
+ {
+ delete __pContentEventListener;
+ __pContentEventListener = null;
+ }
+
delete __pPresentationModelInstance;
__pPresentationModelInstance = null;
}
void
+AlbumListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
+{
+ AppLogDebug("ENTER");
+ if (__pContentEventListener != null)
+ {
+ __pContentEventListener->RemoveAll();
+ __pContentEventListener->Add((Object*)listener);
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+ }
+}
+
+void
+AlbumListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener& listener)
+{
+ AppLogDebug("ENTER");
+ __pContentEventListener->Remove(listener);
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
AlbumListPresentationModel::CallAlbumChangedEvent(void)
{
AppLogDebug("ENTER");
}
delete pEnum;
- pEnum = null;
}
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
+result
+AlbumListPresentationModel::RenameAlbum(const String& orgPath, const String& newPath,
+ IAlbumRenameEventListener* pAlbumListener)
+{
+ AppLogDebug("ENTER");
+ result r = Directory::Rename(orgPath, newPath);
+ if (IsFailed(r))
+ {
+ AppLogDebug("Album Rename failed(%s)", GetErrorMessage(r));
+ }
+ else
+ {
+ __pAlbumListener = pAlbumListener;
+ __renameNewPath = newPath;\r
+ r = ContentManager::ScanDirectory(newPath, true, NULL, __reqId);\r
+ AppLogDebug("Content scan failed (%s)", GetErrorMessage(r));
+ r = ContentManager::ScanDirectory(orgPath, true, NULL, __reqId);\r
+ AppLogDebug("Content scan failed (%s)", GetErrorMessage(r));
+ }
+ AppLogDebug("EXIT");
+ return r;
+}
+
+bool AlbumListPresentationModel::OnContentScanCompleted (const Tizen::Base::String &scanPath)\r
+{
+ AppLogDebug("ENTER");\r
+ if (__pAlbumListener && (scanPath == __renameNewPath))\r
+ {
+ InitializeAlbumInfoList(CONTENT_TYPE_ALL);
+ __pAlbumListener->OnAlbumRenameComplete();
+ __renameNewPath = L"";
+ AppLogDebug("EXIT");
+ return true;
+ }
+ AppLogDebug("EXIT");
+ return false;
+}
+
void
AlbumListPresentationModel::DrawPartialImage(Canvas& canvas, AlbumInfo* pAlbumInfo, const Rectangle& rectNew)
{
if (&canvas == null || __pFolderBackgroundBitmap == null || pAlbumInfo == null)
{
AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
-
return;
}
strCnt.Format(FORMAT_BUFFER_SIZE, L"%d", allContentCount);
String strFolderName = pAlbumInfo->GetAlbumName();
+ String strDirectory = pAlbumInfo->GetDirectory(0);
+ AppLog("The directory path is %ls" , strDirectory.GetPointer());
Rectangle rectCanvas(ICON_CAP + FOLDER_CAP, Y_POS_CANVAS, CANVAS_WIDTH, CANVAS_HEIGHT);
Color bgColor(COLOR_CANVAS_BG);
bgColor.SetAlpha(ALPHA_BG);
canvas.FillRectangle(bgColor, rectCanvas);
- if ( strFolderName == ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS"))
+
+ if (strDirectory == RESERVED_DOWNLOAD_PATH)
{
pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_DOWNLOAD);
}
- else if ( strFolderName == ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB") )
+ else if (strDirectory == RESERVED_CAMERA_PATH || strDirectory == RESERVED_CAMERA_PATH_EXT)
{
pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_CAMERA);
}
pBitmap = ResourceManager::GetBitmapN(IDB_ALBUM_ICON_FOLDER);
}
- if ( pBitmap != null)
+ if (pBitmap != null)
{
canvas.DrawBitmap(Rectangle(ICON_CAP + FOLDER_CAP, rectCanvas.y + HEIGHT_OFFSET, CANVAS_IMAGE_FOLDER_WIDTH,
CANVAS_IMAGE_FOLDER_HEIGHT), *pBitmap);
textElementCount.Construct(strCnt);
- if (strCnt.GetLength() > 3) // if the count in Album is greater than 3 digit number, use small font
+ if (strCnt.GetLength() > 3)
{
textElementCount.SetFont(ftCntSmall);
}
enTextCount.SetTextAbbreviationEnabled(true);
enTextCount.Add(textElementCount);
- pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH , rectCanvas.y + HEIGHT_OFFSET);
+ pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH,
+ rectCanvas.y + HEIGHT_OFFSET);
canvas.SetFont(ftCnt);
canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
canvas.DrawText(pointText, enTextCount);
- pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP , rectCanvas.y + GAP + HEIGHT_OFFSET);
+ pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP,
+ rectCanvas.y + GAP + HEIGHT_OFFSET);
canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
canvas.DrawText(pointText, enText);
}
Bitmap*
-AlbumListPresentationModel::CreateMergeBitmapN(int index)
+AlbumListPresentationModel::CreateMergeBitmapN(const int index)
{
AppLogDebug("ENTER index(%d)", index);
DrawPartialImage(canvas, pAlbumInfo, rectNew);
DrawFontImage(canvas, pAlbumInfo, index);
-
pBitmapNew->Unlock();
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
result
-AlbumListPresentationModel::StartAppControl( const String& providerId, const String& operationId,
- const IMap* pDataList, IAppControlResponseListener* pListener)
+AlbumListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
+ const String* pUriData, const String* pMimeType, const HashMap* pDataList,
+ IAppControlResponseListener* pListener)
{
AppLogDebug("ENTER");
- AppLogDebug("FindAppControlN(%ls, %ls)", providerId.GetPointer(), operationId.GetPointer());
- if (pDataList != null)
- {
- IList* pKeyList = pDataList->GetKeysN();
- if (pKeyList != null)
- {
- int keyCount = pKeyList->GetCount();
- for (int i = 0; i < keyCount; ++i)
- {
- String* pKey = const_cast<String*>(static_cast<const String*>(pKeyList->GetAt(i)));
- String* pValue = const_cast<String*>(static_cast<const String*>(pDataList->GetValue(*pKey)));
-
- AppLogDebug("(%ls:%ls)", pKey == null ? L"(null)" : pKey->GetPointer(), pValue == null ? L"(null)" : pValue->GetPointer());
- }
- }
- }
-
+ FileListPresentationModel::GetInstance()->ClearProviderId();
AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
if (pAc == null)
{
return E_FAILURE;
}
- result r = pAc->Start(null, null, pDataList, pListener);
+ result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
if (r == E_SUCCESS)
{
}
String
-AlbumListPresentationModel::GetDirectoryName(String& directoryPath)
+AlbumListPresentationModel::GetDirectoryName(String& directoryPath) const
{
AppLogDebug("ENTER");
String directoryName;
- int lastIndex = -1 ;
+ int lastIndex = -1;
directoryPath.LastIndexOf(DIRECTORY_SEPARATOR, directoryPath.GetLength() - 1, lastIndex);
directoryPath.SubString(lastIndex + 1, directoryName);
}
int
-AlbumListPresentationModel::GetFolderCount(void)
+AlbumListPresentationModel::GetFolderCount(void) const
{
AppLogDebug("ENTER");
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
if (__pAlbumInfoList != null)
{
+ AlbumInfo* pInfo = null;
+ for (int i = 0; i < __pAlbumInfoList->GetCount(); ++i)
+ {
+ pInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(i));
+ if (pInfo->GetAlbumName().IsEmpty() == false)
+ {
+ AppLog("Print AlbumName(%d)(%ls)", i, pInfo->GetAlbumName().GetPointer());
+ }
+ }
delete __pAlbumInfoList;
}
__pAlbumInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
if (contentType == CONTENT_TYPE_ALL)
{
- IListT< ContentType >* pListT = new (std::nothrow) ArrayListT<ContentType>();
+ IListT<ContentType>* pListT = new (std::nothrow) ArrayListT<ContentType>();
TryReturnVoid(pListT != null, "Unable to Create ArrayListT");
pListT->Add(CONTENT_TYPE_IMAGE);
pListT->Add(CONTENT_TYPE_VIDEO);
result r = directory.Construct(*pListT);
+ delete pListT;
+
if (r != E_SUCCESS)
{
delete __pAlbumInfoList;
__pAlbumInfoList = null;
- delete pListT;
AppLogDebug("EXIT 1(%s)", GetErrorMessage(r));
return;
}
IList* pContentDirectoryPathList = directory.GetContentDirectoryPathListN(SORT_ORDER_ASCENDING);
String* pDirPath = null;
AlbumInfo* pAlbumInfo = null;
- AlbumInfo* pAllAlbumInfo = new (std::nothrow) AlbumInfo();
- result r = pAllAlbumInfo->Construct();
- if (r != E_SUCCESS)
- {
- delete pContentDirectoryPathList;
- delete pAllAlbumInfo;
- AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
-
- return;
- }
- pAllAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS"));
+ AlbumInfo* pAllAlbumInfo = new (std::nothrow) AlbumInfo();
AlbumInfo* pCameraAlbumInfo = new (std::nothrow) AlbumInfo();
- r = pCameraAlbumInfo->Construct();
- if (r != E_SUCCESS)
- {
- delete pContentDirectoryPathList;
- delete pAllAlbumInfo;
- delete pCameraAlbumInfo;
- AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
+ AlbumInfo* pDownloadAlbumInfo = new (std::nothrow) AlbumInfo();
+ AlbumInfo* pNoNameAlbumInfo = new (std::nothrow) AlbumInfo();
- return;
- }
+ result r = pAllAlbumInfo->Construct();
+ TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
+ pAllAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS"));
+ r = pCameraAlbumInfo->Construct();
+ TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
pCameraAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB"));
- AlbumInfo* pDownloadAlbumInfo = new (std::nothrow) AlbumInfo();
- r = pDownloadAlbumInfo->Construct();
- if (r != E_SUCCESS)
- {
- delete pContentDirectoryPathList;
- delete pAllAlbumInfo;
- delete pCameraAlbumInfo;
- delete pDownloadAlbumInfo;
- AppLogDebug("EXIT 5(%s)", GetErrorMessage(GetLastResult()));
-
- return;
- }
+ r = pDownloadAlbumInfo->Construct();
+ TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
pDownloadAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_COM_BODY_DOWNLOADS"));
- AlbumInfo* pNoNameAlbumInfo = new (std::nothrow) AlbumInfo();
- r = pNoNameAlbumInfo->Construct();
- if (r != E_SUCCESS)
- {
- delete pContentDirectoryPathList;
- delete pAllAlbumInfo;
- delete pCameraAlbumInfo;
- delete pDownloadAlbumInfo;
- delete pNoNameAlbumInfo;
- AppLogDebug("EXIT 6(%s)", GetErrorMessage(GetLastResult()));
-
- return;
- }
+ r = pNoNameAlbumInfo->Construct();
+ TryCatch(IsFailed(r) == E_SUCCESS,,"new pNoNameAlbumInfo is %s",GetErrorMessage(r));
pNoNameAlbumInfo->SetAlbumName(ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME"));
+
if ((pContentDirectoryPathList != null) && (pContentDirectoryPathList->GetCount() > 0))
{
IEnumerator* pEnum = pContentDirectoryPathList->GetEnumeratorN();
while (pEnum->MoveNext() == E_SUCCESS)
{
pDirPath = static_cast<String*>(pEnum->GetCurrent());
+ String mediaPath = RESERVED_MEDIA_PATH;
+ int length = mediaPath.GetLength();
+ mediaPath.Remove(length-1,1);
+
if (pDirPath == null)
{
continue;
}
- if ((*pDirPath == RESERVED_CAMERA_PATH)
- ||(*pDirPath == RESERVED_CAMERA_PATH_EXT))
+ if ((*pDirPath == RESERVED_CAMERA_PATH) ||(*pDirPath == RESERVED_CAMERA_PATH_EXT))
{
IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
pAllAlbumInfo->AppendDirectory(*pDirPath);
pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+ pContentIdList->RemoveAll(true);
delete pContentIdList;
}
}
- else if (*pDirPath == RESERVED_MEDIA_PATH)
+ else if (*pDirPath == mediaPath)
{
IList* pContentIdList = GetContentIdListInDirectoryN(*pDirPath, contentType);
pAllAlbumInfo->AppendDirectory(*pDirPath);
pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+ pContentIdList->RemoveAll(true);
delete pContentIdList;
}
}
pAllAlbumInfo->AppendDirectory(*pDirPath);
pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+ pSubDirList->RemoveAll(true);
delete pSubDirList;
}
- delete pContentIdList;
- }
- }
- if (pAlbumInfo != null && pAlbumInfo->GetContentIdCount() > 0)
- {
- __pAlbumInfoList->Add(pAlbumInfo);
- }
- else
- {
- delete pAlbumInfo;
+ if (pContentIdList != NULL)
+ {
+ pContentIdList->RemoveAll(true);
+ delete pContentIdList;
+ }
+ }
+ if (pAlbumInfo != null && pAlbumInfo->GetContentIdCount() > 0)
+ {
+ __pAlbumInfoList->Add(pAlbumInfo);
+ AppLog("Adding album");
+ }
+ else
+ {
+ delete pAlbumInfo;
+ }
+ pAlbumInfo = null;
}
}
if (pContentDirectoryPathList != null)
{
+ pContentDirectoryPathList->RemoveAll(true);
delete pContentDirectoryPathList;
}
-
+ ClearThumbnailRequests(false);
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+ return;
+
+CATCH:
+if (pContentDirectoryPathList != null)
+{
+ pContentDirectoryPathList->RemoveAll(true);
+ delete pContentDirectoryPathList;
+}
+ delete pAllAlbumInfo;
+ delete pCameraAlbumInfo;
+ delete pDownloadAlbumInfo;
+ delete pNoNameAlbumInfo;
}
String
const String contentDirectoryPath = directoryPath;
if (contentType == CONTENT_TYPE_ALL)
{
- IListT< ContentType >* pListT = new (std::nothrow) ArrayListT<ContentType>();
+ IListT<ContentType>* pListT = new (std::nothrow) ArrayListT<ContentType>();
pListT->Add(CONTENT_TYPE_IMAGE);
pListT->Add(CONTENT_TYPE_VIDEO);
result r = directory.Construct(*pListT);
ContentId* pItem;
while (pEnum->MoveNext() == E_SUCCESS)
{
- ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
+ ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
pItem = new (std::nothrow) ContentId(pContentInfo->GetContentId());
pContentIdList->Add(pItem);
}
delete pEnum;
}
- delete pContentInfoList;
+
+ if (pContentInfoList != NULL)
+ {
+ pContentInfoList->RemoveAll(true);
+ delete pContentInfoList;
+ }
+
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
return pContentIdList;
}
result
-AlbumListPresentationModel::DeleteContentInfoInDirectory(int index, ContentType contentType)
+AlbumListPresentationModel::DeleteContentFile(const ContentId& contentId)
{
AppLogDebug("ENTER");
result r = E_SUCCESS;
- if (__pAlbumInfoList == null)
- {
- AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
-
- return r;
- }
-
- AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(index));
-
- int loopCount = pAlbumInfo->GetDirectoryCount();
- for (int i = 0; i < loopCount; ++i)
+ ContentManager contentManager;
+ r = contentManager.Construct();
+ if (r == E_SUCCESS)
{
- ContentDirectory directory;
- const String contentDirectoryPath = pAlbumInfo->GetDirectory(i);
-
- if (contentType == CONTENT_TYPE_ALL)
- {
- IListT< ContentType >* pListT = new (std::nothrow) ArrayListT<ContentType>();
- pListT->Add(CONTENT_TYPE_IMAGE);
- pListT->Add(CONTENT_TYPE_VIDEO);
- r = directory.Construct(*pListT);
- delete pListT;
- pListT = null;
- }
- else
- {
- r = directory.Construct(contentType);
- }
- if (r != E_SUCCESS)
- {
- continue;
- }
-
- int pageNo = 1;
- int countPerPage = directory.GetContentDirectoryItemCount(contentDirectoryPath);
- IList* pContentInfoList = directory.GetContentDirectoryItemListN(contentDirectoryPath, pageNo,
- countPerPage, CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
- ContentManager contentManager;
- r = contentManager.Construct();
- if (r != E_SUCCESS)
- {
- delete pContentInfoList;
- continue;
- }
-
- if ((pContentInfoList != null) && (pContentInfoList->GetCount() > 0))
- {
- IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
- while (pEnum->MoveNext() == E_SUCCESS || r == E_SUCCESS)
- {
- ContentInfo* pContentInfo = static_cast<ContentInfo*>(pEnum->GetCurrent());
- ContentId contentId = pContentInfo->GetContentId();
- r = contentManager.DeleteContent(contentId);
- }
- delete pEnum;
- pEnum = null;
- }
-
- delete pContentInfoList;
+ r = contentManager.DeleteContent(contentId);
}
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
IList*
-AlbumListPresentationModel::GetAlbumInfoList(void)
+AlbumListPresentationModel::GetAlbumInfoList(void) const
{
AppLogDebug("ENTER");
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
return __pAlbumInfoList;
}
+IList* AlbumListPresentationModel::GetContentIdListAtIndexN(const IList& indexList) const
+{
+ AppLogDebug("ENTER");
+ ContentDirectory directory;
+ IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+
+ IListT<ContentType>* pListT = new (std::nothrow) ArrayListT<ContentType>();
+ TryReturn(pListT != null,null, "Unable to Create ArrayListT");
+ pListT->Add(CONTENT_TYPE_IMAGE);
+ pListT->Add(CONTENT_TYPE_VIDEO);
+
+ result r = directory.Construct(*pListT);
+ delete pListT;
+
+ if (r != E_SUCCESS)
+ {
+ AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
+ delete pContentIdList;
+ return null;
+ }
+
+ if (static_cast<const Integer*>(indexList.GetAt(0))->ToInt() == 0) //if all-album is selected, get all files for delete
+ {
+ IList* pContentDirectoryPathList = directory.GetContentDirectoryPathListN(SORT_ORDER_ASCENDING);
+ String* pDirPath = null;
+ if ((pContentDirectoryPathList != null) && (pContentDirectoryPathList->GetCount() > 0))
+ {
+ int loopCount = pContentDirectoryPathList->GetCount();
+ for (int i = 0; i < loopCount; ++i)
+ {
+ pDirPath = static_cast<String*>(pContentDirectoryPathList->GetAt(i));
+ pContentIdList->AddItems(*(GetContentIdListInDirectoryN(*pDirPath, CONTENT_TYPE_ALL)));
+ }
+ }
+ }
+ else
+ {
+ if(__pAlbumInfoList != null)
+ {
+ int loopCount = indexList.GetCount();
+ AlbumInfo* pInfo = null;
+ for (int i = 0; i < loopCount; ++i)
+ {
+ int index = static_cast<const Integer*>(indexList.GetAt(i))->ToInt();
+ pInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(index));
+
+ if(pInfo != null)
+ {
+ IList* pList = pInfo->GetContentIdListN();
+ if(pList != null)
+ {
+ pContentIdList->AddItems(*pList);
+ }
+ }
+ }
+ }
+ }
+ return pContentIdList;
+}
+
void
AlbumListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
{
}
}
+ delete pThumbnailInfo;
+
if (__pPresentationModelListener->GetCount() > 0)
{
IEnumerator* pEnum = __pPresentationModelListener->GetEnumeratorN();
int loopCount = pUpdateFolderIndex->GetCount();
for (int k = 0; k < loopCount; ++k)
{
- Integer *index = (Integer*)pUpdateFolderIndex->GetAt(k);
- int folderIndex = index->ToInt();
+ Integer *pIndex = (Integer*)pUpdateFolderIndex->GetAt(k);
+ int folderIndex = pIndex->ToInt();
pListener->OnThumbnailDecoded(folderIndex);
}
}
}
void
-AlbumListPresentationModel::RequestThumbnail(const int folderIndex, int pathIndex)
+AlbumListPresentationModel::OnContentCreated(void)
{
- AppLogDebug("ENTER : folderIndex(%d), pathIndex(%d)", folderIndex, pathIndex);
+ AppLogDebug("ENTER");
+ if (__updateProgressStatus == true)
+ {
+ AppLogDebug("EXIT update in application");
+ return;
+ }
+ IFormContentUpdateEventListener* pInterface = null;
+ IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
+ while (pEventEnum->MoveNext() == E_SUCCESS)
+ {
+ pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
+ if (pInterface != null)
+ {
+ pInterface->OnContentUpdated();
+ }
+ }
+ delete pEventEnum;
+ AppLogDebug("EXIT");
+}
- ContentId contentId;
- if (__pAlbumInfoList != null)
+void
+AlbumListPresentationModel::OnContentUpdated(void)
+{
+ AppLogDebug("ENTER");
+ if (__updateProgressStatus == true)
{
- AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(folderIndex));
- contentId = pAlbumInfo->GetContentId(pathIndex);
+ AppLogDebug("EXIT update in application");
+ return;
+ }
+ IFormContentUpdateEventListener* pInterface = null;
+ IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
+ while (pEventEnum->MoveNext() == E_SUCCESS)
+ {
+ pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
+ pInterface->OnContentUpdated();
}
+ delete pEventEnum;
+ AppLogDebug("EXIT");
+}
- __pThumbnailProvider->RequestThumbnail(contentId, __pThumbnailEvent);
+void
+AlbumListPresentationModel::OnContentDeleted(void)
+{
+ AppLogDebug("ENTER");
+ if (__updateProgressStatus == true)
+ {
+ AppLogDebug("EXIT update in application");
+ return;
+ }
+ IFormContentUpdateEventListener* pInterface = null;
+ IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
+ while (pEventEnum->MoveNext() == E_SUCCESS)
+ {
+ pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
+ pInterface->OnContentUpdated();
+ }
+ delete pEventEnum;
+ AppLogDebug("EXIT");
+}
+
+void
+AlbumListPresentationModel::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
+{
+ AppLogDebug("ENTER");
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
+AlbumListPresentationModel::SetUpdateProgressStatus(const bool status)
+{
+ AppLogDebug("ENTER status = %d",status);
+ __updateProgressStatus = status;
AppLogDebug("EXIT");
}
+result
+AlbumListPresentationModel::RotateImage(int index, RotateMode rotateMode)
+{
+ return E_SUCCESS;
+}
+
void
-AlbumListPresentationModel::CancelThumbnailRequest(const int folderIndex)
+AlbumListPresentationModel::RequestThumbnail(const int folderIndex, const int pathIndex)
{
- AppLogDebug("ENTER : folderIndex(%d)", folderIndex);
+ AppLogDebug("ENTER : folderIndex(%d), pathIndex(%d)", folderIndex, pathIndex);
+
+ ContentId contentId;
if (__pAlbumInfoList != null)
{
AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(folderIndex));
- if (pAlbumInfo != null)
- {
- /*
- for (int i = 0; i < loopCount ; ++i)
- {
- contentId = pAlbumInfo->GetContentId(i);
- __pThumbnailProvider->CancelThumbnailRequest(contentId, __pThumbnailEvent);
- }
- */
- }
+ contentId = pAlbumInfo->GetContentId(pathIndex);
}
+
+ __pThumbnailProvider->RequestThumbnail(contentId, __pThumbnailEvent);
AppLogDebug("EXIT");
}
void
-AlbumListPresentationModel::ClearThumbnailRequests(bool appTerminating)
+AlbumListPresentationModel::ClearThumbnailRequests(const bool appTerminating)
{
AppLogDebug("ENTER");
if (__pThumbnailProvider != null)