2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FCntDownloadManager.cpp
20 * @brief This is the implementation file for the DownloadManager class.
24 #include <FBaseSysLog.h>
25 #include <FSec_AccessController.h>
26 #include <FCntDownloadManager.h>
27 #include <FCntDownloadRequest.h>
28 #include <FCntIDownloadListener.h>
30 #include "FCnt_DownloadManagerImpl.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Security;
36 namespace Tizen { namespace Content
39 DownloadManager::DownloadManager(void)
40 : __pDownloadManagerImpl(null)
44 DownloadManager::~DownloadManager(void)
46 delete __pDownloadManagerImpl;
50 DownloadManager::GetInstance(void)
53 static DownloadManager* pManager = null;
57 pManager = new (std::nothrow) DownloadManager;
58 SysTryReturn(NID_CNT, pManager != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
60 _DownloadManagerImpl* pImpl = _DownloadManagerImpl::GetInstance();
61 SysTryCatch(NID_CNT, pImpl != null, , E_SYSTEM, "[E_SYSTEM] Failed to initialize download manager.");
63 pManager->__pDownloadManagerImpl = pImpl;
76 DownloadManager::Start(const DownloadRequest& request, RequestId& reqId)
78 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
80 result r = _AccessController::CheckUserPrivilege(_PRV_DOWNLOAD);
81 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
82 SysTryReturnResult(NID_CNT, r == E_SUCCESS, r,
83 "The application is not permitted to call this method.");
85 return __pDownloadManagerImpl->Start(request, reqId);
90 DownloadManager::Pause(RequestId reqId)
92 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
94 return __pDownloadManagerImpl->Pause(reqId);
98 DownloadManager::Resume(RequestId reqId)
100 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
102 return __pDownloadManagerImpl->Resume(reqId);
106 DownloadManager::Cancel(RequestId reqId)
108 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
110 return __pDownloadManagerImpl->Cancel(reqId);
115 DownloadManager::GetDownloadRequestN(RequestId reqId) const
117 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
119 return __pDownloadManagerImpl->GetDownloadRequestN(reqId);
123 DownloadManager::GetState(RequestId reqId) const
125 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
127 return (DownloadState)__pDownloadManagerImpl->GetState(reqId);
131 DownloadManager::GetMimeType(RequestId reqId, String& mimeType) const
133 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
135 return __pDownloadManagerImpl->GetMimeType(reqId, mimeType);
140 DownloadManager::SetAllowedNetwork(unsigned long flags)
142 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
144 return __pDownloadManagerImpl->SetAllowedNetwork(flags);
148 DownloadManager::GetProgress(RequestId reqId, int& progress) const
150 SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
152 return __pDownloadManagerImpl->GetProgress(reqId, progress);
157 DownloadManager::SetDownloadListener(IDownloadListener* pListener)
159 __pDownloadManagerImpl->SetDownloadListener(pListener);
162 } } // Tizen::Content