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;
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;
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;
}
}
-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)
{