|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Fotaengine hdr |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __FOTAENGINE_H__ |
|
21 #define __FOTAENGINE_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <e32def.h> |
|
26 #include <badesca.h> |
|
27 #include <AknServerApp.h> |
|
28 #include <SyncMLDef.h> |
|
29 #include <apacmdln.h> |
|
30 #include <apgtask.h> |
|
31 #include <coemain.h> |
|
32 #include <s32file.h> |
|
33 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
34 #include <uikon.hrh> |
|
35 #else |
|
36 #include <uikon.hrh> |
|
37 #include <uiklaf/private/pluginuid.hrh> |
|
38 #endif |
|
39 |
|
40 |
|
41 #include "fotaengstream.h" |
|
42 #include "fotaConst.h" |
|
43 |
|
44 // CONSTANTS |
|
45 /** FOTA Server commands */ |
|
46 enum TFotaIPCCmds |
|
47 { |
|
48 EFotaFirstCommand = RApaAppServiceBase::KServiceCmdBase, |
|
49 EDeletePackage, |
|
50 EFotaDownload, |
|
51 EFotaDownloadAndUpdate, |
|
52 EGetResult, |
|
53 EGetState, |
|
54 EIsPackageStoreSizeAvailable, |
|
55 EFotaOpenUpdatePackageStore, |
|
56 // Command for getting the downloaded & full size of the update package |
|
57 EFotaGetDownloadUpdatePackageSize, |
|
58 // Command to attempt resuming of the download session for downloading the remaining parts of the update package. |
|
59 // This service is restriced to DM UI and FMS Server. |
|
60 EFotaTryResumeDownload, |
|
61 EFotaUpdate, |
|
62 EUpdatePackageDownloadComplete, |
|
63 EFotaSendChunk, |
|
64 EFotaReleaseChunkHandle, |
|
65 EGetUpdatePackageIds, |
|
66 EGetUpdateTimestamp, |
|
67 EGenericAlertSentForPackage, |
|
68 EScheduledUpdate |
|
69 }; |
|
70 |
|
71 |
|
72 enum TFotaUpdateStates |
|
73 { |
|
74 EFotaDefault, |
|
75 EFotaPendingGenAlert, |
|
76 EFotaDownloadInterrupted, |
|
77 EFotaUpdateInterrupted |
|
78 }; |
|
79 |
|
80 class TFotaScheduledUpdate; |
|
81 |
|
82 // CLASS DECLARATION |
|
83 |
|
84 /** |
|
85 * A client handle to a FOTA engine session. |
|
86 * @lib fotaengine.lib |
|
87 * @since Series 60 3.1 |
|
88 */ |
|
89 class RFotaEngineSession : public RAknAppServiceBase |
|
90 { |
|
91 |
|
92 friend class TDP2StreamBuf; // TDP2StreamBuf will use iChunk |
|
93 |
|
94 public: // enums |
|
95 |
|
96 /** |
|
97 * An enumeration of the firmware update progress state codes as specified |
|
98 * in FUMO spec. |
|
99 */ |
|
100 enum TState |
|
101 { |
|
102 /** No firmware update has been started */ |
|
103 EIdle = 10, |
|
104 /** Client has sent a client initiated request */ |
|
105 EClientRequest = 5, |
|
106 /** There is no data available and download is about to start */ |
|
107 EStartingDownload = 15, |
|
108 /** Download failed and there is no data received */ |
|
109 EDownloadFailed = 20, |
|
110 /** Download is progressing with resume support. This is an internal state and is not a valid FUMO state. |
|
111 * Only DM UI and Fota Server can get this state; others get state 30 instead.*/ |
|
112 EDownloadProgressingWithResume = 25, |
|
113 /** Download is progressing without resume support. */ |
|
114 EDownloadProgressing = 30, |
|
115 /** Have data and download has been completed successfully */ |
|
116 EDownloadComplete = 40, |
|
117 /** Have data and about to start update */ |
|
118 EStartingUpdate = 50, |
|
119 /** Denotes that the update is currently running, but has not yet |
|
120 completed */ |
|
121 EUpdateProgressing = 60, |
|
122 /** Have data but update failed */ |
|
123 EUpdateFailed = 70, |
|
124 /** Update failed and data deleted or removed */ |
|
125 EUpdateFailedNoData = 80, |
|
126 /** Update complete and data still available */ |
|
127 EUpdateSuccessful = 90, |
|
128 /** Data deleted or removed after a successful update */ |
|
129 EUpdateSuccessfulNoData = 100, |
|
130 }; |
|
131 |
|
132 /** |
|
133 * An enumeration of the firmware update result codes as specified |
|
134 * in the OMA Firmware Update Management Oobject specification. |
|
135 */ |
|
136 |
|
137 enum TResult |
|
138 { |
|
139 EResSuccessful = 200, |
|
140 EResUserCancelled = 401, |
|
141 EResCorruptedFWUPD = 402, |
|
142 EResPackageMismatch = 403, |
|
143 EResFailedSignatureAuthentication = 404, |
|
144 EResUndefinedError = 409, |
|
145 EResUpdateFailed = 410, |
|
146 EResMalformedOrBadURL = 411, |
|
147 EResAlternateDLServerUnavailable = 412, |
|
148 EResDLFailDueToDeviceOOM = 501, |
|
149 EResDLFailDueToNWIssues = 503 |
|
150 }; |
|
151 |
|
152 public: // Constructors |
|
153 |
|
154 IMPORT_C RFotaEngineSession(); |
|
155 |
|
156 public: // new functions |
|
157 /** |
|
158 * Opens session to Fota Engine |
|
159 * |
|
160 * @since Series 60 3.1 |
|
161 * @param None |
|
162 * @return None |
|
163 */ |
|
164 IMPORT_C void OpenL(); |
|
165 |
|
166 /** |
|
167 * Closes session to Fota Engine |
|
168 * |
|
169 * @since Series 60 3.1 |
|
170 * @param None |
|
171 * @return None |
|
172 */ |
|
173 IMPORT_C void Close(); |
|
174 |
|
175 |
|
176 /** |
|
177 * Called when DM server calls execute command to |
|
178 * Firmware update object URI ./FUMO/<x>/Download |
|
179 * Initiates a firmware download for the specified update package. |
|
180 * |
|
181 * @since Series 60 3.1 |
|
182 * @param aPkgId Unique identifier of the update package. |
|
183 * Mapped to Mgmt URI ./FUMO/<x> in DM Framework |
|
184 * @param aPkgURL Contains the URL where the firmware update package |
|
185 * or download |
|
186 * descriptor is located. This URL is used for |
|
187 * alternative download |
|
188 * mechanism such as Descriptor Based Download. |
|
189 * Mgmt URI ./FUMO/<x>/Download/PkgURL |
|
190 * @param aProfileId ProfileId of the DM server that send the execute |
|
191 * command |
|
192 * @param aPkgName Name associated with the firmware update package, |
|
193 * may be empty |
|
194 * Mgmt URI ./FUMO/<x>/PkgName |
|
195 * @param aPkgVersion Version information for the firmware update |
|
196 * package, |
|
197 * may be empty. |
|
198 * Mgmt URI./FUMO/<x>/PkgVersion |
|
199 * @return Immediate result of the command |
|
200 * KErrNotFound: url doesn't exist |
|
201 */ |
|
202 IMPORT_C TInt Download( |
|
203 const TInt aPkgId |
|
204 ,const TDesC8& aPkgURL |
|
205 ,const TSmlProfileId aProfileId |
|
206 ,const TDesC8& aPkgName |
|
207 ,const TDesC8& aPkgVersion); |
|
208 |
|
209 |
|
210 /** |
|
211 * Called when DM server calls execute command to |
|
212 * Firmware update object URI ./FUMO/<x>/DownloadAndUpdate |
|
213 * Initiates a firmware download and an immediate update for the specified |
|
214 * update package. |
|
215 * |
|
216 * @since Series 60 3.1 |
|
217 * @param aPkgId Unique identifier of the update package. |
|
218 * Mapped to Mgmt URI ./FUMO/<x> in DM Framework |
|
219 * @param aPkgURL Contains the URL where the firmware update package or |
|
220 * download descriptor is located. This URL is used for |
|
221 * alternative download mechanism such as Descriptor |
|
222 * Based Download. |
|
223 * Mgmt URI ./FUMO/<x>/DownloadAndUpdate/PkgURL |
|
224 * @param aProfileId ProfileId of the DM server that send the execute |
|
225 * command |
|
226 * @param aPkgName Name associated with the firmware update package, |
|
227 * may be empty. |
|
228 * Mgmt URI ./FUMO/<x>/PkgName |
|
229 * @param aPkgVersion Version information for the firmware update |
|
230 * package, may be empty. |
|
231 * Mgmt URI./FUMO/<x>/PkgVersion |
|
232 * @return Immediate result of the command |
|
233 */ |
|
234 IMPORT_C TInt DownloadAndUpdate( |
|
235 const TInt aPkgId |
|
236 ,const TDesC8& aPkgURL |
|
237 ,const TSmlProfileId aProfileId |
|
238 ,const TDesC8& aPkgName |
|
239 ,const TDesC8& aPkgVersion); |
|
240 |
|
241 |
|
242 /** |
|
243 * Called when DM server calls execute command to |
|
244 * Firmware update object URI ./FUMO/<x>/Update |
|
245 * Initiates a firmware update for the specified update package. |
|
246 * Firmware Update Package should be already downloaded to the device |
|
247 * either using DM Large Object or OMA OTA download mechanisms. |
|
248 * |
|
249 * @since Series 60 3.1 |
|
250 * @param aPkgId Unique identifier of the update package. |
|
251 * @param aProfileId ProfileId of the DM server that send the execute |
|
252 * command |
|
253 * @param aPkgName Name associated with the firmware update package, may |
|
254 * be empty. |
|
255 * Mgmt URI ./FUMO/<x>/PkgName |
|
256 * @param aPkgVersion Version information for the firmware update |
|
257 * package, may be empty. |
|
258 * Mgmt URI./FUMO/<x>/PkgVersion |
|
259 * @return Immediate result of the command |
|
260 */ |
|
261 IMPORT_C TInt Update( |
|
262 const TInt aPkgId |
|
263 ,const TSmlProfileId aProfileId |
|
264 ,const TDesC8& aPkgName |
|
265 ,const TDesC8& aPkgVersion); |
|
266 |
|
267 |
|
268 /** |
|
269 * Called when DM server is about to start sending |
|
270 * new firmware update package using DM Large Object download. |
|
271 * This function is used to enquire if there is enough space available |
|
272 * for the firmware update package. |
|
273 * e.g when DM server is about to start sending new firmware update package using |
|
274 * DM Large Object download. |
|
275 |
|
276 * |
|
277 * @since Series 60 3.1 |
|
278 * @param aSize Size of the firmware update package. Since |
|
279 * continuation of interrupted downloads is not supported |
|
280 * , this means new update package. |
|
281 * @return ETrue if there is enough space available, EFalse |
|
282 * otherwise |
|
283 */ |
|
284 IMPORT_C TBool IsPackageStoreSizeAvailable( const TInt aSize ); |
|
285 |
|
286 |
|
287 /** |
|
288 * Opens stream to update package storage. |
|
289 * Call UpdatePackageDownloadComplete when package is completely written. |
|
290 * |
|
291 * @since Series 60 3.1 |
|
292 * @param aPkgId Unique identifier of the update package. Download mgr |
|
293 * may use value -1. |
|
294 * @param aPkgStore On return, open stream in which file may be written |
|
295 * to. |
|
296 * @return Immediate result of the command. KErrInUse store is |
|
297 * already opened |
|
298 */ |
|
299 IMPORT_C TInt OpenUpdatePackageStore( const TInt aPkgId |
|
300 , RWriteStream*& aPkgStore ); |
|
301 |
|
302 /** |
|
303 * Gets the downloaded and full size of the update package. |
|
304 * Called by Download Manager during resume operation to know the size of partially downloaded package. |
|
305 * @since Series 60 3.2.2 |
|
306 * @param aPkgId Unique identifier of the update package. |
|
307 * @param aDownloadedSize On return, size of the downloaded package in bytes |
|
308 * @param aTotalSize On return, full size of the download package in bytes |
|
309 * |
|
310 * @return KErrNone when successful, else System wide errors |
|
311 * |
|
312 */ |
|
313 |
|
314 IMPORT_C TInt GetDownloadUpdatePackageSize( const TInt aPkgId, TInt& aDownloadedSize, TInt& aTotalSize ); |
|
315 |
|
316 /** |
|
317 * Requests to resume the suspended download of the update package. |
|
318 * Called by Fota Monitory Service. for ex, when network is available again. |
|
319 * @since Series 60 3.2.2 |
|
320 * @param None |
|
321 * |
|
322 * @return KErrNone when successful, else System wide errors |
|
323 * |
|
324 */ |
|
325 |
|
326 IMPORT_C TInt TryResumeDownload(); |
|
327 |
|
328 |
|
329 /** |
|
330 * Call this when download of update package is completed. In case of |
|
331 * software error or network interruption, this is not called and package |
|
332 * store is left empty. When this is called, fotaengine closes the stream |
|
333 * and associated storage. |
|
334 * |
|
335 * @since Series 60 3.1 |
|
336 * @param aPkgId Unique identifier of the update package. Download |
|
337 * mgr may use value -1. |
|
338 * @return None |
|
339 */ |
|
340 IMPORT_C void UpdatePackageDownloadComplete( const TInt aPkgId ); |
|
341 |
|
342 |
|
343 /** |
|
344 * Called when caller wants to enquire State of specified |
|
345 * firmware update. If the State is unknown to FOTA Engine, then it should |
|
346 * return EIdle. |
|
347 * |
|
348 * @since Series 60 3.1 |
|
349 * @param aPkgId Unique identifier of the update package. |
|
350 * @return State reached by specified firmware update package |
|
351 */ |
|
352 IMPORT_C TState GetState( const TInt aPkgId ); |
|
353 |
|
354 |
|
355 /** |
|
356 * Called when caller wants to enquire Final Result Code of specified |
|
357 * firmware update operation. If the update operation is not yet reached |
|
358 * final stage, then -1 should be returned to the caller. Possible Final |
|
359 * Result Codes are specified in OMA FUMO Specification. Note that Download |
|
360 * operation also ends to final result code e.g. 202 - Successful Download. |
|
361 * |
|
362 * @since Series 60 3.1 |
|
363 * @param aPkgId Unique identifier of the update package. |
|
364 * @return Result code as specified in FUMO specification, -1 if |
|
365 * not yet reached final result. |
|
366 */ |
|
367 IMPORT_C TInt GetResult( const TInt aPkgId ); |
|
368 |
|
369 |
|
370 /** |
|
371 * Called when DM server deletes firmware update management object |
|
372 * from device's management tree. I.e. Delete to mgmt URI ./FUMO/<x>. |
|
373 * If FOTA Engine has not yet deleted specified update package, then it |
|
374 * should do so. |
|
375 * |
|
376 * @since Series 60 3.1 |
|
377 * @param aPkgId Unique identifier of the update package. |
|
378 * @return Result code |
|
379 */ |
|
380 IMPORT_C TInt DeleteUpdatePackage( const TInt aPkgId ); |
|
381 |
|
382 |
|
383 /** |
|
384 * Retrieves the timestamp of last succesful update. |
|
385 * |
|
386 * @since Series 60 3.1 |
|
387 * @param aUpdate On return, contains time of last succesfull update |
|
388 * @return Error code. KErrUnknown if device has never been |
|
389 * updated. |
|
390 */ |
|
391 IMPORT_C TInt LastUpdate( TTime& aUpdate ); |
|
392 |
|
393 /** |
|
394 * Tells device FW version |
|
395 * |
|
396 * @since Series 60 3.1 |
|
397 * @param aSWVersion On return, contains FW version of device. |
|
398 * @return Error code |
|
399 */ |
|
400 IMPORT_C TInt CurrentVersion( TDes& aSWVersion ); |
|
401 |
|
402 /** |
|
403 * Gets IDs of the present update packages. |
|
404 * |
|
405 * @since Series 60 3.1 |
|
406 * @param aPackageIdList On return, contains array of pkg ids |
|
407 * @return Error code |
|
408 */ |
|
409 IMPORT_C TInt GetUpdatePackageIds( TDes16& aPackageIdList ); |
|
410 |
|
411 IMPORT_C TVersion Version() const; |
|
412 |
|
413 |
|
414 /** |
|
415 * Tells fotaserver that generic alert for package is sent. |
|
416 * When fotaengine session is closed, cleanup for package |
|
417 * is done. |
|
418 * |
|
419 * @since Series 60 3.1 |
|
420 * @param aPackageId |
|
421 * @return Error code |
|
422 */ |
|
423 IMPORT_C void GenericAlertSentL( const TInt aPackageID ) ; |
|
424 |
|
425 |
|
426 /** |
|
427 * Like Update, but called by scheduler mechanism. |
|
428 * Needed package details (profile id etc are already known) |
|
429 * |
|
430 * @since Series 60 3.2 |
|
431 * @param aSchedule Schedule data |
|
432 * @return Error code |
|
433 */ |
|
434 IMPORT_C TInt ScheduledUpdateL( TFotaScheduledUpdate aSchedule ); |
|
435 |
|
436 |
|
437 private: // From RApaAppServiceBase |
|
438 |
|
439 /** Returns the UID of the service that this session provides an |
|
440 * interface for. Client side service implementations must implement this |
|
441 * function to return the UID for the service that they implement. |
|
442 * |
|
443 * @since Series 60 3.1 |
|
444 * @param None |
|
445 * @return The UID of the service implemented by the derived class. |
|
446 */ |
|
447 TUid ServiceUid() const; |
|
448 |
|
449 IMPORT_C virtual void ExtensionInterface( |
|
450 TUid aInterfaceId |
|
451 ,TAny*& aImplementation ); |
|
452 |
|
453 private: // New methods |
|
454 |
|
455 /** |
|
456 * Signals the server to read chunk contents |
|
457 * |
|
458 * @since Series 60 3.1 |
|
459 * @param aP1 Pointer to beginning of content |
|
460 * @param aP2 Pointer to end of content |
|
461 * @return |
|
462 **/ |
|
463 void SendChunkL(const TUint8* aP1, const TUint8* aP2); |
|
464 |
|
465 |
|
466 /** |
|
467 * Signals the server to release chunk handle |
|
468 * |
|
469 * @since Series 60 3.1 |
|
470 * @param None |
|
471 * @return |
|
472 **/ |
|
473 TInt ReleaseChunkHandle(); |
|
474 |
|
475 /** |
|
476 * Starts fotaserver server application. |
|
477 * |
|
478 * @since Series 60 3.1 |
|
479 * @param aNameUid Differentiator. |
|
480 * @param aAppServerUid FotaServer app uid |
|
481 * @return None |
|
482 **/ |
|
483 void StartApplicationL( const TUid& aNameUid,const TUid& aAppServerUid ); |
|
484 |
|
485 |
|
486 /** |
|
487 * Connects to running fotaserver instance |
|
488 * |
|
489 * @since Series 60 3.1 |
|
490 * @param aNameUid Differentiator. |
|
491 * @param aAppServerUid FotaServer app uid |
|
492 * @return None |
|
493 **/ |
|
494 void ConnectToServerL( const TUid& aNameUid,const TUid& aAppServerUid ); |
|
495 |
|
496 private: // Data |
|
497 |
|
498 /** |
|
499 * Stream for writing swupd file to chunk |
|
500 */ |
|
501 RFotaWriteStream* iStream; |
|
502 |
|
503 /** |
|
504 * Chunk for sending swupd contents to fotaserver |
|
505 */ |
|
506 RChunk iChunk; |
|
507 |
|
508 |
|
509 /** |
|
510 * If not -1 , indicates that generic alert has been sent for this package |
|
511 */ |
|
512 TInt iGenericAlertSentPkgID; |
|
513 |
|
514 }; |
|
515 |
|
516 |
|
517 #endif // __FOTAENGINE_H__ |