Fix AppControl spec
[apps/osp/Gallery.git] / src / GlFileListPresentationModel.cpp
index 7ae73b0..d668e4f 100644 (file)
@@ -24,6 +24,7 @@
 #include <FSystem.h>
 #include "GlCommonUtil.h"
 #include "GlFileListPresentationModel.h"
+#include "GlContentUpdateEventListener.h"
 #include "GlGalleryApp.h"
 #include "GlThumbnailEvent.h"
 #include "GlThumbnailEventArg.h"
@@ -48,22 +49,22 @@ static const int SIZE_CONUNT_PER_PAGE = 3000;
 static const int SIZE_ICON_LIST_CACHE = 50;
 static const int W_DURATION_TEXT = 44;
 static const int H_DURATION_TEXT = 4;
-static const int W_DURATION = 158;
-static const int H_DURATION = 38;
-static const int W_DEFAULT_THUMBNAIL = 158;
-static const int H_DEFAULT_THUMBNAIL = 158;
-static const int W_WIDE_THUMBNAIL = 172;
-static const int H_WIDE_THUMBNAIL = 128;
+static const int W_DURATION = 171;
+static const int H_DURATION = 32;
+static const int W_DEFAULT_THUMBNAIL = 171;
+static const int H_DEFAULT_THUMBNAIL = 127;
+static const int W_WIDE_THUMBNAIL = 171;
+static const int H_WIDE_THUMBNAIL = 127;
 static const int W_PLAY_FG = 64;
 static const int H_PLAY_FG = 64;
-static const int GAP_W_PLAY_FG = 47;
-static const int GAP_H_PLAY_FG = 27;
-static const int GAP_H_DURATION = 27+64+28;
+static const int GAP_W_PLAY_FG = (W_DEFAULT_THUMBNAIL -W_PLAY_FG)/2 ;
+static const int GAP_H_PLAY_FG = (H_DEFAULT_THUMBNAIL - H_PLAY_FG)/2;
+static const int GAP_H_DURATION = H_DEFAULT_THUMBNAIL - H_DURATION;
 static const int ALPHA_DURATION = 70;
-static const int FONT_SIZE_DURATION = 28;
-static const Dimension DIMENSION_REAL_ICON (162,164);
-static const Rectangle RECTANGLE_THUMBNAIL_OFFSET_POSION (1, 1, 156, 158);
-static const Rectangle RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION (1, 1, 168, 124);
+static const int FONT_SIZE_DURATION = 24;
+static const Dimension DIMENSION_REAL_ICON (171,127);
+static const Rectangle RECTANGLE_THUMBNAIL_OFFSET_POSION (1, 1, 171, 127);
+static const Rectangle RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION (1, 1, 171, 127);
 static const Color COLOR_DURATION_BG (Color::GetColor(COLOR_ID_BLACK));
 static const Color COLOR_TEXT_OUTLINE (Color::GetColor(COLOR_ID_WHITE));
 
@@ -75,15 +76,16 @@ FileListPresentationModel* FileListPresentationModel::__pPresentationModelInstan
 ThumbnailProvider* FileListPresentationModel::__pThumbnailProvider = null;
 ThumbnailEvent* FileListPresentationModel::__pThumbnailEvent = null;
 ArrayList* FileListPresentationModel::__pPresentationModelListener = null;
+ArrayList* FileListPresentationModel::__pContentEventListener = null;
 ArrayList* FileListPresentationModel::__pIconListViewCache = null;
 IList* FileListPresentationModel::__pDirectoryList = null;
 IList* FileListPresentationModel::__pContentInfoList = null;
 
 FileListPresentationModel::FileListPresentationModel(void)
