|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Declaration of class CCodSaver. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef COD_SAVER_H |
|
22 #define COD_SAVER_H |
|
23 |
|
24 // INCLUDE FILES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <apmstd.h> |
|
28 |
|
29 // FORWARD DECLARATION |
|
30 |
|
31 class MCodLoadObserver; |
|
32 class CCodData; |
|
33 class CAiwGenericParamList; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Content saver base class. Owns data in download-, install- and post-install |
|
39 * phases. |
|
40 * - Provides temp storage for data being downloaded. |
|
41 * - Installs content from temp storage to proper place. |
|
42 * - Provides cleanup in all phases (until content is Release()-d). |
|
43 * This class is driven by CCodEngBase and methods are expected to be called |
|
44 * in order. |
|
45 */ |
|
46 NONSHARABLE_CLASS( CCodSaver ): public CBase |
|
47 { |
|
48 public: // Construct / destruct |
|
49 |
|
50 /** |
|
51 * Constructor. |
|
52 * @param aType Data type. |
|
53 */ |
|
54 inline CCodSaver( const TDesC8& aType ); |
|
55 |
|
56 /** |
|
57 * Second phase constructor. Leaves on failure. |
|
58 */ |
|
59 void ConstructL(); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 virtual ~CCodSaver(); |
|
65 |
|
66 public: // new methods |
|
67 |
|
68 /** |
|
69 * Open temporary store for download. |
|
70 */ |
|
71 virtual void OpenStoreL() = 0; |
|
72 |
|
73 /** |
|
74 * Append data to store. |
|
75 * @param aData Data to append. |
|
76 * @return Error code. |
|
77 */ |
|
78 virtual TInt AppendData( const TDesC8& aData ) = 0; |
|
79 |
|
80 /** |
|
81 * Download finished, close temporary store. |
|
82 */ |
|
83 virtual void CloseStore() = 0; |
|
84 |
|
85 /** |
|
86 * Check if attributes of received content match descriptor data. |
|
87 * Leaves with KErrCodAttributeMismatch in case of mismatch. |
|
88 * @param aData Data to match. |
|
89 */ |
|
90 virtual void CheckResponseAttributesL( const CCodData& aData ) = 0; |
|
91 |
|
92 /** |
|
93 * Install downloaded content. |
|
94 * @param aStatus Completes when done. |
|
95 * @param aName Preferred name |
|
96 * @param aAttached ETrue if download is attached (playing progressively) |
|
97 */ |
|
98 virtual void InstallL( TRequestStatus* aStatus, const TDesC& aName, const TBool aAttached ) = 0; |
|
99 |
|
100 |
|
101 /** |
|
102 * Perform buklk install for multiple downloaded media objects |
|
103 * @param aStatus Completes when done. |
|
104 * @param aData CODData object |
|
105 * @param aAttached ETrue if download is attached (playing progressively) |
|
106 */ |
|
107 virtual void BulkInstallL( TRequestStatus* aStatus, const CCodData &aData, const TBool aAttached ) = 0; |
|
108 |
|
109 /** |
|
110 * Cancel installation. |
|
111 */ |
|
112 virtual void CancelInstall() = 0; |
|
113 |
|
114 /** |
|
115 * Release content (take ownership of content from saver). |
|
116 * @param aFname File name of content returned here. |
|
117 * @param aHandler Handler UID returned here. |
|
118 */ |
|
119 virtual void ReleaseContent( TFileName& aFname, TUid& aHandler ) = 0; |
|
120 |
|
121 /** |
|
122 * Clean up. |
|
123 */ |
|
124 virtual void Cleanup( TBool aDeleteFile ) = 0; |
|
125 |
|
126 /** |
|
127 * Release file name (take ownership of content from saver). |
|
128 * @param aFname File name of content returned here. |
|
129 */ |
|
130 virtual void ResetL() = 0; |
|
131 |
|
132 /** |
|
133 * Get the downloaded file size. |
|
134 */ |
|
135 virtual TInt DownloadedFileSize() = 0; |
|
136 |
|
137 /** |
|
138 * Release file name (take ownership of content from saver). |
|
139 * @param aFname File name of content returned here. |
|
140 */ |
|
141 virtual void ReleaseFileName(TFileName& aFname) = 0; |
|
142 |
|
143 /** |
|
144 * Set progressive mode download |
|
145 * @param aValue ETrue if progressive mode |
|
146 */ |
|
147 virtual void SetProgressiveMode( TBool /*aValue*/ ) {} |
|
148 |
|
149 |
|
150 /** |
|
151 * Called if download completed. |
|
152 * @since Series 60 v2.8 |
|
153 * @param ?arg1 ?description |
|
154 * @return ?description |
|
155 */ |
|
156 virtual void OnComplete(){} |
|
157 |
|
158 |
|
159 |
|
160 public: // new methods |
|
161 |
|
162 /** |
|
163 * Get data type. |
|
164 * @return Data type. |
|
165 */ |
|
166 inline const TDataType& DataType() const; |
|
167 |
|
168 /** |
|
169 * Get current data size. |
|
170 * @return Data size. |
|
171 */ |
|
172 inline TInt DataSize() const; |
|
173 |
|
174 /** |
|
175 * Set source URI. |
|
176 * @param aSourceUri Source URI. |
|
177 */ |
|
178 inline void SetSourceUriL( const TDesC8& aSourceUri ); |
|
179 |
|
180 /** |
|
181 * Set or unset observer (pass NULL to unset). |
|
182 * Panics if already set; unsetting more is allowed. |
|
183 * @param aObserver Observer to set or NULL to unset. |
|
184 */ |
|
185 void SetObserver( MCodLoadObserver* aObserver ); |
|
186 |
|
187 /** |
|
188 * Set or unset parameters (pass NULL to unset). |
|
189 * @param aParams Parameters or NULL. |
|
190 */ |
|
191 inline void SetParams( const CAiwGenericParamList* aParams ); |
|
192 |
|
193 /** |
|
194 * Get Name |
|
195 * @return Name of Saver |
|
196 */ |
|
197 virtual HBufC* NameL ( ) const { return NULL; } |
|
198 |
|
199 public: // new methods |
|
200 |
|
201 /** |
|
202 * Set maximum size based on expected size. (Multiply with a safety |
|
203 * factor, to allow for transport formats, encodings, etc.) |
|
204 */ |
|
205 void SetMaxSize( TInt aSize ); |
|
206 |
|
207 /** |
|
208 * Check if appending new data chunk would go over the limit. |
|
209 * @param aDataChunkSize Data chunk size. |
|
210 * @return KErrCodAttributeMismatch if over the limit, or KErrNone. |
|
211 */ |
|
212 TInt CheckMaxSize( TInt aDataChunkSize ); |
|
213 |
|
214 /** |
|
215 * Creates a buffer having info to be stored. |
|
216 * @Added in OMA pause-resume feature |
|
217 */ |
|
218 void AppendStorageInfoL(TPtr8&)const; |
|
219 /** |
|
220 * Creates a unique download name |
|
221 */ |
|
222 void ConvertDownloadNameUniqueL( HBufC*& filePath, |
|
223 HBufC*& fileName, |
|
224 HBufC*& fileExtn ); |
|
225 |
|
226 /** |
|
227 * Support function for ConvertDownloadNameUniqueL for creating a indexed unique name |
|
228 */ |
|
229 void CreateIndexedNameL( HBufC*& aUniqueName, |
|
230 TDesC& aOrgName, |
|
231 TInt& aIndex ); |
|
232 |
|
233 /** |
|
234 * Calls ConvertDownloadNameUniqueL to create unique name based on source file name |
|
235 * and destination path. |
|
236 */ |
|
237 void FindUniqueDestinationFileNameL( TDesC& srcFile, HBufC*& destPath ); |
|
238 |
|
239 protected: // types |
|
240 |
|
241 enum TState ///< State (debug). |
|
242 { |
|
243 EInit, ///< Initial state. |
|
244 EStoreOpen, ///< Store open. |
|
245 EStoreClosed, ///< Store closed. |
|
246 ERespChecked, ///< Response attributes checked. |
|
247 EInstalling, ///< Install in progress. |
|
248 EInstalled ///< Install done. |
|
249 }; |
|
250 |
|
251 protected: // data |
|
252 |
|
253 MCodLoadObserver* iObserver; ///< Observer or NULL. Not own. |
|
254 const CAiwGenericParamList* iParams; ///< Params or NULL. Not own. |
|
255 HBufC8* iSourceUri; ///< Source URI. Owned. |
|
256 TDataType iType; ///< Data type. |
|
257 TInt iSize; ///< Data size. |
|
258 TInt iMaxSize; ///< Size limit (0 == off). |
|
259 TUid iHandler; ///< Handler app UID. |
|
260 TState iState; ///< State (debug). |
|
261 TFileName iFname; |
|
262 }; |
|
263 |
|
264 /** |
|
265 * Saver factory. |
|
266 */ |
|
267 NONSHARABLE_CLASS( MCodSaverFactory ) |
|
268 { |
|
269 public: // new methods |
|
270 |
|
271 /** |
|
272 * Create saver object. |
|
273 * @param aType Data type. |
|
274 * @return Saver object for this data type. Ownership not passed. |
|
275 */ |
|
276 virtual CCodSaver* CreateSaverL( const TDesC8& aType ) = 0; |
|
277 |
|
278 }; |
|
279 |
|
280 #include "CodSaver.inl" |
|
281 |
|
282 #endif /* def COD_SAVER_H */ |