fotaapplication/fotaserver/FotaEngine/SRC/fotaengine.cpp
branchRCL_3
changeset 25 b183ec05bd8c
parent 24 13d7c31c74e0
child 26 19bba8228ff0
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
     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 "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:   Client for fotaserver
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include <bldvariant.hrh>
       
    23 #include "fotaengine.h"
       
    24 #include "FotaIPCTypes.h"
       
    25 #include "fotaConst.h"
       
    26 #include "fotaenginedebug.h"
       
    27 #include <apgcli.h>
       
    28 #include <AknServerApp.h>
       
    29 
       
    30 // CONSTANTS
       
    31 _LIT(KServerNameFormat, "%08x_%08x_AppServer");        
       
    32 
       
    33 // =================== LOCAL FUNCTIONS ========================================
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // IsClientFota()   Checks if client is another fotaserver
       
    37 // ---------------------------------------------------------------------------
       
    38 TBool IsClientFota()
       
    39     {
       
    40     RThread thread;
       
    41     TUid    fota,dlmgr;
       
    42     fota.iUid           = KFotaServerUid;
       
    43     dlmgr.iUid			= KDLMgrServerUid;
       
    44     if (thread.SecureId() == fota.iUid || thread.SecureId() == dlmgr.iUid )
       
    45         {
       
    46         return ETrue;
       
    47         }
       
    48     return EFalse;
       
    49     }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // RFotaEngineSession::StartServerL() 
       
    54 // Start application server
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 void RFotaEngineSession::StartApplicationL( const TUid& aNameUid
       
    58                                             , const TUid& aAppServerUid )
       
    59     {
       
    60     TInt err;
       
    61     FLOG(_L("RFotaEngineSession::StartApplicationL >>"));
       
    62     RApaLsSession apa;
       
    63     err = apa.Connect();
       
    64     User::LeaveIfError(err);
       
    65     CleanupClosePushL(apa);
       
    66 
       
    67     // Get application information
       
    68     TApaAppInfo info;
       
    69     err=0;
       
    70     for(TInt i = 20; ((err = apa.GetAppInfo(info, 
       
    71 	    aAppServerUid)) == RApaLsSession::EAppListInvalid) && i > 0; i--)
       
    72         {
       
    73         User::After(500000);
       
    74         }
       
    75     User::LeaveIfError(err);
       
    76 
       
    77     // Start aplication server
       
    78     CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
    79     cmdLine->SetExecutableNameL(info.iFullName);
       
    80     cmdLine->SetServerRequiredL( aNameUid.iUid );
       
    81     cmdLine->SetCommandL(EApaCommandBackground);
       
    82     TThreadId   srvid;
       
    83     err = apa.StartApp(*cmdLine, srvid);
       
    84     User::LeaveIfError(err);
       
    85 
       
    86     // Wait until server is running.
       
    87 
       
    88     // Rendezvous() is not reliable for synchronising with the new server
       
    89     // in this case as we may not be able
       
    90     // to open the server thread before it has reached its rendezvous
       
    91     // point, in which case we hang.
       
    92     // So, the standby algorithm is to poll for server existence (yuk)
       
    93 	const TInt maxPoll = 100;
       
    94 	const TInt waitDelay = 100000;	// 0.1 seconds
       
    95     TFullName serverName;
       
    96     serverName.Format(KServerNameFormat, aNameUid, aAppServerUid);
       
    97 	for (TInt ii = 0; ii < maxPoll; ii++)
       
    98 		{
       
    99 		// look for the server name
       
   100 		TFindServer find(serverName);
       
   101 		TFullName fullName;
       
   102         err = find.Next(fullName);
       
   103 		if ( err == KErrNone)
       
   104 			{
       
   105 			break;		// found the server, so return
       
   106 			}
       
   107 		User::After(waitDelay);			// wait before trying again
       
   108 		}
       
   109 	User::LeaveIfError(err);	// failed to find the server, bomb out
       
   110 
       
   111     CleanupStack::PopAndDestroy(2, &apa);	// cmdLine and apa
       
   112     FLOG(_L("RFotaEngineSession::StartApplicationL <<"));
       
   113     }
       
   114 
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // RFotaEngineSession::StartServerL() 
       
   118 // Connect to existing server
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void RFotaEngineSession::ConnectToServerL( const TUid& aNameUid
       
   122                                             , const TUid& aAppServerUid )
       
   123     {
       
   124     RWsSession  ws;
       
   125     TInt        err;
       
   126 
       
   127     FLOG(_L("RFotaEngineSession::ConnectToServerL >>"));
       
   128     if (aAppServerUid == KNullUid)
       
   129         {
       
   130         User::Leave(KErrGeneral);
       
   131         }
       
   132 
       
   133 	// Connect to server
       
   134     TFullName serverName;
       
   135 	serverName.Format(KServerNameFormat, 
       
   136 	aNameUid, aAppServerUid);
       
   137     TRAP(err, ConnectExistingByNameL(serverName) );
       
   138     if(err)
       
   139         {
       
   140         TVersion vers(0,0,1);
       
   141         err = CreateSession (serverName, vers);
       
   142         User::LeaveIfError(err);
       
   143         }
       
   144     FLOG(_L("       3"));
       
   145 
       
   146     FLOG(_L("RFotaEngineSession::ConnectToServerL <<"));
       
   147     }
       
   148     
       
   149 // ---------------------------------------------------------------------------
       
   150 // RFotaEngineSession::OpenL( )
       
   151 // Opens session to fotaserver. 
       
   152 // ---------------------------------------------------------------------------
       
   153 EXPORT_C void RFotaEngineSession::OpenL( )
       
   154 {
       
   155     RProcess pr; TFullName fn = pr.FullName(); 
       
   156     TInt err(0);
       
   157     TUid diff1 = TUid::Uid(KUikonUidPluginInterfaceNotifiers);
       
   158     FLOG(_L("[RFotaEngineSession] OpenL\tcalled by '%S' >>"),&fn );
       
   159 
       
   160     // -------------------------------------------- V
       
   161     err = KErrNotFound;
       
   162     // If client is fotaserver - MUST create new server
       
   163     if( !IsClientFota() ) 
       
   164         {
       
   165         TRAP(err, ConnectToServerL( diff1 , TUid::Uid(KFotaServerUid)) );
       
   166         }
       
   167     else
       
   168         {
       
   169         diff1 = TUid::Uid(KUikonUidPluginInterfaceNotifiers+1);
       
   170         }
       
   171 
       
   172     if(err!=KErrNone)
       
   173         {
       
   174         StartApplicationL( diff1 , TUid::Uid(KFotaServerUid));
       
   175         ConnectToServerL( diff1 , TUid::Uid(KFotaServerUid));
       
   176         }
       
   177     FLOG(_L("[RFotaEngineSession]\tconnected <<") );
       
   178 }
       
   179 
       
   180 
       
   181 // ---------------------------------------------------------------------------
       
   182 // RFotaEngineSession::Close( )
       
   183 // Closes session to fotaserver
       
   184 // ---------------------------------------------------------------------------
       
   185 EXPORT_C void RFotaEngineSession::Close( )
       
   186 {
       
   187     RProcess pr; TFullName fn = pr.FullName(); 
       
   188     FLOG(_L("[RFotaEngineSession] RFotaEngineSession::Close() >> called by '%S'"),&fn );
       
   189         
       
   190     if ( iStream )
       
   191         {
       
   192         iStream->Close(); // this uses iChunk
       
   193         delete iStream;  iStream=0;
       
   194         }
       
   195     iChunk.Close();
       
   196 
       
   197     // Tell server that generic alert is sent for this pkg, so state is 
       
   198     // cleaned up     
       
   199     if ( iGenericAlertSentPkgID != -1 )
       
   200         {
       
   201         TInt err = SendReceive( EGenericAlertSentForPackage
       
   202                                     , TIpcArgs(iGenericAlertSentPkgID) );
       
   203         }
       
   204 
       
   205     REikAppServiceBase::Close();
       
   206     FLOG(_L("[RFotaEngineSession] RFotaEngineSession::Close() <<") );
       
   207 }
       
   208 
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // RFotaEngineSession::Download
       
   212 // Starts download of upd package.
       
   213 // ---------------------------------------------------------------------------
       
   214 EXPORT_C TInt RFotaEngineSession::Download(const TInt aPkgId
       
   215     , const TDesC8& aPkgURL, const TSmlProfileId aProfileId
       
   216     , const TDesC8& aPkgName, const TDesC8& aPkgVersion)
       
   217 {
       
   218     TInt err;
       
   219     TDownloadIPCParams          ipcparam;
       
   220     ipcparam.iPkgId             = aPkgId;
       
   221     ipcparam.iProfileId         = aProfileId;
       
   222     ipcparam.iPkgName.Copy      (aPkgName);
       
   223     ipcparam.iPkgVersion.Copy   (aPkgVersion);
       
   224     TPckg<TDownloadIPCParams>   pkg(ipcparam);
       
   225     err = SendReceive ( EFotaDownload ,  TIpcArgs(&pkg, &aPkgURL));
       
   226     return err;
       
   227 }
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // RFotaEngineSession::DownloadAndUpdate
       
   231 // Starts download and update of update pakcage
       
   232 // ---------------------------------------------------------------------------
       
   233 EXPORT_C TInt RFotaEngineSession::DownloadAndUpdate(const TInt aPkgId
       
   234         ,const TDesC8& aPkgURL, const TSmlProfileId aProfileId
       
   235         ,const TDesC8& aPkgName, const TDesC8& aPkgVersion)
       
   236 {
       
   237     TInt err;
       
   238     TDownloadIPCParams          ipcparam;
       
   239     ipcparam.iPkgId             = aPkgId;
       
   240     ipcparam.iProfileId         = aProfileId;
       
   241     ipcparam.iPkgName.Copy      (aPkgName);
       
   242     ipcparam.iPkgVersion.Copy   (aPkgVersion);
       
   243     TPckg<TDownloadIPCParams>   pkg(ipcparam);
       
   244     err = SendReceive( EFotaDownloadAndUpdate,  TIpcArgs(&pkg, &aPkgURL));
       
   245     return err;
       
   246 }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // RFotaEngineSession::Update
       
   250 // Starts update of update package
       
   251 // ---------------------------------------------------------------------------
       
   252 EXPORT_C TInt RFotaEngineSession::Update(const TInt aPkgId
       
   253         ,const TSmlProfileId aProfileId, const TDesC8& aPkgName
       
   254         ,const TDesC8& aPkgVersion)
       
   255 {
       
   256     TInt err;
       
   257     TDownloadIPCParams          ipcparam;
       
   258     ipcparam.iPkgId             = aPkgId;
       
   259     ipcparam.iProfileId         = aProfileId;
       
   260     ipcparam.iPkgName.Copy      (aPkgName);
       
   261     ipcparam.iPkgVersion.Copy   (aPkgVersion);
       
   262     TPckg<TDownloadIPCParams>   pkg(ipcparam);
       
   263     err = SendReceive ( EFotaUpdate ,  TIpcArgs(&pkg));
       
   264     return err;
       
   265 }
       
   266 
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // RFotaEngineSession::IsPackageStoreSizeAvailable
       
   270 // Checks if there's space enough for update package
       
   271 // ---------------------------------------------------------------------------
       
   272 EXPORT_C TBool RFotaEngineSession::IsPackageStoreSizeAvailable(
       
   273                                                     const TInt aSize)
       
   274     {
       
   275 //    // -------------------------------------------- v 
       
   276 //    if( IsClientFota() ) 
       
   277 //        {
       
   278 //        FLOG(_L("     IsPackageStoreSizeAvailable  NOT CONNECTING"));
       
   279 //        return ETrue;
       
   280 //        }
       
   281 //    // -------------------------------------------- ^ 
       
   282     TInt            err;
       
   283     TBool           available;
       
   284     TPckg<TBool>    pavailable(available);
       
   285     err = SendReceive ( EIsPackageStoreSizeAvailable, TIpcArgs(aSize
       
   286                                                         , &pavailable ) );
       
   287     if ( err ) 
       
   288         {   
       
   289         FLOG(_L("RFotaEngineSession::IsPackageStoreSizeAvailable error %d")
       
   290                     ,err);
       
   291         }
       
   292     return available;
       
   293     }
       
   294 
       
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 // RFotaEngineSession::OpenUpdatePackageStore
       
   298 // OPens update package storage for writing.
       
   299 // ---------------------------------------------------------------------------
       
   300 EXPORT_C TInt RFotaEngineSession::OpenUpdatePackageStore(const TInt aPkgId
       
   301                                                  ,RWriteStream*& aPkgStore)
       
   302 	{
       
   303     FLOG(_L( "RFotaEngineSession::OpenUpdatePackageStore >> pkgid %d " )
       
   304                     ,aPkgId );
       
   305     TInt err;
       
   306     err = iChunk.CreateGlobal( KNullDesC, KFotaChunkMinSize, KFotaChunkMaxSize );
       
   307     if(err) return err;
       
   308     iStream = new RFotaWriteStream();
       
   309     iStream->iFotaEngineSession = this;    
       
   310     TRAP( err, iStream->OpenL(aPkgId) );
       
   311     aPkgStore = iStream;
       
   312     if(err) return err;
       
   313 
       
   314     TIpcArgs args;
       
   315     args.Set(0,aPkgId);
       
   316     args.Set(1,iChunk );
       
   317 	err = SendReceive( EFotaOpenUpdatePackageStore, args );
       
   318     FLOG(_L( "RFotaEngineSession::OpenUpdatePackageStore << err  %d" ),err );
       
   319     return err;
       
   320     }
       
   321 // ---------------------------------------------------------------------------
       
   322 // RFotaEngineSession::GetDownloadUpdatePackageSize
       
   323 // Gets the downloaded and full size of the update package. 
       
   324 // Implementation is not ready and will be provided later.
       
   325 // ---------------------------------------------------------------------------
       
   326 EXPORT_C TInt RFotaEngineSession::GetDownloadUpdatePackageSize(const TInt aPkgId, TInt& aDownloadedSize, TInt& aTotalSize)
       
   327 	{
       
   328 	FLOG(_L("RFotaEngineSession::GetDownloadUpdatePackageSize, aPkgId=%d >>"),aPkgId);
       
   329 	TInt err (KErrNone);
       
   330     TPckg<TInt> pkg1(aDownloadedSize);
       
   331     TPckg<TInt>	pkg2(aTotalSize);
       
   332 	err = SendReceive( EFotaGetDownloadUpdatePackageSize,TIpcArgs(aPkgId,&pkg1, &pkg2)  );
       
   333 	FLOG(_L("RFotaEngineSession::GetDownloadUpdatePackageSize << err = %d, aDownloadedSize = %d, aTotalSize = %d" ), err, aDownloadedSize, aTotalSize);
       
   334 	return err;
       
   335 	}
       
   336 
       
   337 // ---------------------------------------------------------------------------
       
   338 // RFotaEngineSession::TryResumeDownload
       
   339 // Requests to resume the suspended download of the update package. 
       
   340 // Implementation is not ready and will be provided later.
       
   341 // ---------------------------------------------------------------------------
       
   342 EXPORT_C TInt RFotaEngineSession::TryResumeDownload()
       
   343 	{
       
   344 	FLOG(_L("RFotaEngineSession::TryResumeDownload >>"));
       
   345 
       
   346 	TInt err = KErrNone;
       
   347 	
       
   348 	err = SendReceive( EFotaTryResumeDownload );
       
   349 	
       
   350 	FLOG(_L("RFotaEngineSession::TryResumeDownload << err = %d" ),err);
       
   351 	return err;
       
   352 	}
       
   353 
       
   354 // ---------------------------------------------------------------------------
       
   355 // RFotaEngineSession::UpdatePackageDownloadComplete
       
   356 // Ends update pkg storing. Closes resources.
       
   357 // ---------------------------------------------------------------------------
       
   358 EXPORT_C void RFotaEngineSession::UpdatePackageDownloadComplete(
       
   359                                                           const TInt aPkgId)
       
   360     {
       
   361     FLOG(_L("RFotaEngineSession::UpdatePackageDownloadComplete >> id %d")
       
   362                             ,aPkgId);
       
   363     if ( iStream )
       
   364         {
       
   365         iStream->Close();
       
   366         delete iStream;
       
   367         iStream=0;
       
   368         }
       
   369     TInt err = SendReceive(EUpdatePackageDownloadComplete, TIpcArgs(aPkgId) );
       
   370     FLOG(_L("RFotaEngineSession::UpdatePackageDownloadComplete << error %d ")
       
   371                             ,err);
       
   372     }
       
   373 
       
   374 
       
   375 // ---------------------------------------------------------------------------
       
   376 // RFotaEngineSession::GetState
       
   377 // ---------------------------------------------------------------------------
       
   378 EXPORT_C RFotaEngineSession::TState RFotaEngineSession::GetState(
       
   379                                                          const TInt aPkgId)
       
   380     {
       
   381     FLOG(_L("RFotaEngineSession::GetState"));
       
   382     TInt err(0);
       
   383     RFotaEngineSession::TState          state;
       
   384     TPckg<RFotaEngineSession::TState>   pkgstate(state);
       
   385     err = SendReceive ( EGetState , TIpcArgs(aPkgId, &pkgstate));
       
   386     if ( err ) 
       
   387         {
       
   388         FLOG(_L("RFotaEngineSession::GetState error %d"),err);
       
   389         }
       
   390     return state;
       
   391     }
       
   392 
       
   393 
       
   394 // ---------------------------------------------------------------------------
       
   395 // RFotaEngineSession::GetResult    
       
   396 // ---------------------------------------------------------------------------
       
   397 EXPORT_C TInt RFotaEngineSession::GetResult(const TInt aPkgId)
       
   398     {
       
   399     FLOG(_L("RFotaEngineSession::GetResult"));
       
   400     TInt            result;
       
   401     TPckg<TInt>     pkgresult(result);
       
   402     SendReceive ( EGetResult , TIpcArgs(aPkgId, &pkgresult));
       
   403     return result;
       
   404     }
       
   405 
       
   406 
       
   407 // ---------------------------------------------------------------------------
       
   408 // RFotaEngineSession::DeleteUpdatePackage
       
   409 // ---------------------------------------------------------------------------
       
   410 EXPORT_C TInt RFotaEngineSession::DeleteUpdatePackage(const TInt aPkgId)
       
   411 {
       
   412     TInt err = SendReceive(EDeletePackage, TIpcArgs(aPkgId) );
       
   413     return err;
       
   414 }
       
   415 
       
   416 
       
   417 // ---------------------------------------------------------------------------
       
   418 // RFotaEngineSession::LastUpdate
       
   419 // ---------------------------------------------------------------------------
       
   420 EXPORT_C TInt RFotaEngineSession::LastUpdate(TTime& aUpdates)
       
   421     {
       
   422     TInt err;
       
   423     FLOG(_L("RFotaEngineSession::LastUpdate >>"));
       
   424     TBuf<15>                    timestamp;
       
   425     err = SendReceive ( EGetUpdateTimestamp, TIpcArgs(&timestamp) );
       
   426 
       
   427     if ( timestamp.Length() > 0 )
       
   428         {
       
   429         TInt year   = timestamp[0];
       
   430         TInt month  = timestamp[1];
       
   431         TInt day    = timestamp[2];
       
   432         TInt hour   = timestamp[3];
       
   433         TInt minute = timestamp[4];
       
   434         aUpdates = TDateTime (year,(TMonth)month,day,hour,minute,0,0 );
       
   435         }
       
   436     else
       
   437         {
       
   438         aUpdates.Set( _L( "19900327:101010.000000" ) ); 
       
   439         err = KErrUnknown;
       
   440         }
       
   441     FLOG(_L("RFotaEngineSession::LastUpdate <<"));
       
   442     return err;
       
   443     }
       
   444 
       
   445 
       
   446 // ---------------------------------------------------------------------------
       
   447 // RFotaEngineSession::CurrentVersion
       
   448 // ---------------------------------------------------------------------------
       
   449 EXPORT_C TInt RFotaEngineSession::CurrentVersion(TDes& aSWVersion)
       
   450     {
       
   451     aSWVersion.Copy(_L("1.0"));  
       
   452     return KErrNone;
       
   453     }
       
   454 
       
   455 
       
   456 // ---------------------------------------------------------------------------
       
   457 // RFotaEngineSession::ExtensionInterface
       
   458 // ---------------------------------------------------------------------------
       
   459 EXPORT_C void RFotaEngineSession::ExtensionInterface(TUid /*aInterfaceId*/
       
   460                                               ,TAny*& /*aImplementation*/)
       
   461     {
       
   462     RProcess pr; TFullName fn = pr.FullName(); 
       
   463     FLOG(_L("RFotaEngineSession::ExtensionInterface called by %S"), &fn);
       
   464     }
       
   465 
       
   466 
       
   467 // ---------------------------------------------------------------------------
       
   468 // RFotaEngineSession::RFotaEngineSession
       
   469 // ---------------------------------------------------------------------------
       
   470 EXPORT_C RFotaEngineSession::RFotaEngineSession() : iStream(0)
       
   471                     , iGenericAlertSentPkgID(-1)
       
   472     {
       
   473     FLOG(_L("RFotaEngineSession::RFotaEngineSession() >>"));
       
   474     FLOG(_L("RFotaEngineSession::RFotaEngineSession() <<"));
       
   475     }
       
   476 
       
   477 
       
   478 // ---------------------------------------------------------------------------
       
   479 // RFotaEngineSession::GetUpdatePackageIds
       
   480 // Gets ids of the update packages present in the system.
       
   481 // ---------------------------------------------------------------------------
       
   482 EXPORT_C TInt RFotaEngineSession::GetUpdatePackageIds(TDes16& aPackageIdList)
       
   483     {
       
   484     TInt err;
       
   485     FLOG(_L("RFotaEngineSession::GetUpdatePackageIds >>"));
       
   486     TBuf<10> b; b.Copy(_L("dkkd"));
       
   487     TPkgIdList                  pkgids;
       
   488     TPckg<TPkgIdList>           pkgids_pkg(pkgids);
       
   489     TIpcArgs                    args ( &pkgids_pkg);
       
   490     err = SendReceive ( EGetUpdatePackageIds, args);
       
   491     aPackageIdList.Copy(pkgids);
       
   492     FLOG(_L("RFotaEngineSession::GetUpdatePackageIds <<"));
       
   493     return err;
       
   494     }
       
   495 
       
   496 
       
   497 
       
   498 // ---------------------------------------------------------------------------
       
   499 // RFotaEngineSession::GenericAlertSentL
       
   500 // marks genereic alert being sent
       
   501 // ---------------------------------------------------------------------------
       
   502 EXPORT_C void RFotaEngineSession::GenericAlertSentL ( const TInt aPackageID )
       
   503     {
       
   504     iGenericAlertSentPkgID = aPackageID;
       
   505     }
       
   506 
       
   507 // ---------------------------------------------------------------------------
       
   508 // RFotaEngineSession::ScheduledUpdateL
       
   509 // Update fw
       
   510 // ---------------------------------------------------------------------------
       
   511 EXPORT_C TInt RFotaEngineSession::ScheduledUpdateL ( const TFotaScheduledUpdate aSchedule )
       
   512     {
       
   513   	TInt err(KErrNotSupported);
       
   514 
       
   515     TPckg<TFotaScheduledUpdate> p(aSchedule);
       
   516     err = SendReceive( EScheduledUpdate, TIpcArgs(&p) );
       
   517 
       
   518     return err;
       
   519     }
       
   520 
       
   521 // ---------------------------------------------------------------------------
       
   522 // RFotaEngineSession::ServiceUid
       
   523 // Apparc asks which session class to create in server side
       
   524 // ---------------------------------------------------------------------------
       
   525 TUid RFotaEngineSession::ServiceUid() const
       
   526 	{
       
   527     RProcess pr; TFullName fn = pr.FullName(); 
       
   528     FLOG(_L( "RFotaEngineSession::ServiceUid() >> called by: %S" ), &fn );
       
   529     FLOG(_L( "RFotaEngineSession::ServiceUid() << ret: 0x%X" ),
       
   530                                             KFotaServiceUid );
       
   531 	return TUid::Uid( KFotaServiceUid );
       
   532 	}
       
   533 
       
   534 
       
   535 // ---------------------------------------------------------------------------
       
   536 // RFotaEngineSession::SendChunkL
       
   537 // Tells server to read chunk contnets
       
   538 // ---------------------------------------------------------------------------
       
   539 void RFotaEngineSession::SendChunkL(const TUint8* aP1, const TUint8* aP2)
       
   540     {
       
   541     TInt writecount = aP2-aP1;
       
   542     TInt err = SendReceive(EFotaSendChunk, TIpcArgs(writecount) );
       
   543 
       
   544     if ( err )
       
   545         {   
       
   546         FLOG(_L("RFotaEngineSession::SendChunkL error %d"),err);
       
   547         }
       
   548     User::LeaveIfError ( err );
       
   549     }
       
   550 
       
   551 
       
   552 // ---------------------------------------------------------------------------
       
   553 // RFotaEngineSession::ReleaseChunkHandle()
       
   554 // Releases server's handle to the chuhnk
       
   555 // ---------------------------------------------------------------------------
       
   556 TInt RFotaEngineSession::ReleaseChunkHandle()
       
   557 	{
       
   558 	return Send( EFotaReleaseChunkHandle);
       
   559 	}