imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp
branchRCL_3
changeset 9 2eb74cf6572e
parent 5 82749d516180
child 10 7403edfcf0fb
equal deleted inserted replaced
5:82749d516180 9:2eb74cf6572e
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <e32svr.h>
    19 #include <e32svr.h>
    20 #include <mihlscaler.h>
    20 #include <MIHLScaler.h>
    21 #include <driveinfo.h>
    21 #include <driveinfo.h>
    22 #include <caf/data.h>
    22 #include <caf/data.h>
    23 #include <oma2agent.h>
    23 #include <Oma2Agent.h>
    24 #include <bautils.h>  
    24 #include <bautils.h>  
    25 #include <mdesession.h>
    25 #include <mdesession.h>
    26 
    26 
    27 #include "thumbnailserver.h"
    27 #include "thumbnailserver.h"
    28 #include "thumbnailtaskprocessor.h"
    28 #include "thumbnailtaskprocessor.h"
    52 // ----------------------------------------------------------------------------------------
    52 // ----------------------------------------------------------------------------------------
    53 
    53 
    54 // ----------------------------------------------------------------------------------------
    54 // ----------------------------------------------------------------------------------------
    55 // Total number of ranges
    55 // Total number of ranges
    56 // ----------------------------------------------------------------------------------------
    56 // ----------------------------------------------------------------------------------------
    57 const TUint KThumbnailServerRangeCount = 17;
    57 const TUint KThumbnailServerRangeCount = 16;
    58  
    58  
    59 // ----------------------------------------------------------------------------------------
    59 // ----------------------------------------------------------------------------------------
    60 // Definition of the ranges
    60 // Definition of the ranges
    61 // ----------------------------------------------------------------------------------------
    61 // ----------------------------------------------------------------------------------------
    62 const TInt KThumbnailServerRanges[KThumbnailServerRangeCount] = 
    62 const TInt KThumbnailServerRanges[KThumbnailServerRangeCount] = 
    64     ERequestThumbByPathAsync,      
    64     ERequestThumbByPathAsync,      
    65     ERequestThumbByFileHandleAsync,          
    65     ERequestThumbByFileHandleAsync,          
    66     EReleaseBitmap,
    66     EReleaseBitmap,
    67     ECancelRequest,
    67     ECancelRequest,
    68     EChangePriority,
    68     EChangePriority,
    69     ECreateThumbnails,
       
    70     EDeleteThumbnails,
    69     EDeleteThumbnails,
    71     EGetMimeTypeBufferSize,
    70     EGetMimeTypeBufferSize,
    72     EGetMimeTypeList,
    71     EGetMimeTypeList,
    73     ERequestThumbByIdAsync,
    72     ERequestThumbByIdAsync,
    74     ERequestThumbByBufferAsync,
    73     ERequestThumbByBufferAsync,
    88     CPolicyServer::ECustomCheck,    // ERequestThumbByPathAsync
    87     CPolicyServer::ECustomCheck,    // ERequestThumbByPathAsync
    89     CPolicyServer::ECustomCheck,    // ERequestThumbByFileHandleAsync
    88     CPolicyServer::ECustomCheck,    // ERequestThumbByFileHandleAsync
    90     CPolicyServer::ECustomCheck,    // EReleaseBitmap
    89     CPolicyServer::ECustomCheck,    // EReleaseBitmap
    91     CPolicyServer::ECustomCheck,    // ECancelRequest
    90     CPolicyServer::ECustomCheck,    // ECancelRequest
    92     CPolicyServer::ECustomCheck,    // EChangePriority
    91     CPolicyServer::ECustomCheck,    // EChangePriority
    93     CPolicyServer::ECustomCheck,    // ECreateThumbnails
       
    94     CPolicyServer::ECustomCheck,    // EDeleteThumbnails
    92     CPolicyServer::ECustomCheck,    // EDeleteThumbnails
    95     CPolicyServer::ECustomCheck,    // EGetMimeTypeBufferSize
    93     CPolicyServer::ECustomCheck,    // EGetMimeTypeBufferSize
    96     CPolicyServer::ECustomCheck,    // EGetMimeTypeList
    94     CPolicyServer::ECustomCheck,    // EGetMimeTypeList
    97     CPolicyServer::ECustomCheck,    // ERequestThumbByIdAsync
    95     CPolicyServer::ECustomCheck,    // ERequestThumbByIdAsync
    98     CPolicyServer::ECustomCheck,    // ERequestThumbByBufferAsync
    96     CPolicyServer::ECustomCheck,    // ERequestThumbByBufferAsync
   137             break;
   135             break;
   138             }
   136             }
   139         case EReleaseBitmap:
   137         case EReleaseBitmap:
   140         case ECancelRequest:
   138         case ECancelRequest:
   141         case EChangePriority:
   139         case EChangePriority:
   142         case ECreateThumbnails:
       
   143         case EDeleteThumbnails:
   140         case EDeleteThumbnails:
   144         case EGetMimeTypeBufferSize:
   141         case EGetMimeTypeBufferSize:
   145         case EGetMimeTypeList:
   142         case EGetMimeTypeList:
   146         case ERequestSetThumbnailByBuffer:
   143         case ERequestSetThumbnailByBuffer:
   147         case EDeleteThumbnailsById:
   144         case EDeleteThumbnailsById:
   249     
   246     
   250     iFormatObserver = CTMFormatObserver::NewL( *this );
   247     iFormatObserver = CTMFormatObserver::NewL( *this );
   251     
   248     
   252     iFormatting = EFalse;
   249     iFormatting = EFalse;
   253     
   250     
   254     OpenStoresL();
   251     //OpenStoresL();
   255     
   252     
   256     AddUnmountObserversL();
   253     AddUnmountObserversL();
       
   254     
       
   255     iReconnect = CPeriodic::NewL(CActive::EPriorityIdle);
   257     }
   256     }
   258 
   257 
   259 
   258 
   260 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   261 // Destructor.
   260 // Destructor.
   268     iShutdown = ETrue;
   267     iShutdown = ETrue;
   269     
   268     
   270     delete iShutdownObserver;
   269     delete iShutdownObserver;
   271     delete iProcessor;
   270     delete iProcessor;
   272     
   271     
       
   272     if(iReconnect)
       
   273         {
       
   274         iReconnect->Cancel();
       
   275         delete iReconnect;
       
   276         iReconnect = NULL;
       
   277         }
       
   278     
   273     if (iMdESession)
   279     if (iMdESession)
   274         {
   280         {
   275         delete iMdESession;
   281         delete iMdESession;
       
   282         iMdESession = NULL;
   276         }
   283         }
   277 
   284 
   278     ResetAndDestroyHashMap < TInt, CThumbnailStore > ( iStores );
   285     ResetAndDestroyHashMap < TInt, CThumbnailStore > ( iStores );
   279     ResetAndDestroyHashMap < TInt32, CThumbnailProvider > ( iProviders );
   286     ResetAndDestroyHashMap < TInt32, CThumbnailProvider > ( iProviders );
   280     
   287     
   316 // CThumbnailServer::HandleSessionError
   323 // CThumbnailServer::HandleSessionError
   317 // -----------------------------------------------------------------------------
   324 // -----------------------------------------------------------------------------
   318 //
   325 //
   319 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
   326 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
   320     {
   327     {
   321     if (aError != KErrNone)
   328     TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError );
   322         {
   329     if (aError != KErrNone && !iShutdown)
   323         TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError );
   330         {
   324         }   
   331         if (!iReconnect->IsActive())
       
   332             {
       
   333             iReconnect->Start( KMdEReconnect, KMdEReconnect, 
       
   334                                TCallBack(ReconnectCallBack, this));
       
   335             
       
   336             TN_DEBUG1( "CThumbnailServer::HandleSessionError() - reconnect timer started" );
       
   337             }
       
   338         } 
   325     }
   339     }
   326 
   340 
   327 // -----------------------------------------------------------------------------
   341 // -----------------------------------------------------------------------------
   328 // CThumbnailServer::NewSessionL()
   342 // CThumbnailServer::NewSessionL()
   329 // Creates new server session.
   343 // Creates new server session.
   497 // CThumbnailServer::StoreThumbnailL()
   511 // CThumbnailServer::StoreThumbnailL()
   498 // -----------------------------------------------------------------------------
   512 // -----------------------------------------------------------------------------
   499 //
   513 //
   500 void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap,
   514 void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap,
   501     const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize,
   515     const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize,
   502     const TThumbnailId aThumbnailId, const TBool aThumbFromPath, const TBool aCheckExist )
   516     const TInt64 aModified, const TBool aThumbFromPath, const TBool aCheckExist )
   503     {
   517     {
   504     TN_DEBUG6( 
   518     TN_DEBUG6( 
   505         "CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped );
   519         "CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped );
   506 #ifdef _DEBUG
   520 #ifdef _DEBUG
   507     TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode());
   521     TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode());
   508 #endif
   522 #endif
   509     
   523     
   510     if (!aCheckExist)
   524     if (!aCheckExist)
   511         {
   525         {
   512         StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
   526         StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
   513                        aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath );
   527                        aCropped, aThumbnailSize, aModified, aThumbFromPath );
   514         }    
   528         }    
   515     else if(BaflUtils::FileExists( iFs, aPath))
   529     else if(BaflUtils::FileExists( iFs, aPath))
   516         {
   530         {
   517         StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
   531         StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
   518                        aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath );
   532                        aCropped, aThumbnailSize, aModified, aThumbFromPath );
   519         }
   533         }
   520     else
   534     else
   521         {
   535         {
   522         TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!");
   536         TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!");
   523         }
   537         }
   567                 aHandle, ptr->iRefCount );
   581                 aHandle, ptr->iRefCount );
   568             }
   582             }
   569         }
   583         }
   570     else
   584     else
   571         {
   585         {
   572         __ASSERT_DEBUG(( EFalse ), ThumbnailPanic( EThumbnailBitmapNotReleased ));
   586         //__ASSERT_DEBUG(( EFalse ), ThumbnailPanic( EThumbnailBitmapNotReleased ));
   573         TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!",
   587         TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!",
   574             aHandle );
   588             aHandle );
   575         }
   589         }
   576     }
   590     }
   577 
   591 
   584     {
   598     {
   585     TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath);
   599     TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath);
   586     
   600     
   587     StoreForPathL( aPath )->DeleteThumbnailsL( aPath );
   601     StoreForPathL( aPath )->DeleteThumbnailsL( aPath );
   588     }
   602     }
   589 
       
   590 
       
   591 // -----------------------------------------------------------------------------
       
   592 // Delete thumbnails by Id
       
   593 // -----------------------------------------------------------------------------
       
   594 //
       
   595 void CThumbnailServer::DeleteThumbnailsByIdL( const TThumbnailId aItemId )
       
   596     {
       
   597     TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsByIdL(%d)", aItemId);
       
   598     
       
   599 #ifdef _DEBUG
       
   600     TTime aStart, aStop;
       
   601     aStart.UniversalTime();
       
   602 #endif
       
   603     
       
   604     // no path available, can be any store    
       
   605     THashMapIter<TInt, CThumbnailStore*> iter( iStores );
       
   606     CThumbnailStore* const *store = iter.NextValue();
       
   607 
       
   608     while ( store )
       
   609         {
       
   610         TInt err = KErrNone;   
       
   611         TRAP(err, ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId) );
       
   612         if (err == KErrNone)
       
   613             {
       
   614 #ifdef _DEBUG
       
   615     aStop.UniversalTime();
       
   616     TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsByIdL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
   617 #endif
       
   618             return;
       
   619             }
       
   620         store = iter.NextValue();
       
   621         }    
       
   622     }
       
   623 
       
   624 
   603 
   625 // -----------------------------------------------------------------------------
   604 // -----------------------------------------------------------------------------
   626 // CThumbnailServer::ResolveMimeTypeL()
   605 // CThumbnailServer::ResolveMimeTypeL()
   627 // -----------------------------------------------------------------------------
   606 // -----------------------------------------------------------------------------
   628 //
   607 //
   907         }
   886         }
   908 
   887 
   909     return res;
   888     return res;
   910     }
   889     }
   911 
   890 
   912 
       
   913 // -----------------------------------------------------------------------------
       
   914 // CThumbnailServer::FetchThumbnailL()
       
   915 // -----------------------------------------------------------------------------
       
   916 //
       
   917 void CThumbnailServer::FetchThumbnailL( TThumbnailId aThumbnailId, CFbsBitmap* &
       
   918     aThumbnail, TDesC8* & aData, TThumbnailSize aThumbnailSize, TSize &aOriginalSize )
       
   919     {
       
   920     TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aThumbnailId=%d aThumbnailSize=%d)", aThumbnailId, aThumbnailSize );
       
   921 
       
   922 #ifdef _DEBUG
       
   923     TTime aStart, aStop;
       
   924     aStart.UniversalTime();
       
   925     TInt roundCount = 1;
       
   926 #endif
       
   927     
       
   928     THashMapIter<TInt, CThumbnailStore*> storeIter(iStores);
       
   929     
       
   930     TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() store iteration - begin");
       
   931     for (CThumbnailStore* const* pStore = storeIter.NextValue();
       
   932         pStore && aThumbnail == NULL ;
       
   933         pStore = storeIter.NextValue())
       
   934         {
       
   935         TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() store iteration - round == %d ", roundCount++);
       
   936         CThumbnailStore* const store = (CThumbnailStore*)(*pStore);
       
   937         
       
   938         TRAPD(err, store->FetchThumbnailL( aThumbnailId, aThumbnail, aData, aThumbnailSize, aOriginalSize ));
       
   939         
       
   940         if( err == KErrCompletion )
       
   941             {
       
   942             // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion
       
   943             TN_DEBUG1( 
       
   944                 "CThumbnailServer::FetchThumbnailL() - thumbnail blacklisted" );
       
   945             User::Leave( err );
       
   946             }
       
   947         else if ( aThumbnail || aData)
       
   948             { // thumbnail found from DB
       
   949             TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() found" );
       
   950             break;
       
   951             }
       
   952 /*
       
   953 #ifdef _DEBUG
       
   954     aStop.UniversalTime();
       
   955     TN_DEBUG3( "CThumbnailServer::FetchThumbnailL() iteration round %d took %d ms", roundCount, (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
   956 #endif 
       
   957 */
       
   958         }
       
   959 
       
   960 #ifdef _DEBUG
       
   961     aStop.UniversalTime();
       
   962     TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
   963 #endif 
       
   964     
       
   965     if ( !aThumbnail && !aData)
       
   966         { // thumbnail not found from DB
       
   967         TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() not found" );
       
   968         User::Leave( KErrNotFound );
       
   969         }  
       
   970     }
       
   971 
       
   972 
       
   973 // -----------------------------------------------------------------------------
   891 // -----------------------------------------------------------------------------
   974 // Get the thumbnail store instance, which is responsible for the drive
   892 // Get the thumbnail store instance, which is responsible for the drive
   975 // identified by given path
   893 // identified by given path
   976 // -----------------------------------------------------------------------------
   894 // -----------------------------------------------------------------------------
   977 //
   895 //
  1028                 TN_DEBUG2( "CThumbnailServer::OpenStoresL() StoreForDriveL %d", i);
   946                 TN_DEBUG2( "CThumbnailServer::OpenStoresL() StoreForDriveL %d", i);
  1029                 
   947                 
  1030                 // ignore errors
   948                 // ignore errors
  1031                 TRAP_IGNORE( StoreForDriveL( i ));
   949                 TRAP_IGNORE( StoreForDriveL( i ));
  1032                 
   950                 
  1033                 // start also placeholder task
       
  1034                 //AddPlaceholderTaskL(i);
       
  1035                 
       
  1036                 driveCountInt--;
   951                 driveCountInt--;
  1037                 }
   952                 }
  1038             }            
   953             }            
  1039         }
   954         }
  1040     
   955     
  1064 RArray < TThumbnailPersistentSize > CThumbnailServer::PersistentSizesL()
   979 RArray < TThumbnailPersistentSize > CThumbnailServer::PersistentSizesL()
  1065     {
   980     {
  1066     return iPersistentSizes;
   981     return iPersistentSizes;
  1067     }
   982     }
  1068 
   983 
  1069 void CThumbnailServer::GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray <
   984 void CThumbnailServer::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray <
  1070     TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs )
   985     TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly  )
  1071     {
   986     {
  1072     StoreForPathL( aPath )->GetMissingSizesAndIDsL( aPath, aSourceType, aMissingSizes, aMissingIDs );
   987     StoreForPathL( aPath )->GetMissingSizesL( aPath, aSourceType, aMissingSizes, aCheckGridSizeOnly );
  1073     }
   988     }
  1074 
   989 
  1075 // ---------------------------------------------------------------------------
   990 // ---------------------------------------------------------------------------
  1076 // CThumbnailServer::Fs()
   991 // CThumbnailServer::Fs()
  1077 // ---------------------------------------------------------------------------
   992 // ---------------------------------------------------------------------------
  1146         
  1061         
  1147         // mount -- if removable drive, add new store
  1062         // mount -- if removable drive, add new store
  1148         if (!err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable)
  1063         if (!err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable)
  1149             {
  1064             {
  1150             // ignore errors
  1065             // ignore errors
  1151             TRAP_IGNORE( StoreForDriveL( drive ));
  1066             //TRAP_IGNORE( StoreForDriveL( drive ));
  1152                     
       
  1153             }
  1067             }
  1154         
  1068         
  1155         //dismount -- if removable drive, close store
  1069         //dismount -- if removable drive, close store
  1156         else if(err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable)
  1070         else if(err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable)
  1157             {
  1071             {
  1212 
  1126 
  1213 // -----------------------------------------------------------------------------
  1127 // -----------------------------------------------------------------------------
  1214 // Updates thumbnails by given Id.
  1128 // Updates thumbnails by given Id.
  1215 // -----------------------------------------------------------------------------
  1129 // -----------------------------------------------------------------------------
  1216 //
  1130 //
  1217 TBool CThumbnailServer::UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath,
  1131 TBool CThumbnailServer::UpdateThumbnailsL( const TDesC& aPath,
  1218                                            const TInt /*aOrientation*/, const TInt64 aModified )
  1132                                            const TInt /*aOrientation*/, const TInt64 aModified )
  1219     {
  1133     {
  1220     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()");
  1134     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()");
  1221     
  1135     
  1222     // 1. check path change
  1136     // 1. check path change
  1223     // 2. check orientation change
  1137     // 2. check orientation change
  1224     // 3. check timestamp change
  1138     // 3. check timestamp change
  1225     TBool pathChanged = EFalse;
  1139 
  1226     TBool orientationChanged = EFalse;
  1140     TBool orientationChanged = EFalse;
  1227     TBool modifiedChanged = EFalse;
  1141     TBool modifiedChanged = EFalse;
  1228     
  1142     
  1229     CThumbnailStore* newstore = StoreForPathL( aPath );
  1143     CThumbnailStore* store = StoreForPathL( aPath );
  1230     TInt err(KErrNone);
  1144    
  1231 
  1145     // placeholder for orientation check
  1232     // no path available, can be any store    
  1146     orientationChanged = EFalse;
  1233     THashMapIter<TInt, CThumbnailStore*> iter( iStores );
  1147     
  1234     CThumbnailStore* const *store = iter.NextValue();
  1148     if (orientationChanged)
  1235 
  1149         {
  1236     while ( store )
  1150         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated");
  1237          {     
  1151         
  1238         err = KErrNone;   
  1152         // orientation updated, no need to check further
  1239         
  1153         return ETrue;
  1240         TRAP(err, ((CThumbnailStore*)(*store))->FindStoreL( aItemId ) );
  1154         }
  1241          
  1155     else
  1242          // no need to move thumbs to different store
  1156         {
  1243          if (err == KErrNone && *store == newstore)
  1157         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist");
  1244             {
  1158         
  1245             pathChanged = ((CThumbnailStore*)(*store))->UpdateStoreL(aItemId, aPath);
  1159         TBool exists = store->CheckModifiedByPathL(aPath, aModified, modifiedChanged);
       
  1160        
       
  1161         if(!exists)
       
  1162             {
       
  1163             TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exists NO");
       
  1164             //not found, needs to be generated
       
  1165             return EFalse;
       
  1166             }
       
  1167         
       
  1168         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?");
       
  1169         
       
  1170         if (modifiedChanged)
       
  1171             {
       
  1172             TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES");
  1246             
  1173             
  1247             if (pathChanged)
  1174             // delete old thumbs
  1248                 {
  1175             store->DeleteThumbnailsL(aPath, ETrue);
  1249                 TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - path updated");
       
  1250                 
       
  1251                 // path updated, no need to check further
       
  1252                 return ETrue;
       
  1253                 }
       
  1254             else
       
  1255                 {
       
  1256                 // placeholder for orientation check
       
  1257                 orientationChanged = EFalse;
       
  1258                 
       
  1259                 if (orientationChanged)
       
  1260                     {
       
  1261                     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated");
       
  1262                     
       
  1263                     // orientation updated, no need to check further
       
  1264                     return ETrue;
       
  1265                     }
       
  1266                 else
       
  1267                     {
       
  1268                     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?");
       
  1269                     modifiedChanged = ((CThumbnailStore*)(*store))->CheckModifiedL(aItemId, aModified);
       
  1270                     
       
  1271                     if (modifiedChanged)
       
  1272                         {
       
  1273                         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES");
       
  1274                         
       
  1275                         // delete old thumbs
       
  1276                         ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId);
       
  1277                         
       
  1278                         // need to create new thumbs
       
  1279                         return EFalse;
       
  1280                         }
       
  1281                     else
       
  1282                         {
       
  1283                         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO");
       
  1284                         
       
  1285                         // not modified
       
  1286                         return ETrue;
       
  1287                         }
       
  1288                     }
       
  1289                 }
       
  1290             
  1176             
  1291             }                 
  1177             // need to create new thumbs
  1292          // move to new store
  1178             }
  1293          else if (err == KErrNone && *store != newstore)
  1179         else
  1294             {
  1180             {
  1295             RArray < TThumbnailDatabaseData* >* thumbnails = NULL;
  1181             TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO");
  1296             thumbnails = new (ELeave) RArray < TThumbnailDatabaseData* >;
       
  1297             CleanupClosePushL( *thumbnails );
       
  1298             ((CThumbnailStore*)(*store))->FetchThumbnailsL(aItemId, *thumbnails);
       
  1299             newstore->StoreThumbnailsL(aPath, *thumbnails);
       
  1300             ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId);
       
  1301             CleanupStack::PopAndDestroy( thumbnails);
       
  1302             delete thumbnails;
       
  1303             thumbnails = NULL;
       
  1304             
  1182             
  1305             TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - moved to different store");
  1183             // not modified
  1306             
       
  1307             // no need to check further
       
  1308             return ETrue;
  1184             return ETrue;
  1309             }
  1185             }
  1310          
  1186         }
  1311          store = iter.NextValue();
  1187   
  1312          } 
       
  1313     
  1188     
  1314     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new");
  1189     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new");
  1315     
  1190     
  1316     return EFalse;
  1191     return EFalse;
  1317     }
  1192     }
  1578     __UHEAP_MARKEND;
  1453     __UHEAP_MARKEND;
  1579     return result;
  1454     return result;
  1580     }
  1455     }
  1581 
  1456 
  1582 // -----------------------------------------------------------------------------
  1457 // -----------------------------------------------------------------------------
  1583 // Updates ID for thumbnails with given Path
       
  1584 // -----------------------------------------------------------------------------
       
  1585 //
       
  1586 void CThumbnailServer::UpdateIDL( const TDesC& aPath, const TThumbnailId aNewId )
       
  1587     {
       
  1588     TN_DEBUG3( "CThumbnailServer::UpdateIDL() aPath = %S aId = %d", &aPath, aNewId);
       
  1589     
       
  1590     CThumbnailStore* store = StoreForPathL( aPath );
       
  1591     User::LeaveIfNull( store );
       
  1592     store->UpdateStoreL( aPath, aNewId );
       
  1593     }
       
  1594 
       
  1595 // -----------------------------------------------------------------------------
       
  1596 // Closes stores for removable drives
  1458 // Closes stores for removable drives
  1597 // -----------------------------------------------------------------------------
  1459 // -----------------------------------------------------------------------------
  1598 //
  1460 //
  1599 void CThumbnailServer::CloseRemovableDrivesL()
  1461 void CThumbnailServer::CloseRemovableDrivesL()
  1600     {
  1462     {
  1685         {
  1547         {
  1686         TRAP_IGNORE( OpenRemovableDrivesL() );
  1548         TRAP_IGNORE( OpenRemovableDrivesL() );
  1687         }
  1549         }
  1688     }
  1550     }
  1689 
  1551 
       
  1552 // ---------------------------------------------------------------------------
       
  1553 // CThumbnailServer::ReconnectCallBack()
       
  1554 // ---------------------------------------------------------------------------
       
  1555 //
       
  1556 TInt CThumbnailServer::ReconnectCallBack(TAny* aAny)
       
  1557     {
       
  1558     TN_DEBUG1( "CThumbnailServer::ReconnectCallBack() - reconnect");
       
  1559     
       
  1560     CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny );
       
  1561     
       
  1562     self->iReconnect->Cancel();
       
  1563     
       
  1564     if (self->iMdESession)
       
  1565         {
       
  1566         delete self->iMdESession;
       
  1567         self->iMdESession = NULL;
       
  1568         }
       
  1569     
       
  1570     // reconnect to MDS
       
  1571     TRAP_IGNORE( self->iMdESession = CMdESession::NewL( *self ) );
       
  1572     
       
  1573     TN_DEBUG1( "CThumbAGDaemon::ReconnectCallBack() - done");
       
  1574     
       
  1575     return KErrNone;
       
  1576     }
       
  1577