2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FCntDownloadManager.cpp
19 * @brief This is the implementation file for the DownloadManager class.
23 #include <FBaseSysLog.h>
24 #include <FSec_AccessController.h>
25 #include <FCntDownloadManager.h>
26 #include <FCntDownloadRequest.h>
27 #include <FCntIDownloadListener.h>
29 #include "FCnt_DownloadManagerImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Security;
35 namespace Tizen { namespace Content
38 DownloadManager::DownloadManager(void)
39 : __pDownloadManagerImpl(null)
43 DownloadManager::~DownloadManager(void)
45 delete __pDownloadManagerImpl;
49 DownloadManager::GetInstance(void)
52 static DownloadManager* pManager = null;
56 pManager = new (std::nothrow) DownloadManager;
57 SysTryReturn(NID_CNT, pManager != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
59 _DownloadManagerImpl* pImpl = _DownloadManagerImpl::GetInstance();
60 SysTryCatch(NID_CNT, pImpl != null, , E_SYSTEM, "[E_SYSTEM] Failed to initialize download manager.");
62 pManager->__pDownloadManagerImpl = pImpl;
75 DownloadManager::Start(const DownloadRequest& request, RequestId& reqId)
77 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
79 result r = _AccessController::CheckUserPrivilege(_PRV_DOWNLOAD);
80 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
81 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r,
82 "The application is not permitted to call this method.");
84 return __pDownloadManagerImpl->Start(request, reqId);
89 DownloadManager::Pause(RequestId reqId)
91 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
93 return __pDownloadManagerImpl->Pause(reqId);
97 DownloadManager::Resume(RequestId reqId)
99 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
101 return __pDownloadManagerImpl->Resume(reqId);
105 DownloadManager::Cancel(RequestId reqId)
107 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
109 return __pDownloadManagerImpl->Cancel(reqId);
114 DownloadManager::GetDownloadRequestN(RequestId reqId) const
116 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
118 return __pDownloadManagerImpl->GetDownloadRequestN(reqId);
122 DownloadManager::GetState(RequestId reqId) const
124 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
126 return (DownloadState)__pDownloadManagerImpl->GetState(reqId);
130 DownloadManager::GetMimeType(RequestId reqId, String& mimeType) const
132 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
134 return __pDownloadManagerImpl->GetMimeType(reqId, mimeType);
139 DownloadManager::SetAllowedNetwork(unsigned long flags)
141 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
143 return __pDownloadManagerImpl->SetAllowedNetwork(flags);
147 DownloadManager::GetProgress(RequestId reqId, int& progress) const
149 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
151 return __pDownloadManagerImpl->GetProgress(reqId, progress);
156 DownloadManager::SetDownloadListener(IDownloadListener* pListener)
158 __pDownloadManagerImpl->SetDownloadListener(pListener);
161 } } // Tizen::Content