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 FCntContentTransfer.h
19 * @brief This is the header file for the %ContentTransfer class.
21 * This header file contains the declarations of the %ContentTransfer class.
25 #ifndef _FCNT_CONTENT_TRANSFER_H_
26 #define _FCNT_CONTENT_TRANSFER_H_
28 #include <FBaseObject.h>
30 namespace Tizen { namespace Base { namespace Collection
35 namespace Tizen { namespace Base { namespace Utility
40 namespace Tizen { namespace Content
43 class _ContentTransferImpl;
44 class IContentTransferListener;
48 * @class ContentTransfer
49 * @brief <i> [Deprecated] </i> This class provides methods to download the content.
51 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
54 * The %ContentTransfer class provides the following features:
55 * - Downloading the content from the servers that support HTTP access.
56 * - Cancelling a download operation.
58 * HTTP download (ContentTransfer::Download()) is a standard HTTP transaction using the HTTP GET request and response methods.
60 * The following example demonstrates how to use the %ContentTransfer class.
64 * :public Tizen::Content::IContentTransferListener
68 * virtual ~MyClass(void);
71 * void OnContentTransferInProgress(RequestId requestID, int totalReceivedSize);
72 * void OnContentDownloadCompleted(RequestId requestID, ContentId contentID, result res, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage);
73 * void OnContentDownloadToBufferCompleted(RequestId reqId, Tizen::Base::ByteBuffer* pBuffer, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage);
74 * void OnContentTransferCanceled(RequestId reqId, result res, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage);
77 * // Implementation for the listener function and Implementation of other listener function is
78 * void MyClass::OnContentDownloadCompleted(RequestId requestID, ContentId contentID, result res, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage)
80 * result r = E_SUCCESS;
81 * ContentManager contentManager;
82 * ContentInfo* pContentInfo = null;
85 * TryCatch(!IsFailed(res), r, "Download Error [%s]", GetErrorMessage(res));
88 * r = contentManager.Construct();
89 * TryCatch(!IsFailed(r), r, "Construct failed.");
92 * pContentInfo = contentManager.GetContentInfoN(contentID);
95 * delete pContentInfo;
99 * MyClass::RequestDownload(void)
101 * ContentTransfer contentTransfer;
102 * RequestId requestId;
103 * Tizen::Base::Utility::Uri contentUri;
105 * Tizen::Base::String downloadPath;
107 * result r = contentTransfer.Construct(*this);
108 * TryReturn(!IsFailed(r), r, ("Construct is failed.\n"));
110 * // TODO: set uri and download path
112 * r = contentTransfer.Download(contentUri, downloadPath, requestId, false);
113 * TryReturn(!IsFailed(r), r, ("Download Request is failed.\n"));
118 class _OSP_EXPORT_ ContentTransfer
119 : virtual public Tizen::Base::Object
123 * The object is not fully constructed after this constructor is called. @n
124 * For full construction, the Construct(IContentTransferListener&) method must be called right after calling this constructor.
126 * @brief <i> [Deprecated] </i>
127 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
130 * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
132 ContentTransfer(void);
135 * This destructor overrides Tizen::Base::Object::~Object().
137 * @brief <i> [Deprecated] </i>
138 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
142 virtual ~ContentTransfer(void);
145 * Initializes this instance of %ContentTransfer with the specified parameter. @n
146 * The %Construct() method should be called after every instance of %ContentTransfer is constructed.
148 * @brief <i> [Deprecated] </i>
149 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
152 * @return An error code
153 * @param[in] listener A reference to IContentTransferListener
154 * @exception E_SUCCESS The method is successful.
155 * @exception E_OUT_OF_MEMORY The memory is insufficient.
156 * @exception E_SYSTEM A system error has occurred.
158 result Construct(IContentTransferListener& listener);
161 * Downloads a content file from the content provider's server. @n
162 * The @c filesize parameter is used to check the limitation of the local volume. If this parameter is set to @c 0, the %Download() method will not check the volume. @n
163 * An application should set the full destination path for the downloaded contents. When the content is downloaded to one of the following paths, this method internally registers the content using ContentManager.
165 * - /Storagecard/Media/ @n
167 * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadCompleted() method. @n
168 * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
170 * @brief <i> [Deprecated] </i>
171 * @deprecated This method is deprecated due to the operation policy of the Tizen Server.
172 * When downloading the contents from a third party server, it is recommended to use the Download(const Tizen::Base::Utility::Uri&, const Tizen::Base::String&, RequestId&, bool, int, int) method.
175 * @privilege %http://tizen.org/privilege/download
177 * @return An error code
178 * @param[in] uri The content URL
179 * @param[in] fileSize The content file size in bytes @n
180 * If set to @c 0, the method does not check the storage limitation.
181 * @param[in] destFilePath The full destination path
182 * @param[in] replace The replace option of the destination file @n
183 * Set to @c true to replace the file, @n
185 * @param[out] reqId The request ID
186 * @param[in] pListener A pointer to the IContentTransferListener instance
187 * @param[in] sec The timeout period in seconds
188 * @exception E_SUCCESS The method is successful.
189 * @exception E_INVALID_ARG A specified input parameter is invalid.
190 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
191 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
192 * @exception E_FILE_ALREADY_EXIST The specified file already exists.
193 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
194 * @exception E_IN_PROGRESS A previous request is in progress.
195 * @exception E_OUT_OF_MEMORY The memory is insufficient.
196 * @exception E_USER_NOT_CONSENTED The user blocks an application from calling this method. @b Since: @b 2.1
197 * @see IContentTransferListener::OnContentDownloadCompleted()
198 * @see IContentTransferListener::OnContentTransferInProgress()
200 result Download(const Tizen::Base::Utility::Uri& uri, int fileSize, const Tizen::Base::String& destFilePath, bool replace, RequestId& reqId, IContentTransferListener* pListener = null, int sec = 0);
203 * Downloads a content file from the content provider's server. @n
204 * An application should set the destination path for the downloaded contents.
205 * The path of the downloaded file should use Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath().
207 * When the content is downloaded to the path using Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath(), the %Download() method internally registers the content in the content database. @n
208 * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadCompleted() method. @n
209 * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
211 * @brief <i> [Deprecated] </i>
212 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
214 * @brief <i> [Compatibility] </i>
218 * @compatibility This method has compatibility issues with OSP compatible applications. @n
219 * For more information, see @ref CompContentTransferDownloadPage3 "here".
222 * @privilege %http://tizen.org/privilege/download
224 * @return An error code
225 * @param[in] uri The content URL
226 * @param[in] filePath The destination file path @n
227 * Use Tizen::System::Environment::GetMediaPath(), Tizen::System::Environment::GetExternalStoragePath() and Tizen::App::App::GetInstance()->GetAppRootPath().
228 * @param[out] reqId The request ID
229 * @param[in] replace The replace option of the destination file @n
230 * Set to @c true to replace the file, @n
232 * @param[in] timeout The timeout period in seconds
233 * @param[in] progressInterval The progress period interval as a percentage value
234 * @exception E_SUCCESS The method is successful.
235 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
236 * @exception E_INVALID_ARG A specified input parameter is invalid.
237 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
238 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
239 * @exception E_FILE_ALREADY_EXIST The specified file already exists.
240 * @exception E_IN_PROGRESS A previous request is in progress.
241 * @exception E_OUT_OF_MEMORY The memory is insufficient.
242 * @exception E_SYSTEM A system error has occurred.
243 * @exception E_USER_NOT_CONSENTED The user blocks an application from calling this method. @b Since: @b 2.1
245 * - The @c progressInterval is the interval of the progress for each download request. If the value of the @c progressInterval is @c 0, the @c progressInterval uses the value set by the ContentTransfer::SetProgressIntervalByPercent(int). The @c progressInterval is a percentage value between @c 0 and @c 100.
246 * - The @c timeout is the value of the response timeout for each download request. If the value of the @c timeout is @c 0, the value for the @c timeout uses the value set by the ContentTransfer::SetDefaultTimeout(int).
247 * @see IContentTransferListener::OnContentDownloadCompleted()
248 * @see IContentTransferListener::OnContentTransferInProgress()
250 result Download(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& filePath, RequestId& reqId, bool replace = false, int timeout = 0, int progressInterval = 0);
254 * @page CompContentTransferDownloadPage3 Compatibility for the file path.
255 * @section CompContentTransferDownloadPageIssueSection Issues
256 * The content path argument of this method in OSP compatible applications has the following issues: @n
257 * -# The content path should be a path that begins with an allowed path prefix. @n
258 * For example, L"/Media/Images/flower.jpg", "/Storagecard/Media/Images/flower.jpg".
260 * @section CompImageContentInfoConstructPageSolutionSection Resolutions
261 * This issue has been resolved in Tizen. @n
262 * -# The content path can be a path without a specific allowed path prefix. @n
263 * Application do not need to know the specific allowed path prefixes. @n
264 * To get the directory path, use the following methods: @n
265 * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
266 * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
272 * Downloads a content file to a buffer from the content provider's servers. @n
273 * The %DownloadToBuffer() method does not register the content. @n
274 * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadToBufferCompleted() method. @n
275 * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
277 * @brief <i> [Deprecated] </i>
278 * @deprecated This method is deprecated due to the operation policy of the Tizen Server.
279 * When downloading the contents to a buffer from a third party server, it is recommended to use the DownloadToBuffer(const Tizen::Base::Utility::Uri&, RequestId&, int, int) method.
282 * @privilege %http://tizen.org/privilege/download
284 * @return An error code
285 * @param[in] uri The content URL
286 * @param[in] fileSize The content file size in bytes @n
287 * If set to @c 0, the method does not check the storage limitation.
288 * @param[out] reqId The request ID
289 * @param[in] pListener A pointer to the IContentTransferListener instance
290 * @param[in] sec The timeout period in seconds
291 * @exception E_SUCCESS The method is successful.
292 * @exception E_INVALID_ARG A specified input parameter is invalid.
293 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
294 * @exception E_OUT_OF_MEMORY The memory is insufficient.
295 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
296 * @exception E_USER_NOT_CONSENTED The user blocks an application from calling this method. @b Since: @b 2.1
297 * @see IContentTransferListener::OnContentDownloadToBufferCompleted()
298 * @see IContentTransferListener::OnContentTransferInProgress()
300 result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, int fileSize, RequestId& reqId, IContentTransferListener* pListener = null, int sec = 0);
303 * Downloads a content file to a buffer from the content provider's servers. @n
304 * The %DownloadToBuffer() method does not register the content. @n
305 * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadToBufferCompleted() method. @n
306 * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
308 * @brief <i> [Deprecated] </i>
309 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
312 * @privilege %http://tizen.org/privilege/download
314 * @return An error code
315 * @param[in] uri The content URL
316 * @param[out] reqId The request ID
317 * @param[in] timeout The timeout period in seconds
318 * @param[in] progressInterval The progress period interval as a percentage value
319 * @exception E_SUCCESS The method is successful.
320 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
321 * @exception E_INVALID_ARG A specified input parameter is invalid.
322 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
323 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
324 * @exception E_IN_PROGRESS A previous request is in progress.
325 * @exception E_OUT_OF_MEMORY The memory is insufficient.
326 * @exception E_USER_NOT_CONSENTED The user blocks an application from calling this method. @b Since: @b 2.1
328 * - The @c progressInterval is the interval of the progress for each download request. If the value of the @c progressInterval is @c 0, the @c progressInterval uses the value set by the ContentTransfer::SetProgressIntervalByPercent(int). The @c progressInterval is a percentage value between @c 0 and @c 100.
329 * - The @c timeout is the value of the response timeout for each download request. If the value of the @c timeout is @c 0, the value for the @c timeout uses the value set by the ContentTransfer::SetDefaultTimeout(int).
330 * @see IContentTransferListener::OnContentDownloadToBufferCompleted()
331 * @see IContentTransferListener::OnContentTransferInProgress()
333 result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, RequestId& reqId, int timeout = 0, int progressInterval = 0);
336 * Sets the default timeout period. @n
337 * If the server does not respond during the timeout period, the network connection is closed.
338 * @c 0 or minus second means unlimited period.
340 * @brief <i> [Deprecated] </i>
341 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
344 * @param[in] sec The default timeout period in seconds @n
345 * The default value is @c 0.
347 void SetDefaultTimeout(int sec);
350 * Gets the default timeout period.
352 * @brief <i> [Deprecated] </i>
353 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
356 * @return The default timeout period
358 int GetDefaultTimeout(void) const;
361 * Removes a transfer operation. @n
362 * This operation removes a request for multiple downloads.
363 * A download operation in progress is not removed by this operation.
365 * @brief <i> [Deprecated] </i>
366 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
369 * @return An error code
370 * @param[in] reqId The request ID
371 * @exception E_SUCCESS The method is successful.
372 * @exception E_OUT_OF_MEMORY The memory is insufficient.
373 * @exception E_OBJ_NOT_FOUND The specified @c reqId is not found.
374 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
375 * @remarks To stop an on-going transfer, use the Cancel() method.
377 result Remove(RequestId reqId);
380 * Removes all the transfer operations. @n
381 * This operation removes all the requests for multiple downloads.
382 * The download operations in progress are not removed by this operation.
384 * @brief <i> [Deprecated] </i>
385 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
388 * @return An error code
389 * @exception E_SUCCESS The method is successful.
390 * @exception E_OUT_OF_MEMORY The memory is insufficient.
391 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
392 * @remarks To stop an on-going transfer, use the Cancel() method.
394 result RemoveAll(void);
397 * Cancels a transfer operation. @n
398 * The downloaded file is deleted from the file system. @n
399 * When a transfer download operation is canceled, the application is notified via the IContentTransferListener::OnContentTransferCanceled() method.
401 * @brief <i> [Deprecated] </i>
402 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
405 * @return An error code
406 * @param[in] reqId The request ID
407 * @exception E_SUCCESS The method is successful.
408 * @exception E_OBJ_NOT_FOUND The specified @c reqId is not found.
409 * @exception E_INVALID_ARG The specified input parameter is invalid.
410 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
411 * @see IContentTransferListener::OnContentTransferCanceled()
413 result Cancel(RequestId reqId);
416 * Cancels all the operations in progress.
418 * @brief <i> [Deprecated] </i>
419 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
422 * @return An error code
423 * @exception E_SUCCESS The method is successful.
424 * @exception E_OUT_OF_MEMORY The memory is insufficient.
425 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
427 result CancelAll(void);
430 * Gets the content transfer information list.
432 * @brief <i> [Deprecated] </i>
433 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
436 * @return A pointer to a list containing the ContentTransferInfo instances, @n
437 * else an empty list if there is no result and no error
439 Tizen::Base::Collection::IList* GetContentTransferInfoListN(void) const;
442 * Gets the list of transfers that are in progress.
444 * @brief <i> [Deprecated] </i>
445 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
448 * @return A pointer to a list containing the ContentTransferInfo instances, @n
449 * else an empty list if there is no result and no error
451 Tizen::Base::Collection::IList* GetContentTransferInfoListInProgressN(void) const;
454 * Sets the interval of the progress. @n
455 * The input is a percentage value between @c 0 and @c 100. The default value is @c 0.
456 * @c 0 means the application would not receive progress events.
458 * @brief <i> [Deprecated] </i>
459 * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
462 * @param[in] percent The progress period interval as a percentage value
463 * @remarks If a server does not provide the information about the content size, then the content module cannot verify the information. @n
464 * In that case, progress event will occur randomly.
466 void SetProgressIntervalByPercent(int percent);
470 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
472 ContentTransfer(const ContentTransfer& rhs);
475 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
477 ContentTransfer& operator =(const ContentTransfer& rhs);
480 friend class _ContentTransferImpl;
481 _ContentTransferImpl* __pImpl;
483 }; // class ContentTransfer
487 #endif // _FCNT_CONTENT_TRANSFER_H_