-       :__albumContentType(CONTENT_TYPE_ALL)
-       ,__appControlMode(APP_CONTROL_MODE_MAIN)
-       ,__appControlMediaType(APPCONTROL_MEDIA_TYPE_UNKNOWN)
-       ,__appControlSelectionMode(APPCONTROL_SELECTION_MODE_UNKNOWN)
+       : __albumContentType(CONTENT_TYPE_ALL)
+       , __appControlMode(APP_CONTROL_MODE_MAIN)
+       , __appControlMediaType(APPCONTROL_MEDIA_TYPE_IMAGE)
+       , __appControlSelectionMode(APPCONTROL_SELECTION_MODE_SINGLE)
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -117,6 +119,10 @@ FileListPresentationModel::Construct(void)
        __pThumbnailEvent = new (std::nothrow) ThumbnailEvent();
        __pThumbnailEvent->AddListener(*pThumbnailEventListener, true);
 
+       ContentUpdateEventListener::GetInstance();
+       __pContentManager = new (std::nothrow) ContentManager();
+       __pContentManager->Construct();
+
        if (__pIconListViewCache != null)
        {
                delete __pIconListViewCache;
@@ -139,6 +145,9 @@ FileListPresentationModel::Construct(void)
        __pPresentationModelListener = new (std::nothrow) ArrayList();
        __pPresentationModelListener->Construct();
 
+       __pContentEventListener = new (std::nothrow) ArrayList();
+       __pContentEventListener->Construct();
+
        __pThumbnailProvider = ThumbnailProvider::GetInstance();
 
        GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
@@ -156,31 +165,23 @@ FileListPresentationModel::Construct(void)
                if (pArguments != null)
                {
                        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)
+                       if (pApp->GetMimeType().StartsWith(APPCONTROL_DATA_VIDEO, 0) == 0)
                        {
                                __appControlMediaType = APPCONTROL_MEDIA_TYPE_VIDEO;
                        }
-                       else
-                       {
-                               __appControlMediaType = APPCONTROL_MEDIA_TYPE_IMAGE;
-                       }
 
                        if (selectionMode != null && selectionMode->CompareTo(APPCONTROL_DATA_MULTIPLE) == 0)
                        {
                                __appControlSelectionMode = APPCONTROL_SELECTION_MODE_MULTIPLE;
                        }
-                       else
-                       {
-                               __appControlSelectionMode = APPCONTROL_SELECTION_MODE_SINGLE;
-                       }
                }
        }
        else if (operationId.CompareTo(APPCONTROL_OPERATION_ID_CONFIGURE) == 0)
        {
                __appControlMode = APP_CONTROL_MODE_SETTING;
        }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -237,6 +238,12 @@ FileListPresentationModel::DestroyInstance(void)
                __pPresentationModelListener = null;
        }
 
+       if (__pContentEventListener != null)
+       {
+               delete __pContentEventListener;
+               __pContentEventListener = null;
+       }
+
        delete __pPresentationModelInstance;
        __pPresentationModelInstance = null;
 
