Code Refactoring
authorravi.n2 <ravi.n2@samsung.com>
Wed, 3 Jul 2013 04:27:07 +0000 (09:57 +0530)
committerravi.n2 <ravi.n2@samsung.com>
Wed, 3 Jul 2013 04:27:07 +0000 (09:57 +0530)
Change-Id: Ie5d04cfdc78b3d5fce1ab81fad8eb9acd3320bcc

inc/CmTypes.h
inc/CmUtility.h
src/CmCameraPresentationModel.cpp
src/CmTypes.cpp
src/CmUtility.cpp

index 726f300..b683849 100644 (file)
@@ -190,6 +190,10 @@ extern const wchar_t* SECTION_CAMCORDER;
 extern const wchar_t* APPCONTROL_DATA_CAMERA;
 extern const wchar_t* APPCONTROL_DATA_CAMCORDER;
 
+extern const wchar_t* STRING_CAMERA_FOLDER_NAME;
+extern const wchar_t* STRING_EXTENSION_JPG;
+extern const wchar_t* STRING_EXTENSION_MP4;
+
 extern const wchar_t* CURRENT_MODE;
 extern const wchar_t* FLASH_MODE_PRIMARY;
 extern const wchar_t* FLASH_MODE_SECONDARY;
index cf47ed9..179c4a8 100644 (file)
 
 #include <FApp.h>
 #include <FBase.h>
+#include <FContent.h>
 #include <FIo.h>
 #include <FSystem.h>
 
+#include "CmTypes.h"
+
 class CmUtility
 {
 public:
+
+       enum CameraMode
+       {
+               CAMERA_MODE_SNAPSHOT = 0,
+               CAMERA_MODE_RECORD,
+       };
+public:
        static long long GetAvailableMemory(void);
+       static result GetDirectoryPath(int storageType, Tizen::Base::String& directoryPath);
+       static result GetFileName(int currentCameraMode, Tizen::Base::String& fileName);
+       static Tizen::Base::String MakeQuerybyContentFileName(const Tizen::Base::String& QueryString);
+       static Tizen::Graphics::Bitmap* CreateThumbnailN(Tizen::Base::String& pFilename,Tizen::Content::ContentType contentType);
 };
 
 #endif /* _CM_UTILITY_H_ */
index d74f2f1..3180300 100644 (file)
@@ -38,9 +38,6 @@ using namespace Tizen::Ui::Controls;
 static const long RECORD_DEFAULT_SEC = 60000;
 static const long SECONDS_PER_MINUTE = 60;
 static const int MAX_FULL_FILE_PATH = 100;
-static const int MAX_CONTENTSEARCH_COUNTPERPAGE = 10;
-static const int DOUBLE_DIGIT_NUMBER_TEN = 10;
-static const int MAX_QUERY_LENGTH = 1024;
 static const bool CAPTURE_NORMAL_MODE = 0;
 static const bool CAPTURE_BURST_MODE = 1;
 static const int MAX_CAMERA_EXPOSURE_VALUE = 8;
@@ -51,13 +48,6 @@ static const int PREVIEW_RESOLOTION_WVGA_HEIGHT = 240;
 static const int SEARCH_PAGE_NO = 1;
 static const long INIT = -1;
 
-static const wchar_t* STRING_CAMERA_FOLDER_NAME = L"Camera";
-static const wchar_t* STRING_EXTENSION_JPG = L".jpg";
-static const wchar_t* STRING_EXTENSION_MP4 = L".mp4";
-static const wchar_t* STRING_ZERO_CHAR = L"0";
-static const wchar_t* STRING_UNDERBAR_CHAR = L"_";
-static const wchar_t* STRING_QUERY_PREFIX = L"ContentFileName LIKE '%";
-static const wchar_t* STRING_QUERY_SUFFIX = L"'";
 static const wchar_t* STRING_SDCARD_MOUNTED_STATE = L"Mounted";
 static const wchar_t* STRING_KEY_STORAGE_PHONE = L"http://tizen.org/runtime/storage.available.internal.media";
 static const wchar_t* STRING_KEY_STORAGE_SDCARD = L"http://tizen.org/runtime/storage.available.external";
