applicationmanagement/server/src/amstorage.cpp
changeset 42 aa33c2cb9a50
child 62 03849bd79877
equal deleted inserted replaced
41:c742e1129640 42:aa33c2cb9a50
       
     1 /*
       
     2  * Copyright (c) 2000 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 applicationmanagement components
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 #include <centralrepository.h>
       
    20 #include <s32mem.h>
       
    21 #include <s32file.h>
       
    22 #include <e32des8.h>
       
    23 #ifndef __SERIES60_30__
       
    24 #include "AMAppHideUtil.h"
       
    25 #endif
       
    26 #include "debug.h"
       
    27 #include "amprivateCRKeys.h"
       
    28 #include "amstorage.h"
       
    29 #include "AMDeploymentComponent.h"
       
    30 
       
    31 using namespace NApplicationManagement;
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 
       
    36 /***************************************************
       
    37  // RComponentIdArray
       
    38  ***************************************************/
       
    39 
       
    40 void RComponentIdArray::SetListL(const TDesC8& aChilds)
       
    41     {
       
    42 #ifdef _DEBUG
       
    43     HBufC *b = HBufC::NewLC(aChilds.Length() );
       
    44     TPtr p(b->Des() );
       
    45     p.Copy(aChilds);
       
    46     RDEBUG_2( "RComponentIdArray::SetListL: Setting list from: '%S'", &p);
       
    47     CleanupStack::PopAndDestroy(b);
       
    48 #endif
       
    49 
       
    50     RDesReadStream buf(aChilds);
       
    51     //TInt size( buf.Source()->TellL( MStreamBuf::ERead ).SizeL() );
       
    52     TInt left(aChilds.Length() );
       
    53     const TInt KSize(sizeof(TUint32));
       
    54     while (left > 0)
       
    55         {
       
    56         TUint32 val(buf.ReadUint32L() );
       
    57 #ifdef _DEBUG
       
    58         RDEBUG_2( "RComponentIdArray::SetListL: Appending id: '%d'", val);
       
    59 #endif
       
    60         Append(val);
       
    61         left -= KSize;
       
    62         }
       
    63     buf.Close();
       
    64     }
       
    65 
       
    66 void RComponentIdArray::RemoveByValue(TUint32 aValue)
       
    67     {
       
    68     TInt ind(Find(aValue) );
       
    69     Remove(ind);
       
    70     }
       
    71 
       
    72 void RComponentIdArray::GetListLC(HBufC8 *&aChilds, TInt &aLength)
       
    73     {
       
    74     ASSERT( aChilds == NULL );
       
    75     TInt c(Count() );
       
    76     if (c > 0)
       
    77         {
       
    78         aLength = c * sizeof(TUint32);
       
    79         aChilds = HBufC8::NewLC(aLength);
       
    80         TPtr8 p(aChilds->Des() );
       
    81         RDesWriteStream stream(p);
       
    82         CleanupClosePushL(stream);
       
    83         TInt i( 0);
       
    84         do
       
    85             {
       
    86             stream.WriteUint32L(operator[](i) );
       
    87             }
       
    88         while ( ++i < c);
       
    89         stream.CommitL();
       
    90         CleanupStack::PopAndDestroy( &stream);
       
    91         }
       
    92     else
       
    93         {
       
    94         aChilds = KNullDesC8().AllocLC();
       
    95         aLength = 0;
       
    96         }
       
    97     }
       
    98 
       
    99 /*	
       
   100  void TCertInfoPckg::ExternalizeL(RWriteStream& aStream) const
       
   101  {
       
   102  aStream << iId;
       
   103  TPckgBuf<TCertInfo>::ExternalizeL( aStream );
       
   104  }
       
   105 
       
   106  void TCertInfoPckg::InternalizeL(RReadStream& aStream)
       
   107  {
       
   108  
       
   109  }
       
   110  */
       
   111 
       
   112 void RCertArray::ExternalizeL(RWriteStream& aStream) const
       
   113     {
       
   114     TInt c(Count() );
       
   115     aStream.WriteInt32L(c);
       
   116     for (TInt i( 0); i < c; i++)
       
   117         {
       
   118         aStream.WriteInt32L(i);
       
   119         aStream << (*(operator[](i)));
       
   120         }
       
   121     }
       
   122 
       
   123 void RCertArray::InternalizeL(RReadStream& aStream)
       
   124     {
       
   125     TInt c(aStream.ReadInt32L() );
       
   126     for (TInt i( 0); i < c; i++)
       
   127         {
       
   128         TCertInfoPckg *pkg = new ( ELeave ) TCertInfoPckg;
       
   129         RDEBUG_2( "RCertArray::InternalizeL - allocated TCertInfoPckg 0x%X", reinterpret_cast<TUint>( pkg ) );
       
   130         CleanupStack::PushL(pkg);
       
   131         TInt idx(aStream.ReadInt32L() );
       
   132         aStream >> (*pkg);
       
   133         Append(pkg);
       
   134         CleanupStack::Pop(pkg);
       
   135         }
       
   136     }
       
   137 
       
   138 TInt RCertArray::FindByValue(const TCertInfoPckg &aPckg)
       
   139     {
       
   140     TInt c(Count() );
       
   141     for (TInt i( 0); i < c; i++)
       
   142         {
       
   143         if (operator[](i)->Compare(aPckg) == 0)
       
   144             {
       
   145             return i;
       
   146             }
       
   147         }
       
   148     return KErrNotFound;
       
   149     }
       
   150 
       
   151 /***************************************************
       
   152  // CDeliveryComponentStorage
       
   153  ***************************************************/
       
   154 
       
   155 CDeliveryComponentStorage::CDeliveryComponentStorage()
       
   156     {
       
   157 
       
   158     }
       
   159 
       
   160 void CDeliveryComponentStorage::ConstructL()
       
   161     {
       
   162 #ifndef __SERIES60_30__
       
   163     iHidder = CAMAppHideUtil::NewL();
       
   164 #endif
       
   165     LoadCertsL();
       
   166     TRAPD( erx, iRepository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) )
       
   167     ;
       
   168     if (erx != KErrNone)
       
   169         {
       
   170         RDEBUG_2( "CDeliveryComponentStorage::ConstructL() ERROR CentRep not initialized: Check deployment! %d", erx );
       
   171         User::Leave(erx);
       
   172         }
       
   173     TInt err(iRepository->Get(KNextIdKey, iNextId) );
       
   174     if (err == KErrNotFound)
       
   175         {
       
   176         iNextId = KMinIdValue;
       
   177         User::LeaveIfError(iRepository->Create(KNextIdKey, iNextId) );
       
   178         }
       
   179     else
       
   180         {
       
   181         User::LeaveIfError(err);
       
   182         }
       
   183     LoadComponentsL();
       
   184     }
       
   185 
       
   186 void CDeliveryComponentStorage::LoadCertsL()
       
   187     {
       
   188     RFs fs;
       
   189     User::LeaveIfError(fs.Connect() );
       
   190     CleanupClosePushL(fs);
       
   191     TInt e(fs.CreatePrivatePath(KDefaultDrive) );
       
   192 
       
   193     User::LeaveIfError(e);
       
   194     TBuf<64> privatePath;
       
   195     User::LeaveIfError(fs.PrivatePath(privatePath) );
       
   196 
       
   197     TInt privPathLength(privatePath.Length() );
       
   198     _LIT( KCertFile, "amcerts.dat");
       
   199     HBufC *afile = HBufC::NewLC(privPathLength + KCertFile().Length());
       
   200     *afile = privatePath;
       
   201     afile->Des().Append(KCertFile);
       
   202     RFileReadStream certFile;
       
   203     TInt err(certFile.Open(fs, *afile, EFileRead) );
       
   204     if (err == KErrNone)
       
   205         {
       
   206         CleanupClosePushL(certFile);
       
   207         iCertificates.InternalizeL(certFile);
       
   208         CleanupStack::PopAndDestroy( &certFile);
       
   209         }
       
   210     else
       
   211         if (err == KErrNotFound)
       
   212             {
       
   213 
       
   214             }
       
   215         else
       
   216             {
       
   217             User::Leave(err);
       
   218             }
       
   219     CleanupStack::PopAndDestroy(afile);
       
   220     CleanupStack::PopAndDestroy( &fs);
       
   221     }
       
   222 
       
   223 CDeliveryComponentStorage* CDeliveryComponentStorage::NewLC()
       
   224     {
       
   225     CDeliveryComponentStorage *self = new ( ELeave ) CDeliveryComponentStorage( );
       
   226     CleanupStack::PushL(self) ;
       
   227     self->ConstructL() ;
       
   228     return self;
       
   229     }
       
   230 
       
   231 CDeliveryComponentStorage* CDeliveryComponentStorage::NewL()
       
   232     {
       
   233     CDeliveryComponentStorage *self = NewLC();
       
   234     CleanupStack::Pop(self) ;
       
   235     return self;
       
   236     }
       
   237 
       
   238 TInt CDeliveryComponentStorage::NextKey()
       
   239     {
       
   240     TInt oldNext(iNextId++);
       
   241     iRepository->Set(KNextIdKey, iNextId);
       
   242     return oldNext;
       
   243     }
       
   244 
       
   245 CDeliveryComponentStorage::~CDeliveryComponentStorage()
       
   246     {
       
   247     RDEBUG_3( "CDeliveryComponentStorage::~CDeliveryComponentStorage 0x%X - 0x%X", reinterpret_cast<TUint>(this),
       
   248             reinterpret_cast<TUint>(this)+sizeof( CDeliveryComponentStorage ) );
       
   249     delete iRepository;
       
   250     iRepository = NULL;
       
   251     iComponents.ResetAndDestroy();
       
   252     iComponentIds.Close();
       
   253     TRAPD( err,CloseCertificatesL() )
       
   254     ;
       
   255     if (err != KErrNone)
       
   256         {
       
   257         RDEBUG_2( "CDeliveryComponentStorage::~CDeliveryComponentStorage: ERROR Failed to close certificate storage properly: %d", err);
       
   258         }
       
   259 #ifndef __SERIES60_30__
       
   260     delete iHidder;
       
   261     iHidder = NULL;
       
   262 #endif
       
   263     }
       
   264 
       
   265 void CDeliveryComponentStorage::CloseCertificatesL()
       
   266     {
       
   267     RFs fs;
       
   268     User::LeaveIfError(fs.Connect() );
       
   269     CleanupClosePushL(fs);
       
   270     TInt e(fs.CreatePrivatePath(KDefaultDrive) );
       
   271 
       
   272     User::LeaveIfError(e);
       
   273     TBuf<64> privatePath;
       
   274     User::LeaveIfError(fs.PrivatePath(privatePath) );
       
   275 
       
   276     TInt privPathLength(privatePath.Length() );
       
   277     _LIT( KCertFile, "amcerts.dat");
       
   278     HBufC *afile = HBufC::NewLC(privPathLength + KCertFile().Length());
       
   279     *afile = privatePath;
       
   280     afile->Des().Append(KCertFile);
       
   281     RFileWriteStream certFile;
       
   282 
       
   283     TInt err(certFile.Replace(fs, *afile, EFileWrite) );
       
   284     if (err == KErrNone)
       
   285         {
       
   286         CleanupClosePushL(certFile);
       
   287         iCertificates.ExternalizeL(certFile);
       
   288         CleanupStack::PopAndDestroy( &certFile);
       
   289         }
       
   290     else
       
   291         if (err == KErrNotFound)
       
   292             {
       
   293 
       
   294             }
       
   295         else
       
   296             {
       
   297             User::Leave(err);
       
   298             }
       
   299     CleanupStack::PopAndDestroy(afile);
       
   300     CleanupStack::PopAndDestroy( &fs);
       
   301     iCertificates.ResetAndDestroy();
       
   302     }
       
   303 
       
   304 const RComponentIdArray &CDeliveryComponentStorage::GetComponentIds() const
       
   305     {
       
   306     return iComponentIds;
       
   307     }
       
   308 
       
   309 void CDeliveryComponentStorage::GetStateChangeComponentIdsL(
       
   310         RComponentIdArray &aArray)
       
   311     {
       
   312     RDEBUG_2( "CDeliveryComponentStorage::GetStateChangeComponentIdsL %d dcs", iComponentIds.Count());
       
   313     aArray.Reset();
       
   314     TInt c(iComponentIds.Count() );
       
   315     for (TInt i( 0); i < c; i++)
       
   316         {
       
   317         CDeploymentComponent &compo = ComponentL(iComponentIds[i]);
       
   318         if (compo.OldState() != EDCSNone)
       
   319             {
       
   320             aArray.Append(iComponentIds[i]);
       
   321             }
       
   322         }
       
   323     RDEBUG( "CDeliveryComponentStorage::GetStateChangeComponentIdsL end");
       
   324     }
       
   325 
       
   326 void CDeliveryComponentStorage::StateChangedL(TUint32 aInternalId)
       
   327     {
       
   328     RDEBUG_2( "CDeliveryComponentStorage::StateChangedL id %d", aInternalId);
       
   329     CDeploymentComponent &compo = ComponentL(aInternalId);
       
   330     compo.StateChangeComplete();
       
   331     UpdateL(compo);
       
   332     }
       
   333 
       
   334 void CDeliveryComponentStorage::LoadComponentsL()
       
   335     {
       
   336     TInt length( 0);
       
   337     TInt err(iRepository->Get(KIdListLengthKey, length) );
       
   338     if (err == KErrNotFound)
       
   339         {
       
   340         length = 0;
       
   341         User::LeaveIfError(iRepository->Create(KIdListLengthKey, length) );
       
   342         }
       
   343     else
       
   344         {
       
   345         User::LeaveIfError(err);
       
   346         }
       
   347     HBufC8 *listbuf = HBufC8::NewLC(length) ;
       
   348     TPtr8 ptr(listbuf->Des() );
       
   349     err = iRepository->Get(KIdListKey, ptr) ;
       
   350     if (err == KErrNotFound)
       
   351         {
       
   352         err = iRepository->Create(KIdListKey, KNullDesC8);
       
   353         }
       
   354     else
       
   355         {
       
   356 
       
   357         }
       
   358     User::LeaveIfError(err);
       
   359     TRAPD(code, iComponentIds.SetListL( ptr ))
       
   360     ;
       
   361     if (code != KErrEof)
       
   362         {
       
   363         User::LeaveIfError(code);
       
   364         }
       
   365 
       
   366     CleanupStack::PopAndDestroy(listbuf);
       
   367 #ifndef __SERIES60_30__
       
   368     TInt i(iComponentIds.Count() );
       
   369     //iHidder->Reset();
       
   370     while ( --i >= 0)
       
   371         {
       
   372         CDeploymentComponent &comp = ComponentL(iComponentIds[i]);
       
   373         if (comp.State() == EDCSInactive)
       
   374             {
       
   375             iHidder->AddUidL(comp.Uid());
       
   376             }
       
   377         else
       
   378             if (comp.State() == EDCSActive)
       
   379                 {
       
   380                 iHidder->RemoveUidL(comp.Uid() );
       
   381                 }
       
   382         }
       
   383     iHidder->PersistUidsL();
       
   384 #endif
       
   385 
       
   386     }
       
   387 
       
   388 CDeploymentComponent *CDeliveryComponentStorage::NewComponentL(
       
   389         const TDeploymentComponentState &aState, const TDCUserId &aUserId,
       
   390         const TCertInfo *aCertInfo/* = NULL */)
       
   391     {
       
   392     CDeploymentComponent *newc = CDeploymentComponent::NewLC(NextKey(),
       
   393             aUserId);
       
   394     if (aCertInfo != NULL)
       
   395         {
       
   396         TCertInfoPckg *p = new( ELeave ) TCertInfoPckg(*aCertInfo);
       
   397         RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - allocated TCertInfoPckg 0x%X", reinterpret_cast<TUint>( p ) );
       
   398 
       
   399         TInt idx(iCertificates.FindByValue(*p) );
       
   400         if (idx == KErrNotFound)
       
   401             {
       
   402             RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg NOT found 0x%X", reinterpret_cast<TUint>( p ) );
       
   403             iCertificates.Append(p);
       
   404             idx = iCertificates.Count() - 1;
       
   405             }
       
   406         else
       
   407             {
       
   408             RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg found at %d, deleting temporary", idx );
       
   409             delete p;
       
   410             p = NULL;
       
   411             }
       
   412         if (idx >= 0)
       
   413             {
       
   414             RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg found 0x%X", reinterpret_cast<TUint>( p ) );
       
   415             newc->SetOwner(idx);
       
   416             }
       
   417         else
       
   418             {
       
   419             RDEBUG_3( "CDeliveryComponentStorage::NewComponentL - WARNING Could not add certificate 0x%X: %d", reinterpret_cast<TUint>( p ), idx );
       
   420 
       
   421             }
       
   422         }
       
   423     newc->SetState(aState);
       
   424     newc->SetStatusNode(EIdle);
       
   425     UpdateL( *newc);
       
   426     iComponents.Append(newc);
       
   427     iComponentIds.Append(newc->InternalId() );
       
   428 RDEBUG_2( "CDeliveryComponentStorage::NewComponentL -Internal ID is  %d, ", newc->InternalId() );
       
   429     PersistStateL();
       
   430     CleanupStack::Pop(newc);
       
   431     return newc;
       
   432     }
       
   433 
       
   434 void CDeliveryComponentStorage::UpdateL(
       
   435         const CDeploymentComponent &aComponent)
       
   436     {
       
   437     aComponent.PersistL( *iRepository) ;
       
   438 
       
   439 #ifndef __SERIES60_30__
       
   440     if (aComponent.State() == EDCSInactive)
       
   441         {
       
   442         iHidder->AddUidL(aComponent.Uid(), ETrue);
       
   443         }
       
   444     else
       
   445         {
       
   446         iHidder->RemoveUidL(aComponent.Uid(), ETrue);
       
   447         }
       
   448 #endif
       
   449     }
       
   450 
       
   451 void CDeliveryComponentStorage::PersistStateL()
       
   452     {
       
   453     TInt length( 0);
       
   454     HBufC8 *buf= NULL;
       
   455     iComponentIds.GetListLC(buf, length);
       
   456     User::LeaveIfError(iRepository->Set(KIdListLengthKey, length) );
       
   457     User::LeaveIfError(iRepository->Set(KIdListKey, *buf) );
       
   458     CleanupStack::PopAndDestroy(buf);
       
   459     }
       
   460 
       
   461 void CDeliveryComponentStorage::RemoveL(TUint32 aInternalId)
       
   462     {
       
   463     RDEBUG_2("CDeliveryComponentStorage::RemoveL - Remove id: (%d)", aInternalId );
       
   464     TInt count(iComponents.Count() );
       
   465     for (TInt i( 0); i < count; i++)
       
   466         {
       
   467         CDeploymentComponent *el = iComponents[i];
       
   468         if (aInternalId == el->iInternalId)
       
   469             {
       
   470 #ifndef __SERIES60_30__
       
   471             iHidder->RemoveUidL(el->Uid(), ETrue);
       
   472 #endif
       
   473             iComponents.Remove(i);
       
   474             iComponentIds.RemoveByValue(aInternalId);
       
   475             el->DestroyL( *iRepository);
       
   476             delete el;
       
   477             RDEBUG_2("CDeliveryComponentStorage::RemoveL - Removed id: (%d)", aInternalId );
       
   478             PersistStateL();
       
   479             break;
       
   480             }
       
   481         }
       
   482     }
       
   483 
       
   484 CDeploymentComponent &CDeliveryComponentStorage::ComponentL(
       
   485         TUint32 aInternalId)
       
   486     {
       
   487     CDeploymentComponent *resp= NULL;
       
   488     TInt count(iComponents.Count() );
       
   489     for (TInt i( 0); i < count; i++)
       
   490         {
       
   491         CDeploymentComponent *el = iComponents[i];
       
   492         if (aInternalId == el->iInternalId)
       
   493             {
       
   494             resp = el;
       
   495             break;
       
   496             }
       
   497         }
       
   498     if (resp == NULL)
       
   499         {
       
   500         TBuf8< NCentralRepositoryConstants::KMaxBinaryLength> buf;
       
   501         TInt err(iRepository->Get(aInternalId, buf) );
       
   502         User::LeaveIfError(err) ;
       
   503         resp = LoadComponentL(aInternalId, buf) ;
       
   504         iComponents.Append(resp);
       
   505         }
       
   506     if (resp == NULL)
       
   507         {
       
   508         User::Leave(KErrNotFound);
       
   509         }
       
   510     return *resp;
       
   511     }
       
   512 
       
   513 CDeploymentComponent *CDeliveryComponentStorage::LoadComponentL(
       
   514         TInt aInternalId, const TDesC8 &aBuffer) const
       
   515     {
       
   516     CDeploymentComponent *res = CDeploymentComponent::LoadL(aInternalId,
       
   517             aBuffer);
       
   518 #ifdef _DEBUG
       
   519     if (res)
       
   520         {
       
   521         RDEBUG8_4( "CDeliveryComponentStorage::LoadComponentL - loaded component state %d, internalid %d, and userid: %S", res->State(), res->InternalId(),&res->UserId() );
       
   522         }
       
   523     else
       
   524         {
       
   525         RDEBUG( "CDeliveryComponentStorage::LoadComponentL - WARNING failed to load component" );
       
   526         }
       
   527 #endif
       
   528     return res;
       
   529     }
       
   530 void CDeliveryComponentStorage::CheckForDuplicateNodesInDeployedL(
       
   531         CDeploymentComponent &aComponent)
       
   532     {
       
   533     TInt CompIdsCount(iComponentIds.Count() );
       
   534     RDEBUG8_2("CheckForDuplicateNodesInDeployedL: CompIdsCount-> (%d)", CompIdsCount );
       
   535     RDEBUG8_2("CheckForDuplicateNodesInDeployedL: aComponent UserID is %S", &(aComponent.UserId()));
       
   536     for (TInt i( 0); i < CompIdsCount; i++)
       
   537         {
       
   538         CDeploymentComponent &compo = ComponentL(iComponentIds[i]);
       
   539         RDEBUG8_2("CheckForDuplicateNodesInDeployedL: compo UserID is %S", &(compo.UserId()));
       
   540         if (&aComponent != &compo)
       
   541         {
       
   542         if (((compo.State()== EDCSActive) || (compo.State()== EDCSInactive))
       
   543                 &&(compo.UserId() == aComponent.UserId()))
       
   544             {
       
   545             (aComponent.iUserId).Append(*IntToDes8LC(aComponent.iInternalId));
       
   546             CleanupStack::PopAndDestroy();
       
   547             break;
       
   548             }
       
   549           }
       
   550         }
       
   551     }
       
   552 
       
   553 HBufC8* CDeliveryComponentStorage::IntToDes8LC(const TInt aLuid)
       
   554     {
       
   555     HBufC8* buf = HBufC8::NewLC( 10); //10 = max length of 32bit integer
       
   556     TPtr8 ptrBuf = buf->Des();
       
   557     ptrBuf.Num(aLuid);
       
   558     return buf;
       
   559     }
       
   560 
       
   561 void CDeliveryComponentStorage::InstalledL(CDeploymentComponent &aComponent)
       
   562     {
       
   563     CheckForDuplicateNodesInDeployedL(aComponent);
       
   564     aComponent.SetState(EDCSActive);
       
   565     // set state to IDLE 
       
   566     aComponent.SetStatusNode(EIdle);
       
   567     UpdateL(aComponent);
       
   568     }
       
   569 
       
   570 void CDeliveryComponentStorage::DeactivateL(CDeploymentComponent &aComponent)
       
   571     {
       
   572     /* :
       
   573      * set state to InActivate in progress
       
   574      * use TRAP instead of leaving.
       
   575      */
       
   576     aComponent.SetStatusNode(EDeployed_DeactivateProgress);
       
   577     //User::LeaveIfError(aComponent.SetState(EDCSInactive) );
       
   578     TInt err = aComponent.SetState(EDCSInactive);
       
   579     if (err == KErrNone)
       
   580         {
       
   581         TRAP(err,UpdateL(aComponent));
       
   582         }
       
   583     //UpdateL(aComponent);
       
   584     /*:
       
   585      * if error set state to InActivate failed or else set to Idle
       
   586      * call userleaveiferror()
       
   587      */
       
   588     if (err == KErrNone)
       
   589         {
       
   590         aComponent.SetStatusNode(EIdle);
       
   591         }
       
   592     else
       
   593         {
       
   594         aComponent.SetStatusNode(EDeployed_DeactivateFailed);
       
   595         }
       
   596     User::LeaveIfError(err);
       
   597     }
       
   598 
       
   599 void CDeliveryComponentStorage::SetDeploymentComponentState(CDeploymentComponent &aComponent,TDeploymentComponentState aState)
       
   600     {
       
   601     aComponent.SetState( aState );
       
   602     TRAP_IGNORE(UpdateL( aComponent ));    
       
   603     }
       
   604 
       
   605 void CDeliveryComponentStorage::ActivateL(CDeploymentComponent &aComponent)
       
   606     {
       
   607     /* :
       
   608      * set state to Activate in progress
       
   609      * use TRAP instead of leaving.
       
   610      */
       
   611     aComponent.SetStatusNode(EDeployed_ActivateProgress);
       
   612     TInt err = aComponent.SetState(EDCSActive);
       
   613     //UpdateL( aComponent );
       
   614     if (err == KErrNone)
       
   615         {
       
   616         TRAP(err,UpdateL(aComponent));
       
   617         }
       
   618     /*:
       
   619      * if error set state to InActivate failed or else set to Idle
       
   620      * call userleaveiferror()
       
   621      */
       
   622     if (err == KErrNone)
       
   623         {
       
   624         aComponent.SetStatusNode(EIdle);
       
   625         }
       
   626     else
       
   627         {
       
   628         aComponent.SetStatusNode(EDeployed_ActivateFailed);
       
   629         }
       
   630     User::LeaveIfError(err);
       
   631     }
       
   632 
       
   633 /*void CDeliveryComponentStorage::UninstalledL( CDeploymentComponent &aComponent )
       
   634  {
       
   635  aComponent.SetState( EDCSInactive );
       
   636  UpdateL( aComponent );
       
   637  }
       
   638  
       
   639  void CDeliveryComponentStorage::ResetL()
       
   640  {
       
   641  }
       
   642  */
       
   643 //  End of File