|
1 /* |
|
2 * Copyright (c) 2009 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 "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: Implementation of fotaserver component |
|
15 * This is part of fotaapplication. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __FOTADISKSTORAGE_H_ |
|
21 #define __FOTADISKSTORAGE_H_ |
|
22 |
|
23 #include <s32file.h> |
|
24 |
|
25 |
|
26 #include "fotastorage.h" |
|
27 |
|
28 |
|
29 // CONSTANTTS |
|
30 // const TInt KDummyFileSize(2000000); // total of 2MB should be reserved for fota pkgs |
|
31 |
|
32 #ifndef _FOTA_UNIT_TESTER |
|
33 _LIT( KDummyFilePath, "c:\\private\\102072C4\\" ); |
|
34 #else |
|
35 _LIT( KDummyFilePath, "c:\\private\\10009cf4\\" ); |
|
36 #endif |
|
37 _LIT( KDummyFileName, "reserved"); // dummy file name |
|
38 |
|
39 |
|
40 const TInt KFileReservationDefaultSize ( 5000000); |
|
41 const TInt KFileChunkDefaultSize ( 120000 ); |
|
42 |
|
43 /* |
|
44 * Implementation of fotastorage. This implementation |
|
45 * directly stores the update package to user disk. |
|
46 * Private directory of the calling process will be used |
|
47 * for storage. |
|
48 */ |
|
49 |
|
50 class CFotaDiskStorage : public CFotaStorage |
|
51 { |
|
52 public: |
|
53 |
|
54 /** |
|
55 * NewL |
|
56 * @since S60 v3.1 |
|
57 * @param none |
|
58 * @return New instance |
|
59 */ |
|
60 static CFotaDiskStorage* NewL(); |
|
61 |
|
62 |
|
63 /** |
|
64 * Two phase Constructor |
|
65 * @since S60 v3.1 |
|
66 * @param none |
|
67 * @return none |
|
68 */ |
|
69 void ConstructL(); |
|
70 |
|
71 // From base classes |
|
72 |
|
73 /** |
|
74 * Two phase Constructor |
|
75 * @since S60 v3.1 |
|
76 * @param none |
|
77 * @return none |
|
78 */ |
|
79 TInt AdjustDummyStorageL(); |
|
80 |
|
81 /** |
|
82 * Opens stream to package file |
|
83 * @since S60 v3.1 |
|
84 * @param pkgid Package id |
|
85 * @param aPkgStore Stream to the file |
|
86 * @return err |
|
87 */ |
|
88 TInt OpenUpdatePackageStoreL(const TInt aPkgId,TInt aNewDummySize |
|
89 , RWriteStream*& aPkgStore); |
|
90 |
|
91 /** |
|
92 * Gets the update package size |
|
93 * @since S60 v3.2 |
|
94 * @param aPkgid Package id |
|
95 * @param aSize Size in bytes |
|
96 * @return None |
|
97 */ |
|
98 |
|
99 void GetDownloadedUpdatePackageSizeL(const TInt aPkgid, TInt& aSize); |
|
100 |
|
101 |
|
102 /** |
|
103 * Closes stream to package file |
|
104 * @since S60 v3.1 |
|
105 * @param pkgid Package id |
|
106 * @return none |
|
107 */ |
|
108 void UpdatePackageDownloadCompleteL(const TInt aPkgId); |
|
109 |
|
110 /** |
|
111 * Gets path to package |
|
112 * @since S60 v3.1 |
|
113 * @param pkgid Package id |
|
114 * @param aPath path to file |
|
115 * @return none |
|
116 */ |
|
117 void GetUpdatePackageLocationL(const TInt aPkgId, TDes8& aPath ); |
|
118 |
|
119 |
|
120 /** |
|
121 * Gets present packages |
|
122 * @since S60 v3.1 |
|
123 * @param aPackageIdList List of package ids |
|
124 * @return none |
|
125 */ |
|
126 void GetUpdatePackageIdsL(TDes16& aPackageIdList); |
|
127 |
|
128 |
|
129 /** |
|
130 * Checks if there is space for pkg. If not (doesnt fit to filesystem) |
|
131 * returns needed space in aSize. |
|
132 * @since S60 v3.1 |
|
133 * @param aSize Space of pkg. On return, needed space. |
|
134 * @return Whether there's free space |
|
135 */ |
|
136 TFreeSpace IsPackageStoreSizeAvailableL(TInt& aSize); |
|
137 |
|
138 |
|
139 /** |
|
140 * Deletes update package |
|
141 * returns needed space in aSize. |
|
142 * @since S60 v3.1 |
|
143 * @param apPkgid Package id |
|
144 * @return none |
|
145 */ |
|
146 void DeleteUpdatePackageL (const TInt aPkgId); |
|
147 |
|
148 |
|
149 |
|
150 /** |
|
151 * Destructor |
|
152 * @since S60 v3.1 |
|
153 * @param none |
|
154 * @return none |
|
155 */ |
|
156 virtual ~CFotaDiskStorage (); |
|
157 |
|
158 public: |
|
159 |
|
160 |
|
161 /** |
|
162 * Stream to pkg file |
|
163 */ |
|
164 RFileWriteStream iFileWriteStream; |
|
165 |
|
166 |
|
167 /** |
|
168 * File server session |
|
169 */ |
|
170 RFs iFs; |
|
171 |
|
172 /** |
|
173 * Size of reservation file. Configured via cenrep. |
|
174 */ |
|
175 TInt iDummySize; |
|
176 |
|
177 |
|
178 |
|
179 /** |
|
180 * Size of chunk used to separate update package file content from |
|
181 * reservation file. |
|
182 */ |
|
183 TInt iChunkSize; |
|
184 |
|
185 private: // new functions |
|
186 |
|
187 |
|
188 /** |
|
189 * Constructor |
|
190 * @since S60 v3.1 |
|
191 * @param none |
|
192 * @return none |
|
193 */ |
|
194 CFotaDiskStorage (); |
|
195 |
|
196 |
|
197 /** |
|
198 * Deletes the update package so that total space reservation file |
|
199 * stays the same (ie 5MB). |
|
200 * @since S60 v3.1 |
|
201 * @param dummy Handle to reservation file |
|
202 * @param aPkgId package file to be deleted |
|
203 * @param aAlreadyAllocated Already allocated bytes by other pkg files |
|
204 * @return none |
|
205 */ |
|
206 void DoDeleteUpdatePackageL ( RFile& dummy, TInt aPkgId |
|
207 , TInt aAlreadyAllocated=0); |
|
208 |
|
209 |
|
210 /** |
|
211 * Checks how much space is allocated by package files |
|
212 * @since S60 v3.1 |
|
213 * @param aSwupdSize Size allocated by package files |
|
214 * @param aDummySize Size allocated by reservation file |
|
215 * @return none |
|
216 */ |
|
217 void SpaceAllocatedBySWUPDFilesL( TInt& aSwupdSize, TInt& aDummySize); |
|
218 |
|
219 }; |
|
220 |
|
221 |
|
222 #endif //__FOTADISKSTORAGE_H_ |