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.
18 * @file FCnt_ContentTransferImpl.h
19 * @brief This is the header file for the %_ContentTransferImpl class.
21 * This header file contains the declarations of the %_ContentTransferImpl class.
24 #ifndef _FCNT_INTERNAL_CONTENT_TRANSFER_IMPL_H_
25 #define _FCNT_INTERNAL_CONTENT_TRANSFER_IMPL_H_
27 #include <unique_ptr.h>
28 #include <FBaseRtITimerEventListener.h>
29 #include <FBaseColAllElementsDeleter.h>
30 #include <FCntContentTransferInfo.h>
32 namespace Tizen { namespace Base { namespace Runtime
37 namespace Tizen { namespace Content
40 class IContentTransferListener;
41 class ContentTransfer;
42 class _ContentTransferEvent;
43 class _ContentDownloadHandler;
44 class _ContentDownloadUserData;
46 class _ContentTransferImpl
47 : virtual public Tizen::Base::Runtime::ITimerEventListener
51 * This is the default constructor for this class.
55 _ContentTransferImpl(void);
58 * This is the destructor for this class.
62 virtual ~_ContentTransferImpl(void);
65 * @see @ref Tizen::Content::ContentTransfer::Construct()
67 result Construct(IContentTransferListener& listener);
70 * @see @ref Tizen::Content::ContentTransfer::Download(const Tizen::Base::Utility::Uri&, int, const Tizen::Base::String&, bool, RequestId&, const IContentTransferListener*, int)
72 result Download(const Tizen::Base::Utility::Uri& uri, int fileSize, const Tizen::Base::String& destFilePath, bool replace, RequestId& requestID, IContentTransferListener* pListener = null, int sec = 0);
75 * @see @ref Tizen::Content::ContentTransfer::Download(const Tizen::Base::Utility::Uri&, const Tizen::Base::String&, RequestId&, bool, int, int)
77 result Download(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& filePath, RequestId& reqId, bool replace = false, int timeout = 0, int progressInterval = 0);
80 * @see @ref Tizen::Content::ContentTransfer::DownloadToBuffer(const Tizen::Base::Utility::Uri&, int, RequestId&, const IContentTransferListener*, int)
82 result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, int fileSize, RequestId& reqId, IContentTransferListener* pListener = null, int sec = 0);
85 * @see @ref Tizen::Content::ContentTransfer::DownloadToBuffer(const Tizen::Base::Utility::Uri&, RequestId&, int, int)
87 result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, RequestId& reqId, int timeout = 0, int progressInterval = 0);
90 * @see @ref Tizen::Content::ContentTransfer::SetDefaultTimeout()
92 void SetDefaultTimeout(int sec);
95 * @see @ref Tizen::Content::ContentTransfer::GetDefaultTimeout()
97 int GetDefaultTimeout(void) const;
100 * @see @ref Tizen::Content::ContentTransfer::Remove()
102 result Remove(RequestId reqId);
105 * @see @ref Tizen::Content::ContentTransfer::RemoveAll()
107 result RemoveAll(void);
110 * @see @ref Tizen::Content::ContentTransfer::Cancel()
112 result Cancel(RequestId reqId);
115 * @see @ref Tizen::Content::ContentTransfer::CancelAll()
117 result CancelAll(void);
120 * @see @ref Tizen::Content::ContentTransfer::GetContentTransferInfoListN()
122 Tizen::Base::Collection::IList* GetContentTransferInfoListN(void) const;
125 * @see @ref Tizen::Content::ContentTransfer::GetContentTransferInfoListInProgressN()
127 Tizen::Base::Collection::IList* GetContentTransferInfoListInProgressN(void) const;
130 * @see @ref Tizen::Content::ContentTransfer::SetProgressIntervalByPercent()
132 void SetProgressIntervalByPercent(int percent);
135 * Gets the Impl instance.
138 * @return The pointer to _ContentTransferImpl
139 * @param[in] contentTransfer An instance of ContentTransfer
141 static _ContentTransferImpl* GetInstance(ContentTransfer& contentTransfer);
144 * Gets the Impl instance.
147 * @return The pointer to _ContentTransferImpl
148 * @param[in] contentTransfer An instance of ContentTransfer
150 static const _ContentTransferImpl* GetInstance(const ContentTransfer& contentTransfer);
153 _ContentTransferImpl(const _ContentTransferImpl& rhs);
154 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
156 RequestId GetRequestId(void) const;
157 ContentTransferInfo* GetContentTransferInfoByRequestId(RequestId requestId) const;
158 void StartTimer(void);
159 result GetEmptySlot(int& slot) const;
160 void DeleteDownloadObj(void);
161 result CheckDestPath(const Tizen::Base::String& destPath, bool replace);
162 result CheckDownloadStatus(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& destPath);
163 result AddTransferItem(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& destPath,
164 const Tizen::Base::String& sourcePath, int sourceFileSize, ContentTransferStatus status,
165 IContentTransferListener* pListener, int sec, bool isBuffer, RequestId& requestId);
166 result AddTransferItem(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& destPath,
167 const Tizen::Base::String& sourcePath, ContentTransferStatus status,
168 int timeout, int interval, bool isBuffer, RequestId& requestId);
169 result SetDownloadSlotInfo(ContentTransferInfo* pTransferInfo, int& slot);
170 result RequestErrorEvent(result requestErrorCode, ContentTransferInfo* pTransferInfo);
171 result RemoveCompletedTransferInfo(Tizen::Base::Collection::ArrayList* pTransferInfoList);
172 bool ContentTransferHandler(void);
174 void InitializeEmptySlotInternal(_ContentDownloadUserData* pUserData);
175 int GetEmptySlotInternal(void) const;
176 void SetUsedSlotInternal(int slot);
177 void SetEmptySlotInternal(void);
178 int GetMaxDownloadCount(void) const;
180 _ContentTransferImpl& operator =(const _ContentTransferImpl& rhs);
183 RequestId __requestId;
184 RequestId __restRequestId;
185 int __maxDownloadCount;
190 Tizen::Base::String __destFilePath;
191 std::unique_ptr<_ContentDownloadUserData> __pContentDownloadUserData;
192 std::unique_ptr<_ContentDownloadUserData[]> __pContentDownloadUserDataSequence;
193 std::unique_ptr<_ContentDownloadHandler> __pContentDownloadHandler;
194 std::unique_ptr<_ContentDownloadHandler[]> __pContentDownloadHandlerSequence;
195 std::unique_ptr<_ContentTransferEvent> __pTransferEvent;
196 std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> __pTransferInfoList;
197 std::unique_ptr<Tizen::Base::Runtime::Timer> __pTimer;
198 }; // class _ContentTransferImpl
202 #endif // _FCNT_INTERNAL_CONTENT_TRANSFER_IMPL_H_