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