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