[content] Fix a bug of scan listener
authorSeokpil Park <seokpil.park@samsung.com>
Wed, 10 Apr 2013 08:51:08 +0000 (17:51 +0900)
committerSeokpil Park <seokpil.park@samsung.com>
Wed, 10 Apr 2013 08:51:11 +0000 (17:51 +0900)
Change-Id: Ic10098dbcd1c643062bb1845d28b7b08690d8772
Signed-off-by: Seokpil Park <seokpil.park@samsung.com>
src/FCnt_ContentManagerImpl.cpp

index e04fd20..ebc14ca 100644 (file)
@@ -62,7 +62,6 @@ static const int SYSTEM_TYPE_SOUND = 2;
 static const int SYSTEM_TYPE_MUSIC = 3;
 static const int SYSTEM_TYPE_OTHER = 4;
 static const double DEFAULT_COORDINATE = -200.0;
-static const int SOURCE_PATH_LENGTH = 200;
 
 // For extern declaration in FCntTypes.h
 const wchar_t OSP_HOME[] = L"/Home/";
@@ -108,36 +107,34 @@ ConvertError(int error)
 static void
 OnScanCompleted(media_content_error_e error, void* user_data)
 {
-       ClearLastResult();
-
        SysLog(NID_CNT, "OnScanCompleted callback method is called.");
 
-       if (user_data == null)
-       {
-               SysLog(NID_CNT, "OnScanCompleted failed.");
-               return;
-       }
+       ClearLastResult();
+       result r = E_SUCCESS;
+       String scanPath(L"");
+       IContentScanListener* pListener = null;
+       RequestId reqId;
+       unique_ptr< ScanResult > pScanResult;
 
-       unique_ptr< ScanResult > pScanResult(static_cast< ScanResult* >(user_data));
+       SysTryLogCatch(NID_CNT, user_data != null, , "OnScanCompleted failed.");
 
-       if (pScanResult == null || pScanResult->pScanPath == null || pScanResult->pScanListener == null)
-       {
-               SysLog(NID_CNT, "OnScanCompleted failed.");
-               return;
-       }
+       pScanResult = unique_ptr< ScanResult >(static_cast< ScanResult* >(user_data));
+
+       SysTryLogCatch(NID_CNT, pScanResult != null && pScanResult->pScanPath != null, , "OnScanCompleted failed.");
+       SysTryLogCatch(NID_CNT, pScanResult->pScanListener != null, , "Listener is null. OnScanCompleted succeeded.");
 
-       String scanPath(pScanResult->pScanPath);
-       IContentScanListener* pListener = pScanResult->pScanListener;
-       RequestId reqId = pScanResult->requestId;
+       scanPath = pScanResult->pScanPath;
+       pListener = pScanResult->pScanListener;
+       reqId = pScanResult->requestId;
 
-       result r = ConvertError(error);
+       r = ConvertError(error);
 
        pListener->OnContentScanCompleted(reqId, scanPath, r);
+       SysLog(NID_CNT, "OnContentScanCompleted fired.");
 
+CATCH:
        int val = media_content_disconnect();
        SysTryLog(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, "The disconnection failed[%d].", val);
-
-       SysLog(NID_CNT, "Fire the OnContentScanCompleted method.");
 }
 
 static void
@@ -915,8 +912,6 @@ _ContentManagerImpl::ScanDirectory(const Tizen::Base::String& directoryPath, boo
 
        SysLog(NID_CNT, "The scan path is [%ls].", directoryPath.GetPointer());
 
-       SysTryReturnResult(NID_CNT, pListener != null, E_INVALID_ARG, "Failed to ScanDirectory method.");
-
        unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(directoryPath));
        SysTryReturnResult(NID_CNT, (pDirPath.get())[0] != null, E_SYSTEM, "pDirPath is NULL.");