iaupdate/IAD/engine/controller/src/iaupdatenodecontainer.cpp
branchRCL_3
changeset 11 3ba40be8e484
parent 2 661f3784fe57
equal deleted inserted replaced
9:51c0f5edf5ef 11:3ba40be8e484
    30 #include "iaupdatenodefactory.h"
    30 #include "iaupdatenodefactory.h"
    31 
    31 
    32 #include "iaupdatedebug.h"
    32 #include "iaupdatedebug.h"
    33 
    33 
    34 
    34 
       
    35 #include "ncdnodecontentinfo.h"
       
    36 #include "ncdnode.h"
       
    37 #include "iaupdateprotocolconsts.h"
       
    38 
       
    39 
    35 // Constant that is used to inform that dependency node
    40 // Constant that is used to inform that dependency node
    36 // was not found when dependencies were checked.
    41 // was not found when dependencies were checked.
    37 const TInt KDependencyNotFound( -1 );
    42 const TInt KDependencyNotFound( -1 );
    38 
    43 
    39 
    44 
   663         // or if the correct node was already in the list.
   668         // or if the correct node was already in the list.
   664         TBool alreadyIncluded( EFalse );
   669         TBool alreadyIncluded( EFalse );
   665         
   670         
   666         for ( TInt i = 0; i < iHeadNodes.Count(); ++i )
   671         for ( TInt i = 0; i < iHeadNodes.Count(); ++i )
   667             {
   672             {
   668             CIAUpdateNode& tmpNode( *iHeadNodes[ i ] );            
   673             CIAUpdateNode& tmpNode( *iHeadNodes[ i ] );   
   669             if( aNode.Uid() == tmpNode.Uid() && aNode.Type() != MIAUpdateNode::EPackageTypeServicePack ) 
   674             
       
   675             if( NodeExists( aNode, tmpNode ) &&  
       
   676                   aNode.Type() != MIAUpdateNode::EPackageTypeServicePack ) 
   670                 {
   677                 {
   671                 IAUPDATE_TRACE("[IAUPDATE] Head node already in the list.");
   678                 IAUPDATE_TRACE("[IAUPDATE] Head node already in the list.");
   672                 
   679                 
   673                 // Node for the corresponding content already exists in the list.
   680                 // Node for the corresponding content already exists in the list.
   674                 // Replace node from the list if the new node is better choice.
   681                 // Replace node from the list if the new node is better choice.
   724     const CIAUpdateNode& aCurrentNode,
   731     const CIAUpdateNode& aCurrentNode,
   725     const CIAUpdateNode& aNewNode ) const
   732     const CIAUpdateNode& aNewNode ) const
   726     {
   733     {
   727     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeContainer::ReplaceRecommendedL() begin");
   734     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeContainer::ReplaceRecommendedL() begin");
   728     
   735     
   729     if ( aCurrentNode.Uid() != aNewNode.Uid() )
   736     
       
   737     if ( !NodeExists( aCurrentNode, aNewNode ) )
   730         {
   738         {
   731         IAUPDATE_TRACE("[IAUPDATE] LEAVE: Nodes do not match.");
   739         IAUPDATE_TRACE("[IAUPDATE] LEAVE: Nodes do not match.");
   732         User::Leave( KErrArgument );
   740         User::Leave( KErrArgument );
   733         }
   741         }
   734     
   742     
   764     const CIAUpdateNode& aNode ) const
   772     const CIAUpdateNode& aNode ) const
   765     {
   773     {
   766     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeContainer::PackageTypeAcceptedL() begin");
   774     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeContainer::PackageTypeAcceptedL() begin");
   767     
   775     
   768     if ( aNode.Type() == MIAUpdateNode::EPackageTypeServicePack
   776     if ( aNode.Type() == MIAUpdateNode::EPackageTypeServicePack
   769          || aNode.Type() == MIAUpdateNode::EPackageTypeSA )
   777          || aNode.Type() == MIAUpdateNode::EPackageTypeSA 
   770         {
   778          || aNode.Type() == MIAUpdateNode::EPackageTypeWidget )
   771         // Service packs and SA type always accepted.
   779         {
   772         IAUPDATE_TRACE("[IAUPDATE] Upgrade packet type SA or node is service pack");
   780         // Service packs, SA types and Widgets are always accepted.
       
   781         IAUPDATE_TRACE("[IAUPDATE] Upgrade packet type SA, service pack or widget");
   773         IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeContainer::PackageTypeAcceptedL() end: ETrue");
   782         IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeContainer::PackageTypeAcceptedL() end: ETrue");
   774         return ETrue;
   783         return ETrue;
   775         }
   784         }
   776 
   785 
   777     TBool accepted( EFalse );
   786     TBool accepted( EFalse );
  1051     // the service packs can be checked separately.
  1060     // the service packs can be checked separately.
  1052     if ( aNode.Type() != MIAUpdateNode::EPackageTypeServicePack )
  1061     if ( aNode.Type() != MIAUpdateNode::EPackageTypeServicePack )
  1053         {
  1062         {
  1054         IAUPDATE_TRACE("[IAUPDATE] Not a service pack");
  1063         IAUPDATE_TRACE("[IAUPDATE] Not a service pack");
  1055 
  1064 
       
  1065      
  1056         TIAUpdateVersion installedVersion;
  1066         TIAUpdateVersion installedVersion;
  1057         TBool installed( 
  1067         TBool installed = EFalse;
  1058             IAUpdateUtils::IsAppInstalledL( aNode.Uid(), installedVersion ) );
  1068         if ( aNode.Mime().Compare( IAUpdateProtocolConsts::KMimeWidget ) == 0 )
       
  1069             {
       
  1070             installed = IAUpdateUtils::IsWidgetInstalledL( aNode.Identifier(), installedVersion );
       
  1071             }
       
  1072         else
       
  1073             {
       
  1074             installed = IAUpdateUtils::IsAppInstalledL( aNode.Uid(), installedVersion );
       
  1075             }
  1059         // Notice that here we let the check pass also if node has the same version
  1076         // Notice that here we let the check pass also if node has the same version
  1060         // as the installed content. By accepting same version, the dependency chains
  1077         // as the installed content. By accepting same version, the dependency chains
  1061         // will contain the currently installed node dependency information. Then,
  1078         // will contain the currently installed node dependency information. Then,
  1062         // if newer dependencies are provided for the already installed content,
  1079         // if newer dependencies are provided for the already installed content,
  1063         // they will be handled correctly for example inside service packs.
  1080         // they will be handled correctly for example inside service packs.
  1085     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeContainer::InstallCheckL() end: %d",
  1102     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeContainer::InstallCheckL() end: %d",
  1086                      checkPassed);
  1103                      checkPassed);
  1087 
  1104 
  1088     return checkPassed;
  1105     return checkPassed;
  1089     }
  1106     }
       
  1107 
       
  1108 // Checks if  the head node ids / identifers are equal
       
  1109 TBool CIAUpdateNodeContainer::NodeExists( const CIAUpdateNode& aNode, 
       
  1110                                           const CIAUpdateNode& tmpNode )const 
       
  1111     {
       
  1112     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeContainer::NodeExists begin");
       
  1113     
       
  1114     TBool exists = EFalse;
       
  1115 
       
  1116     if ( aNode.Mime().Compare( IAUpdateProtocolConsts::KMimeWidget ) == 0 )
       
  1117         {
       
  1118         if ( aNode.Identifier() == tmpNode.Identifier() )
       
  1119             {
       
  1120             exists = ETrue;
       
  1121             }
       
  1122         }
       
  1123     else
       
  1124         {
       
  1125         if ( aNode.Uid() == tmpNode.Uid() )
       
  1126             {
       
  1127             exists = ETrue;
       
  1128             }
       
  1129         }
       
  1130     
       
  1131     
       
  1132     IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeContainer::NodeExists end: %d",
       
  1133                      exists);
       
  1134     
       
  1135     return exists;
       
  1136     }