@@ -102,283 +92,6 @@ enum CamSetExifOrientationMode
        CAM_SET_EXIF_ORIENTATION_MODE_LANDSCAPE_REVERSE,
 };
 
-result
-GetDirectoryPath(int storageType, Tizen::Base::String& directoryPath)
-{
-       AppLogDebug("ENTER");
-       result r = E_SUCCESS;
-
-       if (storageType == STORAGE_TYPE_MEMORYCARD)
-       {
-               r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMERA_FOLDER);
-               TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
-       }
-       else if (storageType == STORAGE_TYPE_PHONE)
-       {
-               r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
-               TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
-       }
-       else
-       {
-               r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
-               TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
-       }
-
-       AppLogDebug("FilePath %ls", directoryPath.GetPointer());
-       AppLogDebug("EXIT");
-       return r;
-
-CATCH:
-       AppLogDebug("EXIT - CATCH");
-       return r;
-}
-
-result
-GetFileName(int currentCameraMode, Tizen::Base::String& fileName)
-{
-       AppLogDebug("ENTER");
-       result r = E_SUCCESS;
-       DateTime currentDateTime;
-
-       r = SystemTime::GetCurrentTime(currentDateTime);
-       TryCatch(r == E_SUCCESS, , "SystemTime::GetCurrentTime() fail[%s]", GetErrorMessage(r));
-
-       fileName.Clear();
-       r = fileName.Append(currentDateTime.GetYear());
-       TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       if (currentDateTime.GetMonth() < DOUBLE_DIGIT_NUMBER_TEN)
-       {
-               r = fileName.Append(STRING_ZERO_CHAR);
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-               r = fileName.Append(currentDateTime.GetMonth());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-       else
-       {
-               r = fileName.Append(currentDateTime.GetMonth());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-
-       if (currentDateTime.GetDay() < DOUBLE_DIGIT_NUMBER_TEN)
-       {
-               r = fileName.Append(STRING_ZERO_CHAR);
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-
-               r = fileName.Append(currentDateTime.GetDay());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-       else
-       {
-               r = fileName.Append(currentDateTime.GetDay());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-
-       r = fileName.Append(STRING_UNDERBAR_CHAR);
-       TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-
-       if (currentDateTime.GetHour() < DOUBLE_DIGIT_NUMBER_TEN)
-       {
-               r = fileName.Append(STRING_ZERO_CHAR);
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-
-               r = fileName.Append(currentDateTime.GetHour());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-       else
-       {
-               r = fileName.Append(currentDateTime.GetHour());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-
-       if (currentDateTime.GetMinute() < DOUBLE_DIGIT_NUMBER_TEN)
-       {
-               r = fileName.Append(STRING_ZERO_CHAR);
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-
-               r = fileName.Append(currentDateTime.GetMinute());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-       else
-       {
-               r = fileName.Append(currentDateTime.GetMinute());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-
-       if (currentDateTime.GetSecond() < DOUBLE_DIGIT_NUMBER_TEN)
-       {
-               r = fileName.Append(STRING_ZERO_CHAR);
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-
-               r = fileName.Append(currentDateTime.GetSecond());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-       else
-       {
-               r = fileName.Append(currentDateTime.GetSecond());
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-
-       if (currentCameraMode == CameraPresentationModel::CAMERA_MODE_SNAPSHOT)
-       {
-               r = fileName.Append(STRING_EXTENSION_JPG);
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-       else
-       {
-               r = fileName.Append(STRING_EXTENSION_MP4);
-               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
-       }
-
-       AppLogDebug("FileName %ls", fileName.GetPointer());
-       AppLogDebug("EXIT");
-       return r;
-
-CATCH:
-       AppLogDebug("EXIT - CATCH");
-       return r;
-}
-
-Tizen::Base::String
-MakeQuerybyContentFileName(const Tizen::Base::String& QueryString)
-{
-       AppLogDebug("ENTER");
-       String contentNameTypeQuery = L"";
-       String sourceFileName = L"";
-       result r = E_SUCCESS;
-
-       sourceFileName = QueryString;
-
-       AppLogDebug("strTemp %ls", sourceFileName.GetPointer());
-       r = contentNameTypeQuery.SetCapacity(MAX_QUERY_LENGTH);
-       TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
-
-       r = sourceFileName.SetCapacity(MAX_QUERY_LENGTH);
-       TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
-
-       if (!sourceFileName.IsEmpty())
-       {
-               r = contentNameTypeQuery.Append(STRING_QUERY_PREFIX);
-               TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
-
-               r = contentNameTypeQuery.Append(sourceFileName);
-               TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
-
-               r = contentNameTypeQuery.Append(STRING_QUERY_SUFFIX);
-               TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
-       }
-
-       AppLogDebug("strQuery %ls", contentNameTypeQuery.GetPointer());
-       AppLogDebug("EXIT");
-       return contentNameTypeQuery;
-
-CATCH:
-       AppLogDebug("EXIT - CATCH");
-       contentNameTypeQuery.Clear();
-       return contentNameTypeQuery;
-}
-
-Tizen::Graphics::Bitmap*
-CreateThumbnailN(Tizen::Base::String& pFilename, ContentType contentType)
-{
-       AppLogDebug("ENTER");
-       Bitmap* pThumbnailImage = null;
-       ContentSearch contentSearch;
-       IList* pSearchResultList = null;
-       ContentSearchResult* pContentSearchResult = null;
-
-       String strQuery = L"";
-       String sortColumn = L"DateTime";
-       String filePath;
-       int totalPage = 0;
-       int totalCount = 0;
-       int storageType = 0;
-       int page = 1;
-       int contentResultCount = 0;
-       String fullFilePath;
-       result r = E_SUCCESS;
-
-       contentSearch.Construct(contentType);
-       AppLogDebug("pFilename : %ls",pFilename.GetPointer());
-       strQuery = MakeQuerybyContentFileName(pFilename);
-       AppLogDebug("strQuery : %ls",strQuery.GetPointer());
-
-       pSearchResultList = contentSearch.SearchN(page, MAX_CONTENTSEARCH_COUNTPERPAGE, totalPage, totalCount, strQuery, sortColumn, SORT_ORDER_NONE);
-       TryCatch(pSearchResultList != null, r = E_SYSTEM, "pSearchResultList is null");
-
-       AppLogDebug("SearchN Err = %s %d %d", GetErrorMessage(GetLastResult()), totalPage, totalCount);
-
-       if (pSearchResultList != null)
-       {
-               r = CameraPresentationModel::GetInstance()->GetValue(STORAGE_TYPE, storageType);
-
-               if (storageType == STORAGE_TYPE_PHONE)
-               {
-                       filePath = Environment::GetMediaPath();
-               }
-               else
-               {
-                       filePath = Environment::GetExternalStoragePath();
-               }
-
-               filePath.Append(STRING_CAMERA_FOLDER_NAME);
-               filePath.Append("/");
-       }
-
-       if ((pSearchResultList != null) && (pSearchResultList->GetCount() > 0))
-       {
-               for(contentResultCount=0;contentResultCount<pSearchResultList->GetCount();contentResultCount++)
-               {
-                       pContentSearchResult = static_cast<ContentSearchResult*>(pSearchResultList->GetAt(contentResultCount));
-                       TryCatch(pContentSearchResult != null, r = E_SYSTEM, "pContentSearchResult is null");
-                       fullFilePath = pContentSearchResult->GetContentInfo()->GetContentPath();
-                       if (fullFilePath.StartsWith(filePath,0))
-                       {
-                               AppLogDebug("Content Search Result found");
-                               fullFilePath = pContentSearchResult->GetContentInfo()->GetContentPath();
-                               break;
-                       }
-               }
-
-               pThumbnailImage = pContentSearchResult->GetContentInfo()->GetThumbnailN();
-               TryCatch(pThumbnailImage != null, r = E_SYSTEM, "pThumbnailImage is null");
-
-               r = E_SUCCESS;
-       }
-       else
-       {
-               r = E_FAILURE;
-       }
-
-       if (pSearchResultList != null)
-       {
-               pSearchResultList->RemoveAll(true);
-               delete pSearchResultList;
-               pSearchResultList = null;
-       }
-
-       if (r == E_SUCCESS)
-       {
-               AppLogDebug("EXIT");
-               return pThumbnailImage;
-       }
-       else
-       {
-               AppLogDebug("EXIT");
-               return null;
-       }
-
-CATCH:
-       AppLogDebug("EXIT - CATCH");
-       if (pSearchResultList != null)
-       {
-               pSearchResultList->RemoveAll(true);
-               delete pSearchResultList;
-               pSearchResultList = null;
-       }
-
-       return null;
-}
-
 CameraPresentationModel::CameraPresentationModel(void)
        : __pCamera(null)
        , __pPreviewResolutionList(null)
@@ -565,7 +278,7 @@ CameraPresentationModel::CreateThumbnail(int currentCameraMode)
 
        if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
        {
-               __pBitmap = CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
+               __pBitmap = CmUtility::CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
 
                if (latestContentName == L"")
                {
@@ -591,13 +304,13 @@ CameraPresentationModel::CreateThumbnail(int currentCameraMode)
                if (!File::IsFileExist(filePath) || __CurrentVideoFileName.IsEmpty())
                {
                        AppLogDebug("Latest content name is %ls",latestContentName.GetPointer());
-                       __pBitmap = CreateThumbnailN(latestContentName,CONTENT_TYPE_VIDEO);
+                       __pBitmap = CmUtility::CreateThumbnailN(latestContentName,CONTENT_TYPE_VIDEO);
                }
 
                else
                {
                        AppLogDebug("Current content name is %ls",__CurrentVideoFileName.GetPointer());
-                       __pBitmap = CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
+                       __pBitmap = CmUtility::CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
                }
 
                if (latestContentName == L"")
@@ -636,7 +349,7 @@ CameraPresentationModel::IsExistThumbnail(int currentCameraMode)
 
        if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
        {
-               pThumbnailBitmap = CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
+               pThumbnailBitmap = CmUtility::CreateThumbnailN(latestContentName, CONTENT_TYPE_IMAGE);
 
                if (pThumbnailBitmap != null)
                {
@@ -657,7 +370,7 @@ CameraPresentationModel::IsExistThumbnail(int currentCameraMode)
        }
        else
        {
-               pThumbnailBitmap = CreateThumbnailN(latestContentName, CONTENT_TYPE_VIDEO);
+               pThumbnailBitmap = CmUtility::CreateThumbnailN(latestContentName, CONTENT_TYPE_VIDEO);
 
                if (pThumbnailBitmap != null)
                {
@@ -735,10 +448,10 @@ CameraPresentationModel::CreateFileName(Tizen::Base::String& fullFileName)
        pFilePath = new (std::nothrow) String();
        pFileName = new (std::nothrow) String();
 
-       r = GetDirectoryPath(storageType, *pFilePath);
+       r = CmUtility::GetDirectoryPath(storageType, *pFilePath);
        TryCatch(r == E_SUCCESS, , "GetDirectoryPath() fail[%s]", GetErrorMessage(r));
 
-       r = GetFileName(currentCameraMode, *pFileName);
+       r = CmUtility::GetFileName(currentCameraMode, *pFileName);
        TryCatch(r == E_SUCCESS, , "GetFileName() fail[%s]", GetErrorMessage(r));
 
        updatedFileName.Clear();
@@ -3512,7 +3225,7 @@ CameraPresentationModel::OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData,
                                r = GetValue(STORAGE_TYPE, storageType);
                                TryCatch(r == E_SUCCESS, , "GetValue() fail[%s]", GetErrorMessage(r));
 
-                               r = GetDirectoryPath(storageType, FilePath);
+                               r = CmUtility::GetDirectoryPath(storageType, FilePath);
                                TryCatch(r == E_SUCCESS, , "GetDirectoryPath() fail[%s]", GetErrorMessage(r));
 
                                if( File::IsFileExist(FilePath) != true)
@@ -3758,7 +3471,7 @@ CameraPresentationModel::OnVideoRecorderClosed(result r)
                __CurrentVideoFileName.Replace(replaceFilePath,"");
                AppLogDebug("__CurrentVideoFileName path is %ls",__CurrentVideoFileName.GetPointer());
 
-               __pBitmap = CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
+               __pBitmap = CmUtility::CreateThumbnailN(__CurrentVideoFileName,CONTENT_TYPE_VIDEO);
 
                SetAppControlRequestType(APP_CONTROL_REQUEST_TYPE_SUCCEEDED);
 
index a09b504..1339c0a 100644 (file)
@@ -75,6 +75,10 @@ const int MESSAGEBOX_DISPLAY_TIME_3_SEC = 3000;
 
 const int MIN_MEMORY_NEEDED = 1048576;
 
+const wchar_t* STRING_CAMERA_FOLDER_NAME = L"Camera";
+const wchar_t* STRING_EXTENSION_JPG = L".jpg";
+const wchar_t* STRING_EXTENSION_MP4 = L".mp4";
+
 const wchar_t* SECTION_CAMERA = L"CAMERA_SETTING";
 const wchar_t* SECTION_CAMCORDER = L"CAMCORDER_SETTING";
 
index 34a33c0..b03a1df 100644 (file)
  */
 
 #include "CmUtility.h"
+#include "CmCameraPresentationModel.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Content;
+using namespace Tizen::Graphics;
 using namespace Tizen::System;
 
+static const wchar_t* STRING_ZERO_CHAR = L"0";
+static const wchar_t* STRING_UNDERBAR_CHAR = L"_";
+static const wchar_t* STRING_QUERY_PREFIX = L"ContentFileName LIKE '%";
+static const wchar_t* STRING_QUERY_SUFFIX = L"'";
+static const int MAX_CONTENTSEARCH_COUNTPERPAGE = 10;
+static const int DOUBLE_DIGIT_NUMBER_TEN = 10;
+static const int MAX_QUERY_LENGTH = 1024;
+
 long long
 CmUtility::GetAvailableMemory(void)
 {
@@ -42,3 +54,281 @@ CmUtility::GetAvailableMemory(void)
 CATCH:
        return 0;
 }
+
+result
+CmUtility::GetDirectoryPath(int storageType, Tizen::Base::String& directoryPath)
+{
+       AppLogDebug("ENTER");
+       result r = E_SUCCESS;
+
+       if (storageType == STORAGE_TYPE_MEMORYCARD)
+       {
+               r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetExternalStoragePath().GetPointer(), STRING_CAMERA_FOLDER);
+               TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
+       }
+       else if (storageType == STORAGE_TYPE_PHONE)
+       {
+               r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
+               TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
+       }
+       else
+       {
+               r = directoryPath.Format(MAX_DIRECTORY_PATH_LENGTH, L"%ls%ls", Environment::GetMediaPath().GetPointer(), STRING_CAMERA_FOLDER);
+               TryCatch(r == E_SUCCESS, , "String::Format() fail[%s]", GetErrorMessage(r));
+       }
+
+       AppLogDebug("FilePath %ls", directoryPath.GetPointer());
+       AppLogDebug("EXIT");
+       return r;
+
+CATCH:
+       AppLogDebug("EXIT - CATCH");
+       return r;
+}
+
+result
+CmUtility::GetFileName(int currentCameraMode, Tizen::Base::String& fileName)
+{
+       AppLogDebug("ENTER");
+       result r = E_SUCCESS;
+       DateTime currentDateTime;
+
+       r = SystemTime::GetCurrentTime(currentDateTime);
+       TryCatch(r == E_SUCCESS, , "SystemTime::GetCurrentTime() fail[%s]", GetErrorMessage(r));
+
+       fileName.Clear();
+       r = fileName.Append(currentDateTime.GetYear());
+       TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       if (currentDateTime.GetMonth() < DOUBLE_DIGIT_NUMBER_TEN)
+       {
+               r = fileName.Append(STRING_ZERO_CHAR);
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+               r = fileName.Append(currentDateTime.GetMonth());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+       else
+       {
+               r = fileName.Append(currentDateTime.GetMonth());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+
+       if (currentDateTime.GetDay() < DOUBLE_DIGIT_NUMBER_TEN)
+       {
+               r = fileName.Append(STRING_ZERO_CHAR);
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+
+               r = fileName.Append(currentDateTime.GetDay());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+       else
+       {
+               r = fileName.Append(currentDateTime.GetDay());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+
+       r = fileName.Append(STRING_UNDERBAR_CHAR);
+       TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+
+       if (currentDateTime.GetHour() < DOUBLE_DIGIT_NUMBER_TEN)
+       {
+               r = fileName.Append(STRING_ZERO_CHAR);
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+
+               r = fileName.Append(currentDateTime.GetHour());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+       else
+       {
+               r = fileName.Append(currentDateTime.GetHour());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+
+       if (currentDateTime.GetMinute() < DOUBLE_DIGIT_NUMBER_TEN)
+       {
+               r = fileName.Append(STRING_ZERO_CHAR);
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+
+               r = fileName.Append(currentDateTime.GetMinute());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+       else
+       {
+               r = fileName.Append(currentDateTime.GetMinute());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+
+       if (currentDateTime.GetSecond() < DOUBLE_DIGIT_NUMBER_TEN)
+       {
+               r = fileName.Append(STRING_ZERO_CHAR);
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+
+               r = fileName.Append(currentDateTime.GetSecond());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+       else
+       {
+               r = fileName.Append(currentDateTime.GetSecond());
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+
+       if (currentCameraMode == CAMERA_MODE_SNAPSHOT)
+       {
+               r = fileName.Append(STRING_EXTENSION_JPG);
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+       else
+       {
+               r = fileName.Append(STRING_EXTENSION_MP4);
+               TryCatch(r == E_SUCCESS, , "fileName::Append() fail[%s]", GetErrorMessage(r));
+       }
+
+       AppLogDebug("FileName %ls", fileName.GetPointer());
+       AppLogDebug("EXIT");
+       return r;
+
+CATCH:
+       AppLogDebug("EXIT - CATCH");
+       return r;
+}
+
+Tizen::Base::String
+CmUtility::MakeQuerybyContentFileName(const Tizen::Base::String& QueryString)
+{
+       AppLogDebug("ENTER");
+       String contentNameTypeQuery = L"";
+       String sourceFileName = L"";
+       result r = E_SUCCESS;
+
+       sourceFileName = QueryString;
+
+       AppLogDebug("strTemp %ls", sourceFileName.GetPointer());
+       r = contentNameTypeQuery.SetCapacity(MAX_QUERY_LENGTH);
+       TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
+
+       r = sourceFileName.SetCapacity(MAX_QUERY_LENGTH);
+       TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
+
+       if (!sourceFileName.IsEmpty())
+       {
+               r = contentNameTypeQuery.Append(STRING_QUERY_PREFIX);
+               TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
+
+               r = contentNameTypeQuery.Append(sourceFileName);
+               TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
+
+               r = contentNameTypeQuery.Append(STRING_QUERY_SUFFIX);
+               TryCatch(r == E_SUCCESS, , "String::SetCapacity() fail[%s]", GetErrorMessage(r));
+       }
+
+       AppLogDebug("strQuery %ls", contentNameTypeQuery.GetPointer());
+       AppLogDebug("EXIT");
+       return contentNameTypeQuery;
+
+CATCH:
+       AppLogDebug("EXIT - CATCH");
+       contentNameTypeQuery.Clear();
+       return contentNameTypeQuery;
+}
+
+Tizen::Graphics::Bitmap*
+CmUtility::CreateThumbnailN(Tizen::Base::String& pFilename, ContentType contentType)
+{
+       AppLogDebug("ENTER");
+       Bitmap* pThumbnailImage = null;
+       ContentSearch contentSearch;
+       IList* pSearchResultList = null;
+       ContentSearchResult* pContentSearchResult = null;
+
+       String strQuery = L"";
+       String sortColumn = L"DateTime";
+       String filePath;
+       int totalPage = 0;
+       int totalCount = 0;
+       int storageType = 0;
+       int page = 1;
+       int contentResultCount = 0;
+       String fullFilePath;
+       result r = E_SUCCESS;
+
+
+       contentSearch.Construct(contentType);
+       AppLogDebug("pFilename : %ls",pFilename.GetPointer());
+       strQuery = MakeQuerybyContentFileName(pFilename);
+       AppLogDebug("strQuery : %ls",strQuery.GetPointer());
+
+       pSearchResultList = contentSearch.SearchN(page, MAX_CONTENTSEARCH_COUNTPERPAGE, totalPage, totalCount, strQuery, sortColumn, SORT_ORDER_NONE);
+       TryCatch(pSearchResultList != null, r = E_SYSTEM, "pSearchResultList is null");
+
+       AppLogDebug("SearchN Err = %s %d %d", GetErrorMessage(GetLastResult()), totalPage, totalCount);
+
+       if (pSearchResultList != null)
+       {
+               r = CameraPresentationModel::GetInstance()->GetValue(STORAGE_TYPE, storageType);
+
+               if (storageType == STORAGE_TYPE_PHONE)
+               {
+                       filePath = Environment::GetMediaPath();
+               }
+               else
+               {
+                       filePath = Environment::GetExternalStoragePath();
+               }
+
+               filePath.Append(STRING_CAMERA_FOLDER_NAME);
+               filePath.Append("/");
+       }
+
+       if ((pSearchResultList != null) && (pSearchResultList->GetCount() > 0))
+       {
+               for(contentResultCount=0;contentResultCount<pSearchResultList->GetCount();contentResultCount++)
+               {
+                       pContentSearchResult = static_cast<ContentSearchResult*>(pSearchResultList->GetAt(contentResultCount));
+                       TryCatch(pContentSearchResult != null, r = E_SYSTEM, "pContentSearchResult is null");
+                       fullFilePath = pContentSearchResult->GetContentInfo()->GetContentPath();
+                       if (fullFilePath.StartsWith(filePath,0))
+                       {
+                               AppLogDebug("Content Search Result found");
+                               fullFilePath = pContentSearchResult->GetContentInfo()->GetContentPath();
+                               break;
+                       }
+               }
+
+               pThumbnailImage = pContentSearchResult->GetContentInfo()->GetThumbnailN();
+               TryCatch(pThumbnailImage != null, r = E_SYSTEM, "pThumbnailImage is null");
+
+               r = E_SUCCESS;
+       }
+       else
+       {
+               r = E_FAILURE;
+       }
+
+       if (pSearchResultList != null)
+       {
+               pSearchResultList->RemoveAll(true);
+               delete pSearchResultList;
+               pSearchResultList = null;
+       }
+
+       if (r == E_SUCCESS)
+       {
+               AppLogDebug("EXIT");
+               return pThumbnailImage;
+       }
+       else
+       {
+               AppLogDebug("EXIT");
+               return null;
+       }
+
+CATCH:
+       AppLogDebug("EXIT - CATCH");
+       if (pSearchResultList != null)
+       {
+               pSearchResultList->RemoveAll(true);
+               delete pSearchResultList;
+               pSearchResultList = null;
+       }
+
+       return null;
+}