@@ -328,7 +335,6 @@ FileListPresentationModel::IsContainContentInDirectory(const String& directoryPa
        if (pContentTypeList != null)
        {
                delete pContentTypeList;
-               pContentTypeList = null;
        }
        TryReturn(r == E_SUCCESS, false, "[%s] Unable to construct ContentDirectory", GetErrorMessage(r));
 
@@ -336,7 +342,8 @@ FileListPresentationModel::IsContainContentInDirectory(const String& directoryPa
        int pageNo = SIZE_PAGE_NO;
        int countPerPage = SIZE_CONUNT_PER_PAGE;
 
-       IList* pContentList = contentDirectory.GetContentDirectoryItemListN(directoryPath, pageNo, countPerPage, CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
+       IList* pContentList = contentDirectory.GetContentDirectoryItemListN(directoryPath, pageNo, countPerPage,
+                       CONTENT_INFO_ORDER, SORT_ORDER_ASCENDING);
 
        if (pContentList == null || pContentList->GetCount() <= 0)
        {
@@ -350,7 +357,6 @@ FileListPresentationModel::IsContainContentInDirectory(const String& directoryPa
        if (pContentList != null)
        {
                delete pContentList;
-               pContentList = null;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -394,7 +400,6 @@ FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pN
                {
                        pDstBitmap = CoverVideoOverlayedImageOnThumbnailN(*pOrgBitmap, *pThumbnailInfo);
                        delete pOrgBitmap;
-                       pOrgBitmap = null;
                }
        }
        else
@@ -407,15 +412,13 @@ FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pN
                Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
                Rectangle thumbnailRect(RECTANGLE_THUMBNAIL_OFFSET_POSION);
                pDstBitmap->Scale(Dimension(RECTANGLE_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_THUMBNAIL_OFFSET_POSION.x
-                                                                       , RECTANGLE_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_THUMBNAIL_OFFSET_POSION.y));
+                               , RECTANGLE_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_THUMBNAIL_OFFSET_POSION.y));
                if (pThumbnailBgBitmap != null)
                {
                        pThumbnailBgBitmap->Scale(DIMENSION_REAL_ICON);
                        pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pDstBitmap, thumbnailRect);
                        delete pThumbnailBgBitmap;
-                       pThumbnailBgBitmap = null;
                        delete pDstBitmap;
-                       pDstBitmap = null;
                }
                else
                {
@@ -430,7 +433,6 @@ FileListPresentationModel::GetThumbnailInSyncCacheN(const int index, String*& pN
        if (pThumbnailInfo != null)
        {
                delete pThumbnailInfo;
-               pThumbnailInfo = null;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -477,16 +479,14 @@ FileListPresentationModel::GetThumbnailVideoInSyncCacheN(const int index, String
                Bitmap* pThumbnailBgBitmap = ResourceManager::GetBitmapN(IDB_VIDEOTHUMBNAIL_BG);
                Rectangle thumbnailRect(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION);
                pOrgBitmap->Scale(Dimension(RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.width - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.x
-                                                                       , RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.y));
+                               , RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.height - RECTANGLE_VIDEO_THUMBNAIL_OFFSET_POSION.y));
                if (pThumbnailBgBitmap != null)
                {
                        pThumbnailBgBitmap->Scale(Dimension(W_WIDE_THUMBNAIL, H_WIDE_THUMBNAIL));
                        pThumbnail = GetShadedBackgroundBitmapN(*pThumbnailBgBitmap, *pOrgBitmap, thumbnailRect);
                        delete pThumbnailBgBitmap;
-                       pThumbnailBgBitmap = null;
                }
                delete pOrgBitmap;
-               pOrgBitmap = null;
        }
        else
        {
@@ -501,7 +501,6 @@ FileListPresentationModel::GetThumbnailVideoInSyncCacheN(const int index, String
        if (pThumbnailInfo != null)
        {
                delete pThumbnailInfo;
-               pThumbnailInfo = null;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -530,7 +529,7 @@ FileListPresentationModel::RequestThumbnail(const int index)
                return;
        }
 
-        __pThumbnailProvider->RequestThumbnail(pContentInfo->GetContentId(), __pThumbnailEvent);
+       __pThumbnailProvider->RequestThumbnail(pContentInfo->GetContentId(), __pThumbnailEvent);
        AppLogDebug("EXIT");
 }
 
@@ -538,7 +537,7 @@ void
 FileListPresentationModel::CancelThumbnailRequest(const int index)
 {
        AppLogDebug("ENTER : index(%d)", index);
-       ContentInfo* pContentInfo = null;
+       /*ContentInfo* pContentInfo = null;
 
        if (__pContentInfoList != null && index < __pContentInfoList->GetCount())
        {
@@ -548,8 +547,8 @@ FileListPresentationModel::CancelThumbnailRequest(const int index)
                        AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
                        return;
                }
-                __pThumbnailProvider->CancelThumbnailRequest(pContentInfo->GetContentId(), __pThumbnailEvent);
-       }
+               __pThumbnailProvider->CancelThumbnailRequest(pContentInfo->GetContentId(), __pThumbnailEvent);
+       }*/
        AppLogDebug("EXIT");
 }
 
@@ -560,7 +559,7 @@ FileListPresentationModel::ClearThumbnailRequests(bool appTerminating)
 
        if (__pThumbnailProvider != null)
        {
-                __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
+               __pThumbnailProvider->ClearThumbnailRequests(appTerminating);
        }
 
        AppLogDebug("EXIT");
@@ -609,7 +608,6 @@ FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
                                        pTempThumbnailInfo->SetContentType(pThumbnailInfo->GetContentType());
                                        pTempThumbnailInfo->SetDuration(pThumbnailInfo->GetDuration());
                                        delete pThumbnailInfo;
-                                       pThumbnailInfo = null;
                                        isMatch = true;
                                        break;
                                }
@@ -621,7 +619,8 @@ FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
                                {
                                        __pIconListViewCache->RemoveAt(0, true);
                                }
-                               AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)",__pIconListViewCache->GetCount(), pThumbnailInfo->GetFilePath().GetPointer());
+                               AppLogDebug("[CHASEFIRE] (all:%d) Add Thumbail(%ls)",__pIconListViewCache->GetCount(),
+                                               pThumbnailInfo->GetFilePath().GetPointer());
                                __pIconListViewCache->Add(pThumbnailInfo);
                        }
                }
