contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp
changeset 107 b34d53f6acdf
parent 99 7aaf39b772ac
child 112 dbfb5e38438b
equal deleted inserted replaced
106:e78d6e055a5b 107:b34d53f6acdf
   152 
   152 
   153     for ( TInt i = 0; i < fileList->Count(); i++ )
   153     for ( TInt i = 0; i < fileList->Count(); i++ )
   154         {
   154         {
   155         if ( ( *fileList )[i].iName.Find( KManifest ) != KErrNotFound )
   155         if ( ( *fileList )[i].iName.Find( KManifest ) != KErrNotFound )
   156             {
   156             {
   157             RBuf fullFilePath;
   157             RBuf manifestFilePathName;
   158             CleanupClosePushL( fullFilePath );
   158             CleanupClosePushL( manifestFilePathName );
   159             fullFilePath.CreateL( manifestDirectoryPath->Length()
   159             manifestFilePathName.CreateL( manifestDirectoryPath->Length()
   160                     + ( *fileList )[i].iName.Length() );
   160                     + ( *fileList )[i].iName.Length() );
   161             fullFilePath.Append( *manifestDirectoryPath );
   161             manifestFilePathName.Append( *manifestDirectoryPath );
   162             fullFilePath.Append( ( *fileList )[i].iName );
   162             manifestFilePathName.Append( ( *fileList )[i].iName );
   163           
   163           
   164             TPtrC packageUidPtr = manifestDirectoryPath->Mid(
   164             TPtrC packageUidPtr = manifestDirectoryPath->Mid(
   165                     manifestDirectoryPath->Length() - KPackageUidPosition,
   165                     manifestDirectoryPath->Length() - KPackageUidPosition,
   166                     KPackageUidLength); 
   166                     KPackageUidLength); 
   167             TUint packageUid;            
   167             TUint packageUid;            
   168             TLex lexer( packageUidPtr );
   168             TLex lexer( packageUidPtr );
   169             User::LeaveIfError( lexer.Val( packageUid, EHex ) );
   169             User::LeaveIfError( lexer.Val( packageUid, EHex ) );
   170 
   170 
   171             CCaWidgetDescription* compareWidget = NULL;
   171             CCaWidgetDescription* currentWidget = NULL;
   172             for ( TInt j = 0; j < iFetchedWidgets.Count(); j++ )
   172             for ( TInt j = 0; j < iFetchedWidgets.Count(); j++ )
   173                 {
   173                 {
   174                 if ( iFetchedWidgets[j]->GetPackageUidL() ==  packageUid )
   174                 if ( iFetchedWidgets[j]->GetPackageUidL() ==  packageUid )
   175                     {
   175                     {
   176                     compareWidget = iFetchedWidgets[j];
   176                     currentWidget = iFetchedWidgets[j];
   177                     compareWidget->SetValid( ETrue ); //do not remove from db
   177                     currentWidget->SetValid( ETrue ); //do not remove from db
   178                     break; // once found we dont iterate anymore
   178                     break; // once found we dont iterate anymore
   179                     }
   179                     }
   180                 }
   180                 }
   181 
   181 
   182             if ( compareWidget )
   182             if ( currentWidget )
   183                 {
   183                 {
   184                 TTime modificationTime = ( *fileList )[i].iModified;
   184                 TTime modificationTime = ( *fileList )[i].iModified;
   185                 TInt64 modificationIntTime = modificationTime.Int64();
   185                 TInt64 modificationIntTime = modificationTime.Int64();
   186                 TLex lex( compareWidget->GetModificationTime() );
   186                 TLex lex( currentWidget->GetModificationTime() );
   187                 TInt64 uintTimeDB( 0 );
   187                 TInt64 uintTimeDB( 0 );
   188                 User::LeaveIfError( lex.Val( uintTimeDB ) );
   188                 User::LeaveIfError( lex.Val( uintTimeDB ) );
   189 
   189 
   190                 if ( uintTimeDB != modificationIntTime )
   190                 if ( uintTimeDB != modificationIntTime )
   191                     {
   191                     {
   192                     TRAP_IGNORE( ParseManifestFileL( fullFilePath,
   192                     TRAP_IGNORE( ParseManifestFileL( manifestFilePathName,
   193                                     aDirectoryName, aDrive ) );
   193                                     aDirectoryName, aDrive ) );
   194                     }
   194                     }
       
   195                 else if ( currentWidget->IsMissing() ) 
       
   196                     {
       
   197                     // manifest of missing widget found
       
   198                     CCaWidgetDescription* clone = currentWidget->CloneL();
       
   199                     CleanupStack::PushL( clone );
       
   200                     clone->SetManifestFilePathNameL( manifestFilePathName );
       
   201                     iWidgets.AppendL( clone );
       
   202                     CleanupStack::Pop( clone );
       
   203                     }
   195                 }
   204                 }
   196             else
   205             else
   197                 {
   206                 {
   198                 TRAP_IGNORE( ParseManifestFileL( fullFilePath, aDirectoryName,
   207                 TRAP_IGNORE( ParseManifestFileL( manifestFilePathName, aDirectoryName,
   199                                 aDrive ) );
   208                                 aDrive ) );
   200                 }
   209                 }
   201             CleanupStack::PopAndDestroy( &fullFilePath );
   210             CleanupStack::PopAndDestroy( &manifestFilePathName );
   202             }
   211             }
   203         }
   212         }
   204     CleanupStack::PopAndDestroy( fileList );
   213     CleanupStack::PopAndDestroy( fileList );
   205     CleanupStack::PopAndDestroy( manifestDirectoryPath );
   214     CleanupStack::PopAndDestroy( manifestDirectoryPath );
   206     }
   215     }
   302         CleanupStack::PopAndDestroy( libraryPath2 );
   311         CleanupStack::PopAndDestroy( libraryPath2 );
   303 
   312 
   304         SetModificationTimeL( aFilePath, widgetDescriptor );
   313         SetModificationTimeL( aFilePath, widgetDescriptor );
   305 
   314 
   306         TInt index = iWidgets.Find( widgetDescriptor,
   315         TInt index = iWidgets.Find( widgetDescriptor,
   307                 CCaWidgetDescription::Compare );
   316                 CCaWidgetDescription::CompareUri );
   308         if ( index != KErrNotFound )
   317         if ( index != KErrNotFound )
   309             {
   318             {
   310             delete iWidgets[index];
   319             delete iWidgets[index];
   311             iWidgets.Remove( index );
   320             iWidgets.Remove( index );
   312             }
   321             }
   338     SetMmcIdL( widget, aDrive );
   347     SetMmcIdL( widget, aDrive );
   339     SetTranslationFileNameL( aElement, widget );
   348     SetTranslationFileNameL( aElement, widget );
   340 
   349 
   341     SetModificationTimeL( aFilePath, widget );
   350     SetModificationTimeL( aFilePath, widget );
   342 
   351 
   343     TInt index = iWidgets.Find( widget, CCaWidgetDescription::Compare );
   352     TInt index = iWidgets.Find( widget, CCaWidgetDescription::CompareUri );
   344     if ( index != KErrNotFound )
   353     if ( index != KErrNotFound )
   345         {
   354         {
   346         delete iWidgets[index];
   355         delete iWidgets[index];
   347         iWidgets.Remove( index );
   356         iWidgets.Remove( index );
   348         }
   357         }