X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FFCnt_DownloadManagerImpl.cpp;h=2d8df1ebf2aed10c1a52af8f86cd6d1eaf472f99;hb=acbcabe49f4af6e36412974089c1a33260e2e55d;hp=f8cae5daf89d5bba399309687ba7b160d3cc6dab;hpb=7e7c42f45e68ca2a0cf89fb7984cd8bff82dcd33;p=platform%2Fframework%2Fnative%2Fcontent.git diff --git a/src/FCnt_DownloadManagerImpl.cpp b/src/FCnt_DownloadManagerImpl.cpp index f8cae5d..2d8df1e 100644 --- a/src/FCnt_DownloadManagerImpl.cpp +++ b/src/FCnt_DownloadManagerImpl.cpp @@ -435,8 +435,8 @@ _DownloadManagerImpl::Start(const DownloadRequest& request, RequestId& reqId) } // Set the callback functions - r = RegisterCallback((long)download_id); - SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "The internal system service is not available."); + ret = RegisterCallback((long)download_id); + SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available. %d", ret); // Start the download request ret = download_start(download_id); @@ -473,19 +473,27 @@ result _DownloadManagerImpl::Resume(RequestId reqId) { int ret = 0; + result r = E_SUCCESS; // Set the callback functions - result r = RegisterCallback((int)reqId); - SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "The internal system service is not available."); - - // Resume the download request - ret = download_start((int)reqId); + ret = RegisterCallback((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); + // Resume the download request + ret = download_start((int)reqId); + SysTryCatch(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_PARAMETER, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] There is no download request for the request."); + SysTryCatch(NID_CNT, ret != DOWNLOAD_ERROR_ID_NOT_FOUND, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The request ID is not valid."); + SysTryCatch(NID_CNT, ret != DOWNLOAD_ERROR_INVALID_STATE, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current download state is not paused or has failed."); + SysTryCatch(NID_CNT, ret >= 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The internal system service is not available. %d", ret); + return E_SUCCESS; + +CATCH: + UnregisterCallback((int)reqId); + + return r; } result @@ -678,23 +686,23 @@ _DownloadManagerImpl::DestroyResources(RequestId reqId) SysTryLog(NID_CNT, ret >= 0, "url_download_destory fails %d", ret); } -result +int _DownloadManagerImpl::RegisterCallback(RequestId reqId) { int ret = 0; ret = download_set_state_changed_cb(reqId, OnStateChanged, this); - SysTryCatch(NID_CNT, ret >= 0, , E_SYSTEM, "[E_SYSTEM] Fails to set state_changed_cb: %d, id = %d", ret, reqId); + SysTryCatch(NID_CNT, ret >= 0, , E_INVALID_ARG, "[E_INVALID_ARG] Fails to set state_changed_cb: %d, id = %d", ret, reqId); ret = download_set_progress_cb(reqId, OnProgress, this); - SysTryCatch(NID_CNT, ret >= 0, , E_SYSTEM, "[E_SYSTEM] Fails to set progress_cb: %d, id = %d", ret, reqId); + SysTryCatch(NID_CNT, ret >= 0, , E_INVALID_ARG, "[E_INVALID_ARG] Fails to set progress_cb: %d, id = %d", ret, reqId); - return E_SUCCESS; + return DOWNLOAD_ERROR_NONE; CATCH: UnregisterCallback(reqId); - return E_SYSTEM; + return ret; } void