@@ -645,12 +644,71 @@ FileListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
                        pInterface->OnThumbnailDecoded(index);
                }
                delete pEventEnum;
-               pEventEnum = null;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
 void
+FileListPresentationModel::OnContentCreated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
+{
+       AppLogDebug("ENTER");
+       IFormContentUpdateEventListener* pInterface = null;
+       if (__pContentEventListener == null)
+       {
+               AppLogDebug("EXIT");
+               return;
+       }
+       IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
+       while (pEventEnum->MoveNext() == E_SUCCESS)
+       {
+               pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
+               pInterface->OnContentUpdated();
+       }
+       delete pEventEnum;
+       AppLogDebug("EXIT");
+}
+
+void
+FileListPresentationModel::OnContentUpdated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
+{
+       AppLogDebug("ENTER");
+       IFormContentUpdateEventListener* pInterface = null;
+       if (__pContentEventListener == null)
+       {
+               AppLogDebug("EXIT");
+               return;
+       }
+       IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
+       while (pEventEnum->MoveNext() == E_SUCCESS)
+       {
+               pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
+               pInterface->OnContentUpdated();
+       }
+       delete pEventEnum;
+       AppLogDebug("EXIT");
+}
+
+void
+FileListPresentationModel::OnContentDeleted(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
+{
+       AppLogDebug("ENTER");
+       IFormContentUpdateEventListener* pInterface = null;
+       if (__pContentEventListener == null)
+       {
+               AppLogDebug("EXIT");
+               return;
+       }
+       IEnumerator* pEventEnum = __pContentEventListener->GetEnumeratorN();
+       while (pEventEnum->MoveNext() == E_SUCCESS)
+       {
+               pInterface = static_cast<IFormContentUpdateEventListener*>(pEventEnum->GetCurrent());
+               pInterface->OnContentUpdated();
+       }
+       delete pEventEnum;
+       AppLogDebug("EXIT");
+}
+
+void
 FileListPresentationModel::AddPresentationModelListener(const IAlbumEventListener* listener)
 {
        AppLogDebug("ENTER");
@@ -666,6 +724,26 @@ FileListPresentationModel::RemovePresentationModelListener(const IAlbumEventList
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
+void
+FileListPresentationModel::AddContentEventListener(const IFormContentUpdateEventListener* listener)
+{
+       AppLogDebug("ENTER");
+       if (__pContentEventListener != null)
+       {
+               __pContentEventListener->RemoveAll();
+               __pContentEventListener->Add((Object*)listener);
+               AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+       }
+}
+
+void
+FileListPresentationModel::RemoveContentEventListener(const IFormContentUpdateEventListener* listener)
+{
+       AppLogDebug("ENTER");
+       __pContentEventListener->Remove(*listener);
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
 ThumbnailInfo*
 FileListPresentationModel::GetThumbnailInfoFromInternalBufferN(const ContentId& contentId) const
 {
@@ -715,7 +793,8 @@ FileListPresentationModel::DeleteContentFileList(const IList& contentIndexList)
 
                if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
                {
-                       pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
+                       pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>
+                                       (__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
                }
        }
 
@@ -737,7 +816,8 @@ IList*
 FileListPresentationModel::GetCollisionIndexListN(const IList& contentIndexList, const String& destDirectory)
 {
        AppLogDebug("ENTER");
-       if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null || destDirectory.IsEmpty() == true)
+       if (&contentIndexList == null || contentIndexList.GetCount() <= 0 || &destDirectory == null
+                       || destDirectory.IsEmpty() == true)
        {
                AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
 
@@ -805,7 +885,8 @@ FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList,
                Directory::Create(destDirectory, true);
        }
 
-       IList * pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+       delete __pContentIdList;
+       __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
        int loopCount = contentIndexList.GetCount();
        for (int i = 0; i < loopCount; ++i)
        {
@@ -813,19 +894,11 @@ FileListPresentationModel::MoveToContentFileList(const IList& contentIndexList,
 
                if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
                {
-                       pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
+                       __pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
                }
        }
 
-       loopCount = pContentIdList->GetCount();
-       for (int i = 0; i < loopCount; ++i)
-       {
-               ContentId* pContentId = static_cast<ContentId*>(pContentIdList->GetAt(i));
-               if (pContentId != null)
-               {
-                       MoveToContentFile(*pContentId, destDirectory);
-               }
-       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -841,12 +914,8 @@ FileListPresentationModel::DeleteContentFile(const ContentId& contentId)
 
                return E_SUCCESS;
        }
-       ContentManager contentManager;
-       result r = contentManager.Construct();
-       if (r == E_SUCCESS)
-       {
-               r = contentManager.DeleteContent(contentId);
-       }
+       result r = __pContentManager->DeleteContent(contentId);
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return r;
@@ -861,129 +930,103 @@ FileListPresentationModel::MoveToContentFile(const ContentId& contentId, const S
                AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
                return E_FAILURE;
        }
-
-       ContentManager contentManager;
-       result r = contentManager.Construct();
-       if (r == E_SUCCESS)
+       result r = E_SUCCESS;
+       ContentInfo* pContentInfo = __pContentManager->GetContentInfoN(contentId);
+       if (pContentInfo == null)
        {
-               ContentInfo* pContentInfo = contentManager.GetContentInfoN(contentId);
-               if (pContentInfo == null)
-               {
-                       AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
-                       return E_FAILURE;
-               }
-
-               String filePath = pContentInfo->GetContentPath();
-               if (filePath.GetLength() < 4)
-               {
-                       AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
-
-                       return E_SUCCESS;
-               }
-
-               String destPath;
-               if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
-               {
-                       destPath.Append(destDirectory);
-                       destPath.Append(GetFileNameFromFullPath(filePath, true));
-               }
-               else
-               {
-                       destPath.Append(destDirectory);
-                       destPath.Append(DIRECTORY_SEPARATOR);
-                       destPath.Append(GetFileNameFromFullPath(filePath, true));
-               }
+               AppLogDebug("Santhosh %s", destDirectory.GetPointer());
+               AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
+               return E_FAILURE;
+       }
 
-               if (destPath.CompareTo(filePath) == 0)
-               {
-                       AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
+       String filePath = pContentInfo->GetContentPath();
+       if (filePath.GetLength() < 4)
+       {
+               AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
+               return E_SUCCESS;
+       }
 
-                       return E_SUCCESS;
-               }
+       String destPath;
+       if (destDirectory.EndsWith(DIRECTORY_SEPARATOR) == true)
+       {
+               destPath.Append(destDirectory);
+               destPath.Append(GetFileNameFromFullPath(filePath, true));
+       }
+       else
+       {
+               destPath.Append(destDirectory);
+               destPath.Append(DIRECTORY_SEPARATOR);
+               destPath.Append(GetFileNameFromFullPath(filePath, true));
+       }
 
-               if (File::IsFileExist(destPath) == true)
-               {
-                       File::Remove(destPath);
-               }
+       if (destPath.CompareTo(filePath) == 0)
+       {
+               AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
+               return E_SUCCESS;
+       }
 
-               result r = E_SUCCESS;
+       if (File::IsFileExist(destPath) == true)
+       {
+               File::Remove(destPath);
+       }
 
-               if (pContentInfo->GetContentType() == CONTENT_TYPE_IMAGE)
+       if (pContentInfo->GetContentType() == CONTENT_TYPE_IMAGE)
+       {
+               r = File::Copy(filePath, destPath, false);
+               if (r == E_SUCCESS)
                {
-
-                       r = File::Copy(filePath, destPath, false);
                        if (r == E_SUCCESS)
                        {
-                               ContentManager cntManager;
-                               result rt = cntManager.Construct();
-                               if (rt == E_SUCCESS)
+                               ImageContentInfo contentInfo;
+                               r = contentInfo.Construct(&destPath);
+                               if (r == E_SUCCESS)
                                {
-                                       ImageContentInfo contentInfo;
-                                       rt = contentInfo.Construct(&destPath);
-                                       if (rt == E_SUCCESS)
-                                       {
-                                               cntManager.CreateContent(contentInfo);
-                                               cntManager.DeleteContent(contentId);
-                                       }
+                                       __pContentManager->CreateContent(contentInfo);
+                                       r = GetLastResult();
+                                       TryCatch(!IsFailed(r),,"CreateContent::the value is %s",GetErrorMessage(r));
+                                       r = __pContentManager->DeleteContent(contentId);
+                                       TryCatch(!IsFailed(r),,"DeleteContent::the value is %s",GetErrorMessage(r));
                                }
                        }
                }
-               else if (pContentInfo->GetContentType() == CONTENT_TYPE_VIDEO)
+       }
+       else if (pContentInfo->GetContentType() == CONTENT_TYPE_VIDEO)
+       {
+               r = File::Copy(filePath, destPath, false);
+               if (r == E_SUCCESS)
                {
-                       r = File::Copy(filePath, destPath, false);
-
-                       if (r == E_SUCCESS)
+                       VideoContentInfo contentInfo;
+                       r = contentInfo.Construct(&destPath);
                        {
-                               ContentManager cntManager;
-                               result rt = cntManager.Construct();
-                               if (rt == E_SUCCESS)
-                               {
-                                       VideoContentInfo contentInfo;
-                                       rt = contentInfo.Construct(&destPath);
-                                       {
-                                               cntManager.CreateContent(contentInfo);
-                                               cntManager.DeleteContent(contentId);
-                                       }
-                               }
+                               __pContentManager->CreateContent(contentInfo);
+                               r = GetLastResult();
+                               TryCatch(!IsFailed(r),,"CreateContent::the value is %s",GetErrorMessage(r));
+                               r = __pContentManager->DeleteContent(contentId);
+                               TryCatch(!IsFailed(r),,"DeleteContent::the value is %s",GetErrorMessage(r));
                        }
                }
-               delete pContentInfo;
-               pContentInfo = null;
        }
+       CATCH:
+       delete pContentInfo;
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return r;
 }
 
 result
-FileListPresentationModel::StartAppControl( const String& providerId, const String& operationId,
-                                                                       const IMap* pDataList, IAppControlResponseListener* pListener)
+FileListPresentationModel::StartAppControl(const String& providerId, const String& operationId,
+               const String* pUriData, const Tizen::Base::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());
-                       }
-               }
-       }
        AppControl* pAc = AppManager::FindAppControlN(providerId, operationId);
        if (pAc == null)
        {
                AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
-
                return E_FAILURE;
        }
-       result r = pAc->Start(null, null, pDataList, pListener);
+       result r = pAc->Start(pUriData, pMimeType, pDataList, pListener);
 
        if (r == E_SUCCESS)
        {
@@ -1054,7 +1097,8 @@ FileListPresentationModel::SetCurrentAlbumInfo(const String& albumName, const IL
        int loopCount = directoryList.GetCount();
        for (int i = 0; i < loopCount; ++i)
        {
-               __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>(static_cast<const String*>(directoryList.GetAt(i))))));
+               __pDirectoryList->Add(new (std::nothrow) String(*(const_cast<String*>
+                       (static_cast<const String*>(directoryList.GetAt(i))))));
        }
 
        if (__pContentInfoList != null)
@@ -1114,6 +1158,7 @@ FileListPresentationModel::RefreshContentInfoList(ContentType contentType)
        if (__pContentInfoList != null)
        {
                delete __pContentInfoList;
+               __pContentInfoList = null;
        }
        __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -1233,6 +1278,24 @@ FileListPresentationModel::GetContentInfo(int index)
        return pContentInfo;
 }
 
