|
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 CFileSaver. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef FILE_SAVER_H |
|
22 #define FILE_SAVER_H |
|
23 |
|
24 // INCLUDE FILES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <f32file.h> |
|
28 #include "CodSaver.h" |
|
29 |
|
30 // FORWARD DECLARATION |
|
31 |
|
32 class CDocumentHandler; |
|
33 class CDrmHandler; |
|
34 class CCodBuffStorage; |
|
35 class CCodData; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * File saver (saving to file system). Handles DRM packaged objects too. |
|
41 */ |
|
42 NONSHARABLE_CLASS( CFileSaver ): public CCodSaver |
|
43 { |
|
44 public: // Construct / destruct |
|
45 |
|
46 /** |
|
47 * Two phase constructor. Leaves on failure. |
|
48 * @param aType Data type. |
|
49 * @param aFs File Server session. |
|
50 * @param aDocHandler Document Handler. |
|
51 * @param aTempPath Temp path. |
|
52 * @param aRootPath Root path. |
|
53 * @param aFname File name. |
|
54 * @return The constructed saver. |
|
55 |
|
56 */ |
|
57 static CFileSaver* NewL |
|
58 ( |
|
59 const TDesC8& aType, |
|
60 RFs& aFs, |
|
61 CDocumentHandler& aDocHandler, |
|
62 const TFileName& aTempPath, |
|
63 const TFileName& aRootPath, |
|
64 const TFileName& aFname |
|
65 ); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 virtual ~CFileSaver(); |
|
71 |
|
72 public: // from CCodSaver |
|
73 |
|
74 /** |
|
75 * Open temporary store for download. |
|
76 */ |
|
77 virtual void OpenStoreL(); |
|
78 |
|
79 /** |
|
80 * Append data to store. |
|
81 * @param aData Data to append. |
|
82 * @return Error code. |
|
83 */ |
|
84 virtual TInt AppendData( const TDesC8& aData ); |
|
85 |
|
86 /** |
|
87 * Download finished, close temporary store. |
|
88 */ |
|
89 virtual void CloseStore(); |
|
90 |
|
91 /** |
|
92 * Check if attributes of received content match descriptor data. |
|
93 * Leaves with KErrCodAttributeMismatch in case of mismatch. |
|
94 * @param aData Data to match. |
|
95 */ |
|
96 virtual void CheckResponseAttributesL( const CCodData& aData ); |
|
97 |
|
98 /** |
|
99 * Install downloaded content. |
|
100 * @param aStatus Completes when done. |
|
101 * @param aName Preferred name. |
|
102 * @param aAttached. ETrue if the download is attached and playing progressively. |
|
103 */ |
|
104 virtual void InstallL( TRequestStatus* aStatus, const TDesC& aName, const TBool aAttached ); |
|
105 |
|
106 /** |
|
107 * Perform bulk install for the downloaded media objects |
|
108 * @param aData CODData. |
|
109 * @param aAttached. ETrue if the download is attached and playing progressively. |
|
110 */ |
|
111 virtual void BulkInstallL( TRequestStatus* aStatus, const CCodData &aData, const TBool aAttached ); |
|
112 /** |
|
113 * Cancel installation. |
|
114 */ |
|
115 virtual void CancelInstall(); |
|
116 |
|
117 /** |
|
118 * Release content (take ownership of content from saver). |
|
119 * @param aFname File name of content returned here. |
|
120 * @param aHandler Handler UID returned here. |
|
121 */ |
|
122 virtual void ReleaseContent( TFileName& aFname, TUid& aHandler ); |
|
123 |
|
124 /** |
|
125 * Get the downloaded file size. |
|
126 */ |
|
127 virtual TInt DownloadedFileSize(); |
|
128 |
|
129 /** |
|
130 * Discard the old contents |
|
131 */ |
|
132 virtual void ResetL(); |
|
133 |
|
134 /** |
|
135 * Clean up. |
|
136 */ |
|
137 virtual void Cleanup( TBool aDeleteFile ); |
|
138 |
|
139 /** |
|
140 * Release file name (take ownership of content from saver). |
|
141 * @param aFname File name of content returned here. |
|
142 */ |
|
143 virtual void ReleaseFileName( TFileName& aFname); |
|
144 |
|
145 /** |
|
146 * Get Name |
|
147 * @return Name of Saver |
|
148 */ |
|
149 virtual HBufC* NameL ( ) const ; |
|
150 |
|
151 |
|
152 protected: // Construct / destruct |
|
153 |
|
154 /** |
|
155 * Constructor. |
|
156 * @param aType Data type. |
|
157 * @param aFs File Server session. |
|
158 * @param aDocHandler Document Handler. |
|
159 * @param aTempPath Temp path. |
|
160 * @param aRootPath Root path. |
|
161 * @param aFname File name of content. |
|
162 */ |
|
163 CFileSaver |
|
164 ( |
|
165 const TDesC8& aType, |
|
166 RFs& aFs, |
|
167 CDocumentHandler& aDocHandler, |
|
168 const TFileName& aTempPath, |
|
169 const TFileName& aRootPath, |
|
170 const TFileName& aFname |
|
171 ); |
|
172 |
|
173 /** |
|
174 * Second phase constructor. Leaves on failure. |
|
175 */ |
|
176 void ConstructL(); |
|
177 |
|
178 /** |
|
179 * Update saved file to DCFRepository. |
|
180 * @param aFileName File name of new file. |
|
181 */ |
|
182 void UpdateDCFRepositoryL( const TDesC& aFileName ); |
|
183 |
|
184 /** |
|
185 * Update repository about the new file. |
|
186 * @param aFileName File name of new file. |
|
187 */ |
|
188 void NotifyMediaGalleryL( const TDesC& aFileName ); |
|
189 |
|
190 /** |
|
191 * Calls MediaGallery Update method so that media gallery |
|
192 * knows update its view. |
|
193 * @param aFileName File name of new file. |
|
194 */ |
|
195 void UpdateMediaGalleryIfNeededL( const TDesC& aFileName ); |
|
196 |
|
197 |
|
198 /** |
|
199 * Set progressive mode download |
|
200 * @param aValue ETrue if progressive mode |
|
201 */ |
|
202 void SetProgressiveMode( TBool aValue ); |
|
203 |
|
204 /** |
|
205 * Called if download completed. |
|
206 */ |
|
207 void OnComplete(); |
|
208 |
|
209 /** |
|
210 * Writes Buffer data to file |
|
211 */ |
|
212 void FlushL(); |
|
213 |
|
214 |
|
215 protected: // data |
|
216 |
|
217 CDocumentHandler& iDocHandler; ///< Document Handler. Not owned. |
|
218 RFs& iFs; ///< File Server session. Not owned. |
|
219 RFile iFile; ///< Temp file for content body. Own. |
|
220 const TFileName& iTempPath; ///< Temp file path. |
|
221 const TFileName& iRootPath; ///< Root path. |
|
222 CDrmHandler* iDrmHandler; ///< DRM Handler or NULL. Owned. |
|
223 TFileName iFname; ///< File name. |
|
224 |
|
225 //Double buff chaanges |
|
226 TInt32 iBufferedSize; // How much data received over the air (but not necessarily all in file yet) |
|
227 TInt32 iBufferSize; // disk io buffer size - bytes |
|
228 TInt32 iLength; // EDlAttrLength |
|
229 TBool iProgressiveDownload; // EDlAttrProgressive |
|
230 CCodBuffStorage *iStorage; //Implenments double buffering foe storing downloaded data |
|
231 |
|
232 |
|
233 friend class CCodBuffStorage; |
|
234 }; |
|
235 |
|
236 #endif /* def FILE_SAVER_H */ |