Update the check-routine
authorSunwook Bae <sunwook45.bae@samsung.com>
Thu, 21 Mar 2013 02:31:38 +0000 (11:31 +0900)
committerSunwook Bae <sunwook45.bae@samsung.com>
Thu, 21 Mar 2013 02:31:38 +0000 (11:31 +0900)
Change-Id: I33f3517c239074ff24dfce4489ea6103ec13783b
Signed-off-by: Sunwook Bae <sunwook45.bae@samsung.com>
src/FCnt_DownloadManagerImpl.cpp
src/inc/FCnt_DownloadManagerImpl.h

index 5a90762..5259269 100644 (file)
@@ -446,20 +446,11 @@ _DownloadManagerImpl::Pause(RequestId reqId)
        int ret = 0;
        int state = STATE_NONE;
 
-       // Get the current state
-       state = GetState(reqId);
-       SysTryReturnResult(NID_CNT, state != STATE_NONE, E_INVALID_ARG, "There is no download request for the request ID.");
-
-       // Check the pre-state
-       r = CheckPrestate(DOWNLOAD_OPERATION_PAUSE, state);
-       if(IsFailed(r))
-       {
-               SysPropagate(NID_CNT, r);
-               return r;
-       }
-
        // Pause the download request
        ret = download_pause((int)reqId);
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_PARAMETER, E_INVALID_ARG, "There is no download request for the request.");
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_ID_NOT_FOUND, E_INVALID_ARG, "The request ID is not valid.");
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_STATE, E_INVALID_OPERATION, "The current download state is not downloading.");
        SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret);
 
        return E_SUCCESS;
@@ -473,20 +464,11 @@ _DownloadManagerImpl::Resume(RequestId reqId)
        int ret = 0;
        int state = STATE_NONE;
 
-       // Get the current state
-       state = GetState(reqId);
-       SysTryReturnResult(NID_CNT, state != STATE_NONE, E_INVALID_ARG, "There is no download request for the request ID.");
-
-       // Check the pre-state
-       r = CheckPrestate(DOWNLOAD_OPERATION_RESUME, state);
-       if(IsFailed(r))
-       {
-               SysPropagate(NID_CNT, r);
-               return r;
-       }
-
        // Resume the download request
        ret = download_start((int)reqId);
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_PARAMETER, E_INVALID_ARG, "There is no download request for the request.");
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_ID_NOT_FOUND, E_INVALID_ARG, "The request ID is not valid.");
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_STATE, E_INVALID_OPERATION, "The current download state is not paused or has failed.");
        SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret);
 
        return E_SUCCESS;
@@ -498,12 +480,10 @@ _DownloadManagerImpl::Cancel(RequestId reqId)
        int ret = 0;
        int state = STATE_NONE;
 
-       // Get the current state
-       state = GetState(reqId);
-       SysTryReturnResult(NID_CNT, state != STATE_NONE, E_INVALID_ARG, "There is no download request for the request ID.");
-
        // Stop the download request
        ret = download_cancel((int)reqId);
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_PARAMETER, E_INVALID_ARG, "There is no download request for the request.");
+       SysTryReturnResult(NID_CNT, ret != DOWNLOAD_ERROR_ID_NOT_FOUND, E_INVALID_ARG, "The request ID is not valid.");
        SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret);
 
        return E_SUCCESS;
@@ -646,35 +626,6 @@ _DownloadManagerImpl::SetDownloadListener(IDownloadListener* pListener)
        }
 }
 
-result
-_DownloadManagerImpl::CheckPrestate(DownloadOperation operation, int current)
-{
-       SysLog(NID_CNT, "Operation: %d, Current state: %d", operation, current);
-
-       switch(operation)
-       {
-               case DOWNLOAD_OPERATION_PAUSE:
-                       // Check the pre-state: downloading
-                       SysTryReturnResult(NID_CNT, current == STATE_DOWNLOADING, E_INVALID_OPERATION,
-                       "The current download state is not STATE_DOWNLOADING.");
-                       break;
-
-               case DOWNLOAD_OPERATION_RESUME:
-                       // Check the pre-state: paused / failed
-                       SysTryReturnResult(NID_CNT, !(current != STATE_PAUSED && current != STATE_FAILED), E_INVALID_OPERATION,
-                       "The current download state is not STATE_PAUSED or STATE_FAILED.");
-                       break;
-
-               case DOWNLOAD_OPERATION_CANCEL:
-                       break;
-
-               default:
-                       break;
-       }
-
-       return E_SUCCESS;
-}
-
 void
 _DownloadManagerImpl::DestroyResources(RequestId reqId)
 {
index a52ac73..a38414f 100644 (file)
@@ -87,16 +87,6 @@ private:
        static void InitSingleton(void);
        static void DestroySingleton(void);
 
-       enum DownloadOperation
-       {
-               DOWNLOAD_OPERATION_START,
-               DOWNLOAD_OPERATION_PAUSE,
-               DOWNLOAD_OPERATION_RESUME,
-               DOWNLOAD_OPERATION_CANCEL,
-       };
-
-       result CheckPrestate(DownloadOperation operation, int current);
-
        result RegisterCallback(RequestId reqId);
        void UnregisterCallback(RequestId reqId);