+
+IList* FileListPresentationModel::GetContentIdListN(const IList& contentInfoList)
+{
+       IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+       int loopCount = contentInfoList.GetCount();
+       for (int i = 0; i < loopCount; ++i)
+       {
+               const Integer* pIndex = static_cast<const Integer*>(contentInfoList.GetAt(i));
+
+               if ((pIndex != null) && (pIndex->ToInt())>=0 && __pContentInfoList->GetCount() > pIndex->ToInt())
+               {
+                       pContentIdList->Add(new (std::nothrow) ContentId((static_cast<ContentInfo*>(__pContentInfoList->GetAt(pIndex->ToInt())))->GetContentId()));
+               }
+       }
+
+       return pContentIdList;
+}
+
 int
 FileListPresentationModel::GetCurrentAlbumContentInfoCount(void)
 {
@@ -1299,7 +1362,7 @@ FileListPresentationModel::GetContentFilePath(int index)
 
 Bitmap*
 FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnail,
-                                                                                                                                       const ThumbnailInfo& thumbmailInfo)
+               const ThumbnailInfo& thumbmailInfo)
 {
        AppLogDebug("ENTER");
        Bitmap* overlayedImage = null;
@@ -1329,7 +1392,6 @@ FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnai
                {
                        mainCanvas.DrawBitmap(playRect, *playBitmap);
                        delete playBitmap;
-                       playBitmap = null;
                }
 
                Canvas durCanvas;
@@ -1357,8 +1419,8 @@ FileListPresentationModel::CoverVideoOverlayedImageOnThumbnailN(Bitmap& thumbnai
 
 Bitmap*
 FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
-                                                                                       const Bitmap& orgBitmap,
-                                                                                       const Rectangle& orgBitmapPosition)
+               const Bitmap& orgBitmap,
+               const Rectangle& orgBitmapPosition)
 {
        AppLogDebug("ENTER");
        if (&orgBitmap == null || &orgBitmap == null)
@@ -1385,7 +1447,7 @@ FileListPresentationModel::GetShadedBackgroundBitmapN(Bitmap& bgBitmap,
 
 IList*
 FileListPresentationModel::GetContentInfoListInDirectoryListN(const IList& contentDirectoryList,
-                                                                                                                       ContentType contentType)const
+               ContentType contentType)const
 {
        AppLogDebug("ENTER");
        IList* pContentList = new (std::nothrow) ArrayList(SingleObjectDeleter);